Change the order we use to check the position of the mouse pointer

inside menus: first sub, then current, then super. It's more logical, 
and handles every case (hopefully I've tested every possible 
combination) of overlapping menus correctly.
Fixes bug #1821.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24044 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2008-02-21 10:10:17 +00:00
parent 5ed8d60d1a
commit 47d3c50607
1 changed files with 14 additions and 15 deletions

View File

@ -1424,13 +1424,14 @@ BMenu::_Track(int *action, long start)
continue; continue;
} }
// The order of the checks is important
// to be able to handle overlapping menus:
// first we check if mouse is inside a submenu,
// then if the menu is inside this menu,
// then if it's over a super menu.
bool overSub = _OverSubmenu(fSelected, screenLocation);
item = _HitTestItems(location, B_ORIGIN); item = _HitTestItems(location, B_ORIGIN);
if (item != NULL) { if (overSub) {
_UpdateStateOpenSelect(item, openTime, mouseSpeed);
if (!releasedOnce)
releasedOnce = true;
} else if (_OverSubmenu(fSelected, screenLocation)) {
// Since the submenu has its own looper, // Since the submenu has its own looper,
// we can unlock ours. Doing so also make sure // we can unlock ours. Doing so also make sure
// that our window gets any update message to // that our window gets any update message to
@ -1450,11 +1451,15 @@ BMenu::_Track(int *action, long start)
fState = MENU_STATE_CLOSED; fState = MENU_STATE_CLOSED;
} }
if (!LockLooper()) if (!LockLooper())
break; break;
} else if (item != NULL) {
_UpdateStateOpenSelect(item, openTime, mouseSpeed);
if (!releasedOnce)
releasedOnce = true;
} else if (_OverSuper(screenLocation)) { } else if (_OverSuper(screenLocation)) {
fState = MENU_STATE_TRACKING; fState = MENU_STATE_TRACKING;
UnlockLooper(); UnlockLooper();
break; break;
} else { } else {
// Mouse pointer outside menu: // Mouse pointer outside menu:
// If there's no other submenu opened, // If there's no other submenu opened,
@ -1489,12 +1494,6 @@ BMenu::_Track(int *action, long start)
UnlockLooper(); UnlockLooper();
} }
#if 1
// TODO: on vmware, looks like the second system_time() could return
// a value smaller than the first call. Bug in VMWare or haiku ?
if (newPollTime <= pollTime)
newPollTime = pollTime + 5000;
#endif
// mouseSpeed in px per ms // mouseSpeed in px per ms
// (actually point_distance returns the square of the distance, // (actually point_distance returns the square of the distance,
// so it's more px^2 per ms) // so it's more px^2 per ms)
@ -2040,7 +2039,7 @@ BMenu::_OverSubmenu(BMenuItem *item, BPoint loc)
if (subMenu == NULL || subMenu->Window() == NULL) if (subMenu == NULL || subMenu->Window() == NULL)
return false; return false;
// we assume that loc is in screen coords // we assume that loc is in screen coords {
if (subMenu->Window()->Frame().Contains(loc)) if (subMenu->Window()->Frame().Contains(loc))
return true; return true;