From 415c63bee290da0d064c5102d5e32b7f4ffe3aef Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 15 Apr 2006 16:57:51 +0000 Subject: [PATCH] PopUpMenus didn't respect the openanyway setting (sticky mode), they always set it. And even in that case, they weren't working correctly. This should fix bugs 463 and 476. This might not work if click to open isn't selected in the menu prefs, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17136 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Menu.cpp | 17 ++++++++--------- src/kits/interface/PopUpMenu.cpp | 8 ++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index f69a725a33..40c951465e 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -959,14 +959,9 @@ BMenu::Hide() BMenuItem * -BMenu::Track(bool openAnyway, BRect *clickToOpenRect) -{ - if (!IsStickyPrefOn()) - openAnyway = false; - - SetStickyMode(openAnyway); - - if (openAnyway && LockLooper()) { +BMenu::Track(bool sticky, BRect *clickToOpenRect) +{ + if (sticky && LockLooper()) { RedrawAfterSticky(Bounds()); UnlockLooper(); } @@ -977,8 +972,12 @@ BMenu::Track(bool openAnyway, BRect *clickToOpenRect) UnlockLooper(); } + // If sticky is false, pass 0 to the tracking function + // so the menu will stay in nonsticky mode, regardless + // of the "IsStickyPrefOn()" value + const bigtime_t trackTime = sticky ? system_time() : 0; int action; - BMenuItem *menuItem = _track(&action, system_time()); + BMenuItem *menuItem = _track(&action, trackTime); SetStickyMode(false); fExtraRect = NULL; diff --git a/src/kits/interface/PopUpMenu.cpp b/src/kits/interface/PopUpMenu.cpp index a46a8c7d7c..504b8b76a4 100644 --- a/src/kits/interface/PopUpMenu.cpp +++ b/src/kits/interface/PopUpMenu.cpp @@ -267,6 +267,14 @@ BMenuItem * BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened, BRect *_specialRect, bool async) { + if (fTrackThread >= 0) { + // Something bad happened: Go() was called on us twice, and we got here + // while the other instance hasn't finished yet. + // TODO: Maybe we should simply call debugger() ? + status_t unused; + wait_for_thread(fTrackThread, &unused); + } + BMenuItem *selected = NULL; // Can't use Window(), as the BPopUpMenu isn't attached