Window moving and resizing resumed
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11661 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -48,6 +48,7 @@
|
|||||||
#include "FMWList.h"
|
#include "FMWList.h"
|
||||||
#include "DisplayDriver.h"
|
#include "DisplayDriver.h"
|
||||||
#include "ServerProtocol.h"
|
#include "ServerProtocol.h"
|
||||||
|
#include "Decorator.h"
|
||||||
|
|
||||||
//#define DEBUG_ROOTLAYER
|
//#define DEBUG_ROOTLAYER
|
||||||
|
|
||||||
@@ -74,6 +75,8 @@ RootLayer::RootLayer(const char *name, int32 workspaceCount,
|
|||||||
SetWorkspaceCount(workspaceCount);
|
SetWorkspaceCount(workspaceCount);
|
||||||
SetActiveWorkspace(0L);
|
SetActiveWorkspace(0L);
|
||||||
|
|
||||||
|
fMovingWindow = false;
|
||||||
|
fResizingWindow = false;
|
||||||
fMouseTarget = NULL;
|
fMouseTarget = NULL;
|
||||||
fDragMessage = NULL;
|
fDragMessage = NULL;
|
||||||
fScreenShotIndex = 1;
|
fScreenShotIndex = 1;
|
||||||
@@ -881,19 +884,52 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg)
|
|||||||
msg.Read<int32>(&evt.buttons);
|
msg.Read<int32>(&evt.buttons);
|
||||||
msg.Read<int32>(&evt.clicks);
|
msg.Read<int32>(&evt.clicks);
|
||||||
|
|
||||||
|
WinBorder *target = WinBorderAt(evt.where);
|
||||||
|
if (target)
|
||||||
|
{
|
||||||
|
click_type action;
|
||||||
|
bool invalidate;
|
||||||
|
bool sendMessage = true;
|
||||||
|
|
||||||
|
action = target->TellWhat(evt);
|
||||||
|
|
||||||
|
if (action == DEC_MOVETOBACK)
|
||||||
|
invalidate = ActiveWorkspace()->MoveToBack(target);
|
||||||
|
else
|
||||||
|
invalidate = ActiveWorkspace()->MoveToFront(target);
|
||||||
|
|
||||||
|
if (invalidate)
|
||||||
|
{
|
||||||
|
BRegion reg(target->fFull);
|
||||||
|
reg.Include(&target->fTopLayer->fFull);
|
||||||
|
invalidate_layer(this, reg);
|
||||||
|
|
||||||
|
if (!(target->Window()->Flags() & B_WILL_ACCEPT_FIRST_CLICK))
|
||||||
|
sendMessage = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action == DEC_DRAG)
|
||||||
|
{
|
||||||
|
fMovingWindow = true;
|
||||||
|
}
|
||||||
|
else if (action == DEC_RESIZE)
|
||||||
|
{
|
||||||
|
fResizingWindow = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
target->Window()->Lock();
|
||||||
|
target->MouseDown(evt, sendMessage);
|
||||||
|
target->Window()->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
fMouseTarget = target;
|
||||||
|
}
|
||||||
|
|
||||||
// We'll need this so that GetMouse can query for which buttons
|
// We'll need this so that GetMouse can query for which buttons
|
||||||
// are down.
|
// are down.
|
||||||
fButtons=evt.buttons;
|
fButtons=evt.buttons;
|
||||||
|
|
||||||
// printf("MOUSE DOWN: at (%f, %f)\n", evt.where.x, evt.where.y);
|
|
||||||
WinBorder *target = WinBorderAt(evt.where);
|
|
||||||
if (target)
|
|
||||||
{
|
|
||||||
target->Window()->Lock();
|
|
||||||
target->MouseDown(evt, true);
|
|
||||||
target->Window()->Unlock();
|
|
||||||
fMouseTarget = target;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_MOUSE_UP:
|
case B_MOUSE_UP:
|
||||||
@@ -911,14 +947,18 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg)
|
|||||||
msg.Read<float>(&evt.where.y);
|
msg.Read<float>(&evt.where.y);
|
||||||
msg.Read<int32>(&evt.modifiers);
|
msg.Read<int32>(&evt.modifiers);
|
||||||
|
|
||||||
fMouseTarget = NULL;
|
// currently mouse up goes to the same window which received mouse down
|
||||||
WinBorder *target = WinBorderAt(evt.where);
|
if (fMouseTarget)
|
||||||
if (target)
|
|
||||||
{
|
{
|
||||||
target->Window()->Lock();
|
fMouseTarget->Window()->Lock();
|
||||||
target->MouseUp(evt);
|
fMouseTarget->MouseUp(evt);
|
||||||
target->Window()->Unlock();
|
fMouseTarget->Window()->Unlock();
|
||||||
|
fMouseTarget = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fMovingWindow = false;
|
||||||
|
fResizingWindow = false;
|
||||||
|
|
||||||
STRACE(("MOUSE UP: at (%f, %f)\n", evt.where.x, evt.where.y));
|
STRACE(("MOUSE UP: at (%f, %f)\n", evt.where.x, evt.where.y));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -940,6 +980,34 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg)
|
|||||||
|
|
||||||
GetDisplayDriver()->MoveCursorTo(evt.where.x, evt.where.y);
|
GetDisplayDriver()->MoveCursorTo(evt.where.x, evt.where.y);
|
||||||
|
|
||||||
|
if (fMouseTarget)
|
||||||
|
{
|
||||||
|
BPoint pt = evt.where;
|
||||||
|
pt -= fLastMousePossition;
|
||||||
|
|
||||||
|
if (fMovingWindow)
|
||||||
|
{
|
||||||
|
if(fMouseTarget->fDecorator)
|
||||||
|
fMouseTarget->fDecorator->MoveBy(pt.x, pt.y);
|
||||||
|
|
||||||
|
fMouseTarget->move_layer(pt.x, pt.y);
|
||||||
|
}
|
||||||
|
else if (fResizingWindow)
|
||||||
|
{
|
||||||
|
if(fMouseTarget->fDecorator)
|
||||||
|
fMouseTarget->fDecorator->ResizeBy(pt.x, pt.y);
|
||||||
|
|
||||||
|
fMouseTarget->resize_layer(pt.x, pt.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fMouseTarget->Window()->Lock();
|
||||||
|
fMouseTarget->MouseMoved(evt);
|
||||||
|
fMouseTarget->Window()->Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
WinBorder *target = WinBorderAt(evt.where);
|
WinBorder *target = WinBorderAt(evt.where);
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
@@ -947,6 +1015,9 @@ void RootLayer::MouseEventHandler(int32 code, BPortLink& msg)
|
|||||||
target->MouseMoved(evt);
|
target->MouseMoved(evt);
|
||||||
target->Window()->Unlock();
|
target->Window()->Unlock();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fLastMousePossition = evt.where;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,6 +155,9 @@ friend class Desktop;
|
|||||||
int32 fScreenYResolution;
|
int32 fScreenYResolution;
|
||||||
uint32 fColorSpace;
|
uint32 fColorSpace;
|
||||||
int32 fButtons;
|
int32 fButtons;
|
||||||
|
BPoint fLastMousePossition;
|
||||||
|
bool fMovingWindow;
|
||||||
|
bool fResizingWindow;
|
||||||
|
|
||||||
int32 fActiveWksIndex;
|
int32 fActiveWksIndex;
|
||||||
int32 fWsCount;
|
int32 fWsCount;
|
||||||
|
|||||||
@@ -93,8 +93,6 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
|
|||||||
fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT;
|
fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT;
|
||||||
fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE;
|
fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE;
|
||||||
|
|
||||||
fIsMoving = false;
|
|
||||||
fIsResizing = false;
|
|
||||||
fIsClosing = false;
|
fIsClosing = false;
|
||||||
fIsMinimizing = false;
|
fIsMinimizing = false;
|
||||||
fIsZooming = false;
|
fIsZooming = false;
|
||||||
@@ -144,6 +142,16 @@ void WinBorder::RebuildFullRegion(void)
|
|||||||
fDecorator->GetFootprint(&fFull);
|
fDecorator->GetFootprint(&fFull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
click_type WinBorder::TellWhat(PointerEvent& evt) const
|
||||||
|
{
|
||||||
|
if (fTopLayer->fFullVisible.Contains(evt.where))
|
||||||
|
return DEC_NONE;
|
||||||
|
else if (fDecorator)
|
||||||
|
return fDecorator->Clicked(evt.where, evt.buttons, evt.modifiers);
|
||||||
|
else
|
||||||
|
return DEC_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Handles B_MOUSE_DOWN events and takes appropriate actions
|
\brief Handles B_MOUSE_DOWN events and takes appropriate actions
|
||||||
\param evt PointerEvent object containing the info from the last B_MOUSE_DOWN message
|
\param evt PointerEvent object containing the info from the last B_MOUSE_DOWN message
|
||||||
@@ -197,20 +205,10 @@ void WinBorder::MouseDown(PointerEvent& evt, bool sendMessage)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEC_RESIZE:
|
case DEC_RESIZE:
|
||||||
{
|
|
||||||
fIsResizing = true;
|
|
||||||
STRACE_CLICK(("===> DEC_RESIZE\n"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DEC_DRAG:
|
case DEC_DRAG:
|
||||||
{
|
|
||||||
fIsMoving = true;
|
|
||||||
STRACE_CLICK(("===> DEC_DRAG\n"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DEC_MOVETOBACK:
|
case DEC_MOVETOBACK:
|
||||||
{
|
{
|
||||||
GetRootLayer()->ActiveWorkspace()->MoveToBack(this);
|
// do nothing - RootLayer takes care of that
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DEC_NONE:
|
case DEC_NONE:
|
||||||
@@ -254,23 +252,6 @@ void WinBorder::MouseMoved(PointerEvent& evt)
|
|||||||
if (!(Window()->IsLocked()))
|
if (!(Window()->IsLocked()))
|
||||||
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseMoved()\n");
|
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseMoved()\n");
|
||||||
|
|
||||||
if (fIsMoving)
|
|
||||||
{
|
|
||||||
STRACE_CLICK(("===> Moving...\n"));
|
|
||||||
BPoint offset = evt.where;
|
|
||||||
offset -= fLastMousePosition;
|
|
||||||
MoveBy(offset.x, offset.y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (fIsResizing)
|
|
||||||
{
|
|
||||||
STRACE_CLICK(("===> Resizing...\n"));
|
|
||||||
BPoint offset = evt.where;
|
|
||||||
offset -= fLastMousePosition;
|
|
||||||
ResizeBy(offset.x, offset.y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Do a click test only if we have to, which would be now. :)
|
// Do a click test only if we have to, which would be now. :)
|
||||||
click_type location=fDecorator->Clicked(evt.where, evt.buttons,fKeyModifiers);
|
click_type location=fDecorator->Clicked(evt.where, evt.buttons,fKeyModifiers);
|
||||||
|
|
||||||
@@ -291,7 +272,6 @@ void WinBorder::MouseMoved(PointerEvent& evt)
|
|||||||
fDecorator->SetMinimize(false);
|
fDecorator->SetMinimize(false);
|
||||||
fDecorator->DrawMinimize();
|
fDecorator->DrawMinimize();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fTopLayer->fFullVisible.Contains(evt.where))
|
if (fTopLayer->fFullVisible.Contains(evt.where))
|
||||||
{
|
{
|
||||||
@@ -324,18 +304,6 @@ void WinBorder::MouseUp(PointerEvent& evt)
|
|||||||
// find out where user clicked in Decorator
|
// find out where user clicked in Decorator
|
||||||
action = fDecorator->Clicked(evt.where, evt.buttons, evt.modifiers);
|
action = fDecorator->Clicked(evt.where, evt.buttons, evt.modifiers);
|
||||||
|
|
||||||
if(fIsMoving)
|
|
||||||
{
|
|
||||||
fIsMoving = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fIsResizing)
|
|
||||||
{
|
|
||||||
fIsResizing = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fIsZooming)
|
if (fIsZooming)
|
||||||
{
|
{
|
||||||
fIsZooming = false;
|
fIsZooming = false;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "FMWList.h"
|
#include "FMWList.h"
|
||||||
|
#include "Decorator.h"
|
||||||
|
|
||||||
// these are used by window manager to properly place window.
|
// these are used by window manager to properly place window.
|
||||||
enum {
|
enum {
|
||||||
@@ -80,6 +81,7 @@ public:
|
|||||||
|
|
||||||
void SetSizeLimits(float minwidth, float maxwidth, float minheight, float maxheight);
|
void SetSizeLimits(float minwidth, float maxwidth, float minheight, float maxheight);
|
||||||
|
|
||||||
|
click_type TellWhat(PointerEvent& evt) const;
|
||||||
void MouseDown(PointerEvent& evt, bool sendMessage);
|
void MouseDown(PointerEvent& evt, bool sendMessage);
|
||||||
void MouseMoved(PointerEvent& evt);
|
void MouseMoved(PointerEvent& evt);
|
||||||
void MouseUp(PointerEvent& evt);
|
void MouseUp(PointerEvent& evt);
|
||||||
@@ -114,8 +116,6 @@ protected:
|
|||||||
int32 fKeyModifiers;
|
int32 fKeyModifiers;
|
||||||
BPoint fLastMousePosition;
|
BPoint fLastMousePosition;
|
||||||
|
|
||||||
bool fIsMoving;
|
|
||||||
bool fIsResizing;
|
|
||||||
bool fIsClosing;
|
bool fIsClosing;
|
||||||
bool fIsMinimizing;
|
bool fIsMinimizing;
|
||||||
bool fIsZooming;
|
bool fIsZooming;
|
||||||
|
|||||||
Reference in New Issue
Block a user