Some changes in menu tracking:
- in the code path, now it's clear if the looper is locked or not - if menus are quitting, now we don't call snooze() anymore, and avoid the extra GetMouse() call. - some other cleanups git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23279 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+39
-39
@@ -1374,32 +1374,34 @@ BMenu::_Track(int *action, long start)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool releasedOnce = buttons == 0;
|
bool releasedOnce = buttons == 0;
|
||||||
while (true) {
|
while (fState != MENU_STATE_CLOSED) {
|
||||||
if (_CustomTrackingWantsToQuit())
|
if (_CustomTrackingWantsToQuit())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
bool locked = LockLooper();
|
if (!LockLooper())
|
||||||
if (!locked)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BMenuWindow *window = static_cast<BMenuWindow *>(Window());
|
BMenuWindow *window = static_cast<BMenuWindow *>(Window());
|
||||||
|
|
||||||
BPoint screenLocation = ConvertToScreen(location);
|
BPoint screenLocation = ConvertToScreen(location);
|
||||||
if (window->CheckForScrolling(screenLocation)) {
|
if (window->CheckForScrolling(screenLocation)) {
|
||||||
item = NULL;
|
UnlockLooper();
|
||||||
} else {
|
continue;
|
||||||
item = _HitTestItems(location, B_ORIGIN);
|
}
|
||||||
if (item != NULL) {
|
|
||||||
_UpdateStateOpenSelect(item, openTime, closeTime);
|
item = _HitTestItems(location, B_ORIGIN);
|
||||||
if (!releasedOnce)
|
if (item != NULL) {
|
||||||
releasedOnce = true;
|
_UpdateStateOpenSelect(item, openTime, closeTime);
|
||||||
}
|
if (!releasedOnce)
|
||||||
|
releasedOnce = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Track the submenu
|
// Track the submenu
|
||||||
if (_OverSubmenu(fSelected, screenLocation)) {
|
if (_OverSubmenu(fSelected, screenLocation)) {
|
||||||
|
// Since the submenu has its own looper,
|
||||||
|
// we can unlock ours. Doing so also make sure
|
||||||
|
// that our window gets any update message to
|
||||||
|
// redraw itself
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
locked = false;
|
|
||||||
int submenuAction = MENU_STATE_TRACKING;
|
int submenuAction = MENU_STATE_TRACKING;
|
||||||
BMenu *submenu = fSelected->Submenu();
|
BMenu *submenu = fSelected->Submenu();
|
||||||
submenu->_SetStickyMode(_IsStickyMode());
|
submenu->_SetStickyMode(_IsStickyMode());
|
||||||
@@ -1408,6 +1410,8 @@ BMenu::_Track(int *action, long start)
|
|||||||
item = submenuItem;
|
item = submenuItem;
|
||||||
fState = MENU_STATE_CLOSED;
|
fState = MENU_STATE_CLOSED;
|
||||||
}
|
}
|
||||||
|
if (!LockLooper())
|
||||||
|
break;
|
||||||
} else if (item == NULL) {
|
} else if (item == NULL) {
|
||||||
if (_OverSuper(screenLocation)) {
|
if (_OverSuper(screenLocation)) {
|
||||||
fState = MENU_STATE_TRACKING;
|
fState = MENU_STATE_TRACKING;
|
||||||
@@ -1423,39 +1427,35 @@ BMenu::_Track(int *action, long start)
|
|||||||
if (fSuper != NULL) {
|
if (fSuper != NULL) {
|
||||||
// Give supermenu the chance to continue tracking
|
// Give supermenu the chance to continue tracking
|
||||||
*action = fState;
|
*action = fState;
|
||||||
if (locked)
|
UnlockLooper();
|
||||||
UnlockLooper();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!locked)
|
UnlockLooper();
|
||||||
locked = LockLooper();
|
|
||||||
|
|
||||||
BPoint newLocation;
|
|
||||||
uint32 newButtons;
|
|
||||||
if (locked) {
|
|
||||||
GetMouse(&newLocation, &newButtons, true);
|
|
||||||
UnlockLooper();
|
|
||||||
locked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newLocation != location || newButtons != buttons) {
|
if (fState != MENU_STATE_CLOSED) {
|
||||||
if (!releasedOnce && newButtons == 0 && buttons != 0)
|
bigtime_t snoozeAmount = 50000;
|
||||||
releasedOnce = true;
|
snooze(snoozeAmount);
|
||||||
location = newLocation;
|
|
||||||
buttons = newButtons;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (releasedOnce)
|
|
||||||
_UpdateStateClose(item, location, buttons);
|
|
||||||
|
|
||||||
if (fState == MENU_STATE_CLOSED)
|
|
||||||
break;
|
|
||||||
|
|
||||||
bigtime_t snoozeAmount = 50000;
|
BPoint newLocation;
|
||||||
snooze(snoozeAmount);
|
uint32 newButtons;
|
||||||
|
if (LockLooper()) {
|
||||||
|
GetMouse(&newLocation, &newButtons, true);
|
||||||
|
UnlockLooper();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newLocation != location || newButtons != buttons) {
|
||||||
|
if (!releasedOnce && newButtons == 0 && buttons != 0)
|
||||||
|
releasedOnce = true;
|
||||||
|
location = newLocation;
|
||||||
|
buttons = newButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (releasedOnce)
|
||||||
|
_UpdateStateClose(item, location, buttons);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action != NULL)
|
if (action != NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user