From 33da1e65164819b81d2a0fb58c53a5a9411bfedf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 21 Apr 2010 07:46:12 +0000 Subject: [PATCH] * Cleaned up MouseDown(), and fixed crash #5121 based on a patch by DarkWyrm, thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36389 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/deskbar/ExpandoMenuBar.cpp | 72 +++++++++++++---------------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 6a34b080b2..b390f06b4b 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -302,16 +302,14 @@ TExpandoMenuBar::MouseDown(BPoint where) TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem); // check for three finger salute, a.k.a. Vulcan Death Grip - if (message != NULL) { + if (message != NULL && item != NULL && !fBarView->Dragging()) { int32 modifiers = 0; message->FindInt32("modifiers", &modifiers); if ((modifiers & B_COMMAND_KEY) != 0 && (modifiers & B_OPTION_KEY) != 0 - && (modifiers & B_SHIFT_KEY) != 0 - && !fBarView->Dragging() - && item != NULL) { - const BList *teams = item->Teams(); + && (modifiers & B_SHIFT_KEY) != 0) { + const BList* teams = item->Teams(); int32 teamCount = teams->CountItems(); team_id teamID; @@ -324,50 +322,44 @@ TExpandoMenuBar::MouseDown(BPoint where) return; } - } - // control click - show all/hide all shortcut - int32 modifiers; - if (message != NULL && message->FindInt32("modifiers", &modifiers) == B_OK - && (modifiers & B_CONTROL_KEY) != 0 - && !fBarView->Dragging() - && item != NULL) { - // show/hide item's teams - BMessage showMessage((modifiers & B_SHIFT_KEY) != 0 - ? kMinimizeTeam : kBringTeamToFront); - showMessage.AddInt32("itemIndex", IndexOf(item)); - Window()->PostMessage(&showMessage, this); - return; - } - - // Check the bounds of the expand Team icon - if (fShowTeamExpander && fVertical && !fBarView->Dragging() - && item != NULL) { - BRect expanderRect = item->ExpanderBounds(); - if (expanderRect.Contains(where)) { - // Let the update thread wait... - BAutolock locker(sMonLocker); - - // Toggle the item - item->ToggleExpandState(true); - item->Draw(); - - // Absorb the message. + // control click - show all/hide all shortcut + if ((modifiers & B_CONTROL_KEY) != 0) { + // show/hide item's teams + BMessage showMessage((modifiers & B_SHIFT_KEY) != 0 + ? kMinimizeTeam : kBringTeamToFront); + showMessage.AddInt32("itemIndex", IndexOf(item)); + Window()->PostMessage(&showMessage, this); return; } - } - // double-click on an item brings the team to front - int32 clicks; - if (message != NULL && message->FindInt32("clicks", &clicks) == B_OK - && clicks > 1) { - if (item == menuItem && item == fLastClickItem) { + // Check the bounds of the expand Team icon + if (fShowTeamExpander && fVertical) { + BRect expanderRect = item->ExpanderBounds(); + if (expanderRect.Contains(where)) { + // Let the update thread wait... + BAutolock locker(sMonLocker); + + // Toggle the item + item->ToggleExpandState(true); + item->Draw(); + + // Absorb the message. + return; + } + } + + // double-click on an item brings the team to front + int32 clicks; + if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1 + && item == menuItem && item == fLastClickItem) { // activate this team be_roster->ActivateApp((team_id)item->Teams()->ItemAt(0)); return; } - } else + fLastClickItem = item; + } BMenuBar::MouseDown(where); }