Always use the current decorator. This partially fix bug #6334.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37608 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Clemens Zeidler 2010-07-20 00:58:11 +00:00
parent 66d288a959
commit 30c31ae28a
3 changed files with 38 additions and 32 deletions

View File

@ -28,11 +28,9 @@
#endif #endif
DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window, DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window)
Decorator* decorator)
: :
fWindow(window), fWindow(window),
fDecorator(decorator),
fIsClosing(false), fIsClosing(false),
fIsMinimizing(false), fIsMinimizing(false),
@ -61,10 +59,12 @@ static const bigtime_t kWindowActivationTimeout = 500000LL;
bool bool
DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where) DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
{ {
Decorator* decorator = fWindow->Decorator();
int32 modifiers = _ExtractModifiers(message); int32 modifiers = _ExtractModifiers(message);
bool inBorderRegion = false; bool inBorderRegion = false;
if (fWindow->Decorator()) if (fWindow->Decorator())
inBorderRegion = fWindow->Decorator()->GetFootprint().Contains(where); inBorderRegion = decorator->GetFootprint().Contains(where);
bool windowModifier = bool windowModifier =
(fWindow->Flags() & B_NO_SERVER_SIDE_WINDOW_MODIFIERS) == 0 (fWindow->Flags() & B_NO_SERVER_SIDE_WINDOW_MODIFIERS) == 0
&& (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY && (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
@ -82,7 +82,7 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0)
action = CLICK_MOVE_TO_BACK; action = CLICK_MOVE_TO_BACK;
else if ((fWindow->Flags() & B_NOT_MOVABLE) == 0 else if ((fWindow->Flags() & B_NOT_MOVABLE) == 0
&& fDecorator != NULL) && decorator != NULL)
action = CLICK_DRAG; action = CLICK_DRAG;
else { else {
// pass click on to the application // pass click on to the application
@ -143,22 +143,22 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
break; break;
} }
if (fDecorator != NULL) { if (decorator != NULL) {
// redraw decorator // redraw decorator
BRegion* visibleBorder = fWindow->RegionPool()->GetRegion(); BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
fWindow->GetBorderRegion(visibleBorder); fWindow->GetBorderRegion(visibleBorder);
visibleBorder->IntersectWith(&fWindow->VisibleRegion()); visibleBorder->IntersectWith(&fWindow->VisibleRegion());
DrawingEngine* engine = fDecorator->GetDrawingEngine(); DrawingEngine* engine = decorator->GetDrawingEngine();
engine->LockParallelAccess(); engine->LockParallelAccess();
engine->ConstrainClippingRegion(visibleBorder); engine->ConstrainClippingRegion(visibleBorder);
if (fIsZooming) if (fIsZooming)
fDecorator->SetZoom(true); decorator->SetZoom(true);
else if (fIsClosing) else if (fIsClosing)
fDecorator->SetClose(true); decorator->SetClose(true);
else if (fIsMinimizing) else if (fIsMinimizing)
fDecorator->SetMinimize(true); decorator->SetMinimize(true);
engine->UnlockParallelAccess(); engine->UnlockParallelAccess();
@ -206,8 +206,10 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
void void
DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where) DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
{ {
Decorator* decorator = fWindow->Decorator();
bool invalidate = false; bool invalidate = false;
if (fDecorator) { if (decorator) {
click_type action = _ActionFor(message); click_type action = _ActionFor(message);
// redraw decorator // redraw decorator
@ -215,13 +217,13 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
fWindow->GetBorderRegion(visibleBorder); fWindow->GetBorderRegion(visibleBorder);
visibleBorder->IntersectWith(&fWindow->VisibleRegion()); visibleBorder->IntersectWith(&fWindow->VisibleRegion());
DrawingEngine* engine = fDecorator->GetDrawingEngine(); DrawingEngine* engine = decorator->GetDrawingEngine();
engine->LockParallelAccess(); engine->LockParallelAccess();
engine->ConstrainClippingRegion(visibleBorder); engine->ConstrainClippingRegion(visibleBorder);
if (fIsZooming) { if (fIsZooming) {
fIsZooming = false; fIsZooming = false;
fDecorator->SetZoom(false); decorator->SetZoom(false);
if (action == CLICK_ZOOM) { if (action == CLICK_ZOOM) {
invalidate = true; invalidate = true;
fWindow->ServerWindow()->NotifyZoom(); fWindow->ServerWindow()->NotifyZoom();
@ -229,7 +231,7 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
} }
if (fIsClosing) { if (fIsClosing) {
fIsClosing = false; fIsClosing = false;
fDecorator->SetClose(false); decorator->SetClose(false);
if (action == CLICK_CLOSE) { if (action == CLICK_CLOSE) {
invalidate = true; invalidate = true;
fWindow->ServerWindow()->NotifyQuitRequested(); fWindow->ServerWindow()->NotifyQuitRequested();
@ -237,7 +239,7 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
} }
if (fIsMinimizing) { if (fIsMinimizing) {
fIsMinimizing = false; fIsMinimizing = false;
fDecorator->SetMinimize(false); decorator->SetMinimize(false);
if (action == CLICK_MINIMIZE) { if (action == CLICK_MINIMIZE) {
invalidate = true; invalidate = true;
fWindow->ServerWindow()->NotifyMinimize(true); fWindow->ServerWindow()->NotifyMinimize(true);
@ -277,9 +279,11 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
void void
DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake) DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
{ {
Decorator* decorator = fWindow->Decorator();
#if 0 #if 0
if (fDecorator != NULL && fWindow->TopView() != NULL) { if (decorator != NULL && fWindow->TopView() != NULL) {
DrawingEngine* engine = fDecorator->GetDrawingEngine(); DrawingEngine* engine = decorator->GetDrawingEngine();
engine->LockParallelAccess(); engine->LockParallelAccess();
engine->ConstrainClippingRegion(&fWindow->VisibleRegion()); engine->ConstrainClippingRegion(&fWindow->VisibleRegion());
@ -306,21 +310,21 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
fLastMoveTime = now; fLastMoveTime = now;
} }
if (fDecorator) { if (decorator) {
BRegion* visibleBorder = fWindow->RegionPool()->GetRegion(); BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
fWindow->GetBorderRegion(visibleBorder); fWindow->GetBorderRegion(visibleBorder);
visibleBorder->IntersectWith(&fWindow->VisibleRegion()); visibleBorder->IntersectWith(&fWindow->VisibleRegion());
DrawingEngine* engine = fDecorator->GetDrawingEngine(); DrawingEngine* engine = decorator->GetDrawingEngine();
engine->LockParallelAccess(); engine->LockParallelAccess();
engine->ConstrainClippingRegion(visibleBorder); engine->ConstrainClippingRegion(visibleBorder);
if (fIsZooming) { if (fIsZooming) {
fDecorator->SetZoom(_ActionFor(message) == CLICK_ZOOM); decorator->SetZoom(_ActionFor(message) == CLICK_ZOOM);
} else if (fIsClosing) { } else if (fIsClosing) {
fDecorator->SetClose(_ActionFor(message) == CLICK_CLOSE); decorator->SetClose(_ActionFor(message) == CLICK_CLOSE);
} else if (fIsMinimizing) { } else if (fIsMinimizing) {
fDecorator->SetMinimize(_ActionFor(message) == CLICK_MINIMIZE); decorator->SetMinimize(_ActionFor(message) == CLICK_MINIMIZE);
} }
engine->UnlockParallelAccess(); engine->UnlockParallelAccess();
@ -426,7 +430,9 @@ DefaultWindowBehaviour::_ExtractModifiers(const BMessage* message) const
click_type click_type
DefaultWindowBehaviour::_ActionFor(const BMessage* message) const DefaultWindowBehaviour::_ActionFor(const BMessage* message) const
{ {
if (fDecorator == NULL) Decorator* decorator = fWindow->Decorator();
if (decorator == NULL)
return CLICK_NONE; return CLICK_NONE;
int32 buttons = _ExtractButtons(message); int32 buttons = _ExtractButtons(message);
@ -439,14 +445,16 @@ click_type
DefaultWindowBehaviour::_ActionFor(const BMessage* message, int32 buttons, DefaultWindowBehaviour::_ActionFor(const BMessage* message, int32 buttons,
int32 modifiers) const int32 modifiers) const
{ {
if (fDecorator == NULL) Decorator* decorator = fWindow->Decorator();
if (decorator == NULL)
return CLICK_NONE; return CLICK_NONE;
BPoint where; BPoint where;
if (message->FindPoint("where", &where) != B_OK) if (message->FindPoint("where", &where) != B_OK)
return CLICK_NONE; return CLICK_NONE;
return fDecorator->Clicked(where, buttons, modifiers); return decorator->Clicked(where, buttons, modifiers);
} }
@ -472,8 +480,9 @@ DefaultWindowBehaviour::_AlterDeltaForSnap(BPoint& delta, bigtime_t now)
// TODO: Perhaps obtain the usable area (not covered by the Deskbar)? // TODO: Perhaps obtain the usable area (not covered by the Deskbar)?
BRect screenFrame = fWindow->Screen()->Frame(); BRect screenFrame = fWindow->Screen()->Frame();
if (fDecorator) { Decorator* decorator = fWindow->Decorator();
frame = fDecorator->GetFootprint().Frame(); if (decorator) {
frame = decorator->GetFootprint().Frame();
offsetWithinFrame.x = fWindow->Frame().left - frame.left; offsetWithinFrame.x = fWindow->Frame().left - frame.left;
offsetWithinFrame.y = fWindow->Frame().top - frame.top; offsetWithinFrame.y = fWindow->Frame().top - frame.top;
} }

View File

@ -27,8 +27,7 @@ class Window;
class DefaultWindowBehaviour : public WindowBehaviour class DefaultWindowBehaviour : public WindowBehaviour
{ {
public: public:
DefaultWindowBehaviour(Window* window, DefaultWindowBehaviour(Window* window);
Decorator* decorator);
virtual ~DefaultWindowBehaviour(); virtual ~DefaultWindowBehaviour();
virtual bool MouseDown(BMessage* message, BPoint where); virtual bool MouseDown(BMessage* message, BPoint where);
@ -38,7 +37,6 @@ class DefaultWindowBehaviour : public WindowBehaviour
protected: protected:
Window* fWindow; Window* fWindow;
Decorator* fDecorator;
Desktop* fDesktop; Desktop* fDesktop;
bool fIsClosing : 1; bool fIsClosing : 1;

View File

@ -135,8 +135,7 @@ Window::Window(const BRect& frame, const char *name,
&fMaxWidth, &fMaxHeight); &fMaxWidth, &fMaxHeight);
} }
} }
fWindowBehaviour = new (std::nothrow)DefaultWindowBehaviour(this, fWindowBehaviour = new (std::nothrow)DefaultWindowBehaviour(this);
fDecorator);
// do we need to change our size to let the decorator fit? // do we need to change our size to let the decorator fit?
// _ResizeBy() will adapt the frame for validity before resizing // _ResizeBy() will adapt the frame for validity before resizing