diff options
| author | Rene Gollent <anevilyak@gmail.com> | 2012-07-22 15:53:19 -0400 |
|---|---|---|
| committer | Rene Gollent <anevilyak@gmail.com> | 2012-07-22 15:53:19 -0400 |
| commit | d7ed9414a3260efaed0fa9de5dde9bb8c0bc11ef (patch) | |
| tree | f1693fa9adc684b532c60abd93ddb069b1f9ac32 | |
| parent | 7e67ec90a46ec4202ab7e4f7b0e07cf398200f45 (diff) | |
- When the message filter would receive and process a mouse moved message,
if the message resulted in causing the deskbar to relocate or reorient
itself, it was possible for the expando view to become detached from
the looper. Consequently, if the intercepted mouse moved happened to have
come from the latter, when returning out of the filter the view would no
longer have a target looper, triggering a debugger condition in BLooper.
In order to prevent this situation, we now dispatch a message asking for
the layout change to occur asynchronously.
| -rw-r--r-- | src/apps/deskbar/BarView.cpp | 77 | ||||
| -rw-r--r-- | src/apps/deskbar/BarView.h | 5 | ||||
| -rw-r--r-- | src/apps/deskbar/StatusView.cpp | 2 |
3 files changed, 61 insertions, 23 deletions
diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp index 8fb1715936..44248e06d0 100644 --- a/src/apps/deskbar/BarView.cpp +++ b/src/apps/deskbar/BarView.cpp @@ -69,6 +69,8 @@ const int32 kDefaultRecentAppCount = 10; const int32 kMenuTrackMargin = 20; +const uint32 kUpdateOrientation = 'UpOr'; + class BarViewMessageFilter : public BMessageFilter { @@ -102,7 +104,7 @@ BarViewMessageFilter::Filter(BMessage* message, BHandler** target) if (message->what == B_MOUSE_DOWN || message->what == B_MOUSE_MOVED) { BPoint where = message->FindPoint("be:view_where"); uint32 transit = message->FindInt32("be:transit"); - BMessage *dragMessage = NULL; + BMessage* dragMessage = NULL; if (message->HasMessage("be:drag_message")) { dragMessage = new BMessage(); message->FindMessage("be:drag_message", dragMessage); @@ -140,7 +142,8 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, fCachedTypesList(NULL), fMaxRecentDocs(kDefaultRecentDocCount), fMaxRecentApps(kDefaultRecentAppCount), - fLastDragItem(NULL) + fLastDragItem(NULL), + fMouseFilter(NULL) { fReplicantTray = new TReplicantTray(this, fVertical); fDragRegion = new TDragRegion(this, fReplicantTray); @@ -167,7 +170,8 @@ TBarView::AttachedToWindow() SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); SetFont(be_plain_font); - Window()->AddCommonFilter(new BarViewMessageFilter(this)); + fMouseFilter = new BarViewMessageFilter(this); + Window()->AddCommonFilter(fMouseFilter); UpdatePlacement(); @@ -180,6 +184,9 @@ TBarView::AttachedToWindow() void TBarView::DetachedFromWindow() { + Window()->RemoveCommonFilter(fMouseFilter); + delete fMouseFilter; + fMouseFilter = NULL; delete fTrackingHookData.fDragMessage; fTrackingHookData.fDragMessage = NULL; } @@ -232,6 +239,12 @@ TBarView::MessageReceived(BMessage* message) break; } + case kUpdateOrientation: + { + _ChangeState(message); + break; + } + default: BView::MessageReceived(message); } @@ -588,25 +601,19 @@ TBarView::UpdatePlacement() void -TBarView::ChangeState(int32 state, bool vertical, bool left, bool top) +TBarView::ChangeState(int32 state, bool vertical, bool left, bool top, + bool async) { - bool vertSwap = (fVertical != vertical); - bool leftSwap = (fLeft != left); - bool stateChanged = (fState != state); - - fState = state; - fVertical = vertical; - fLeft = left; - fTop = top; - - // Send a message to the preferences window to let it know to enable - // or disable preference items - if (stateChanged || vertSwap) - be_app->PostMessage(kStateChanged); - - PlaceDeskbarMenu(); - PlaceTray(vertSwap, leftSwap); - PlaceApplicationBar(); + BMessage message(kUpdateOrientation); + message.AddInt32("state", state); + message.AddBool("vertical", vertical); + message.AddBool("left", left); + message.AddBool("top", top); + + if (async) + BMessenger(this).SendMessage(&message); + else + _ChangeState(&message); } @@ -678,6 +685,34 @@ TBarView::ExpandItems() void +TBarView::_ChangeState(BMessage* message) +{ + int32 state = message->FindInt32("state"); + bool vertical = message->FindBool("vertical"); + bool left = message->FindBool("left"); + bool top = message->FindBool("top"); + + bool vertSwap = (fVertical != vertical); + bool leftSwap = (fLeft != left); + bool stateChanged = (fState != state); + + fState = state; + fVertical = vertical; + fLeft = left; + fTop = top; + + // Send a message to the preferences window to let it know to enable + // or disable preference items + if (stateChanged || vertSwap) + be_app->PostMessage(kStateChanged); + + PlaceDeskbarMenu(); + PlaceTray(vertSwap, leftSwap); + PlaceApplicationBar(); +} + + +void TBarView::AddExpandedItem(const char* signature) { bool shouldAdd = true; diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index 293bed7ea5..f375c872d4 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -90,7 +90,8 @@ class TBarView : public BView { void SaveSettings(); void UpdatePlacement(); - void ChangeState(int32 state, bool vertical, bool left, bool top); + void ChangeState(int32 state, bool vertical, bool left, bool top, + bool aSync = false); void RaiseDeskbar(bool raise); void HideDeskbar(bool hide); @@ -165,6 +166,7 @@ class TBarView : public BView { void SaveExpandedItems(); void RemoveExpandedItems(); void ExpandItems(); + void _ChangeState(BMessage* message); TBarMenuBar* fBarMenuBar; TExpandoMenuBar* fExpando; @@ -190,6 +192,7 @@ class TBarView : public BView { TTeamMenuItem* fLastDragItem; BList fExpandedItems; + BMessageFilter* fMouseFilter; }; diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index e32b769839..4b2df60065 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -1483,7 +1483,7 @@ TDragRegion::SwitchModeForRect(BPoint mouse, BRect rect, return true; } - fBarView->ChangeState(newState, newVertical, newLeft, newTop); + fBarView->ChangeState(newState, newVertical, newLeft, newTop, true); return true; } |
