more fixes
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17104 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1146,7 +1146,6 @@ BMenu::_track(int *action, bigtime_t trackTime, long start)
|
|||||||
bigtime_t startTime = system_time();
|
bigtime_t startTime = system_time();
|
||||||
bigtime_t delay = 200000; // TODO: Test and reduce if needed.
|
bigtime_t delay = 200000; // TODO: Test and reduce if needed.
|
||||||
|
|
||||||
bool okay = true;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
bool locked = LockLooper();
|
bool locked = LockLooper();
|
||||||
if (!locked)
|
if (!locked)
|
||||||
@@ -1172,7 +1171,6 @@ BMenu::_track(int *action, bigtime_t trackTime, long start)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (OverSuper(screenLocation)) {
|
if (OverSuper(screenLocation)) {
|
||||||
okay = false;
|
|
||||||
localAction = MENU_ACT_NONE;
|
localAction = MENU_ACT_NONE;
|
||||||
item = NULL;
|
item = NULL;
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
@@ -1188,7 +1186,7 @@ BMenu::_track(int *action, bigtime_t trackTime, long start)
|
|||||||
int submenuAction = MENU_ACT_NONE;
|
int submenuAction = MENU_ACT_NONE;
|
||||||
if (IsStickyMode())
|
if (IsStickyMode())
|
||||||
fSelected->Submenu()->SetStickyMode(true);
|
fSelected->Submenu()->SetStickyMode(true);
|
||||||
BMenuItem *submenuItem = fSelected->Submenu()->_track(&submenuAction, startTime);
|
BMenuItem *submenuItem = fSelected->Submenu()->_track(&submenuAction, trackTime);
|
||||||
if (submenuAction == MENU_ACT_CLOSE) {
|
if (submenuAction == MENU_ACT_CLOSE) {
|
||||||
item = submenuItem;
|
item = submenuItem;
|
||||||
localAction = submenuAction;
|
localAction = submenuAction;
|
||||||
|
|||||||
@@ -392,18 +392,27 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
ulong buttons;
|
ulong buttons;
|
||||||
GetMouse(&where, &buttons);
|
GetMouse(&where, &buttons);
|
||||||
BMenuItem *menuItem = HitTestItems(where, B_ORIGIN);
|
BMenuItem *menuItem = HitTestItems(where, B_ORIGIN);
|
||||||
if (menuItem != NULL && menuItem != fSelected) {
|
if (menuItem != NULL) {
|
||||||
// Select item if:
|
// Select item if:
|
||||||
|
// - no previous selection
|
||||||
|
// - nonsticky mode and different selection,
|
||||||
// - clicked in sticky mode
|
// - clicked in sticky mode
|
||||||
// - nonsticky mode,
|
if (fSelected == NULL
|
||||||
// - no previous selection
|
|| (!IsStickyMode() && menuItem != fSelected)
|
||||||
if (fSelected == NULL || !IsStickyMode() || buttons != 0) {
|
|| (buttons != 0 && IsStickyMode())) {
|
||||||
// only select the item
|
if (menuItem->Submenu() != NULL) {
|
||||||
SelectItem(menuItem, -1);
|
if (menuItem->Submenu()->Window() == NULL) {
|
||||||
if (menuItem->Submenu() != NULL
|
// open the menu if it's not opened yet
|
||||||
&& menuItem->Submenu()->Window() == NULL) {
|
SelectItem(menuItem);
|
||||||
// open the menu if it's not opened yet
|
} else {
|
||||||
SelectItem(menuItem);
|
// Menu was already opened, close it and bail
|
||||||
|
SelectItem(NULL);
|
||||||
|
localAction = MENU_ACT_CLOSE;
|
||||||
|
resultItem = NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// No submenu, just select the item
|
||||||
|
SelectItem(menuItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,11 +438,15 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
if (localAction == MENU_ACT_CLOSE || (buttons != 0 && IsStickyMode() && menuItem == NULL))
|
if (localAction == MENU_ACT_CLOSE || (buttons != 0 && IsStickyMode() && menuItem == NULL))
|
||||||
break;
|
break;
|
||||||
else if (buttons == 0 && !IsStickyMode()) {
|
else if (buttons == 0 && !IsStickyMode()) {
|
||||||
// Don't switch to sticky mode if user kept the mouse pressed for too long
|
// On an item without a submenu
|
||||||
// TODO: Delay could be smaller, but then it wouldn't be noticeable on QEMU on my machine
|
if (fSelected != NULL && fSelected->Submenu() == NULL) {
|
||||||
if (IsStickyPrefOn() && system_time() < startTime + 2000000)
|
resultItem = fSelected;
|
||||||
|
break;
|
||||||
|
} else if (IsStickyPrefOn() && system_time() < startTime + 2000000) {
|
||||||
|
// Don't switch to sticky mode if user kept the mouse pressed for too long
|
||||||
|
// TODO: Delay could be smaller, but then it wouldn't be noticeable on QEMU on my machine
|
||||||
SetStickyMode(true);
|
SetStickyMode(true);
|
||||||
else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,11 +455,8 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (window->Lock()) {
|
if (window->Lock()) {
|
||||||
if (fSelected != NULL) {
|
if (fSelected != NULL)
|
||||||
if (fSelected->Submenu() == NULL)
|
|
||||||
resultItem = fSelected;
|
|
||||||
SelectItem(NULL);
|
SelectItem(NULL);
|
||||||
}
|
|
||||||
if (resultItem != NULL)
|
if (resultItem != NULL)
|
||||||
resultItem->Invoke();
|
resultItem->Invoke();
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
|
|||||||
Reference in New Issue
Block a user