- 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.
This commit is contained in:
Rene Gollent
2012-07-22 15:53:19 -04:00
parent 7e67ec90a4
commit d7ed9414a3
3 changed files with 60 additions and 22 deletions
+55 -20
View File
@@ -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);
BMessage message(kUpdateOrientation);
message.AddInt32("state", state);
message.AddBool("vertical", vertical);
message.AddBool("left", left);
message.AddBool("top", top);
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();
if (async)
BMessenger(this).SendMessage(&message);
else
_ChangeState(&message);
}
@@ -677,6 +684,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)
{
+4 -1
View File
@@ -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;
};
+1 -1
View File
@@ -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;
}