diff options
author | markt <markt> | 2007-01-21 18:43:22 (GMT) |
---|---|---|
committer | markt <markt> | 2007-01-21 18:43:22 (GMT) |
commit | feb56381d704d61255ca5b0f0ae60e3f4f5f9986 (patch) | |
tree | a0f7e1279e1c29b58af5a9eb9368c3e1c4f63202 /src/FbTk/Menu.cc | |
parent | 5503545d8f3228dee6db0c7a1d9de18c77a92ca4 (diff) | |
download | fluxbox-feb56381d704d61255ca5b0f0ae60e3f4f5f9986.zip fluxbox-feb56381d704d61255ca5b0f0ae60e3f4f5f9986.tar.bz2 |
various changes to menu behavior
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r-- | src/FbTk/Menu.cc | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index e7fc6d8..5ee329b 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -73,7 +73,7 @@ using std::endl; | |||
73 | 73 | ||
74 | namespace FbTk { | 74 | namespace FbTk { |
75 | 75 | ||
76 | static Menu *shown = 0; | 76 | Menu *Menu::shown = 0; |
77 | 77 | ||
78 | Menu *Menu::s_focused = 0; | 78 | Menu *Menu::s_focused = 0; |
79 | 79 | ||
@@ -365,12 +365,14 @@ void Menu::enterSubmenu() { | |||
365 | } | 365 | } |
366 | 366 | ||
367 | void Menu::enterParent() { | 367 | void Menu::enterParent() { |
368 | if (!validIndex(m_which_press) || parent() == 0) | 368 | if (parent() == 0) |
369 | return; | 369 | return; |
370 | 370 | ||
371 | Menu *submenu = menuitems[m_which_press]->submenu(); | 371 | if (validIndex(m_which_press)) { |
372 | if (submenu) | 372 | Menu *submenu = menuitems[m_which_press]->submenu(); |
373 | submenu->internal_hide(); | 373 | if (submenu) |
374 | submenu->internal_hide(); | ||
375 | } | ||
374 | 376 | ||
375 | m_active_index = -1; | 377 | m_active_index = -1; |
376 | //clearItem(m_which_press); | 378 | //clearItem(m_which_press); |
@@ -570,6 +572,13 @@ void Menu::hide() { | |||
570 | } | 572 | } |
571 | 573 | ||
572 | void Menu::grabInputFocus() { | 574 | void Menu::grabInputFocus() { |
575 | // if there's a submenu open, focus it instead | ||
576 | if (validIndex(m_which_sub) && | ||
577 | menuitems[m_which_sub]->submenu()->isVisible()) { | ||
578 | menuitems[m_which_sub]->submenu()->grabInputFocus(); | ||
579 | return; | ||
580 | } | ||
581 | |||
573 | s_focused = this; | 582 | s_focused = this; |
574 | 583 | ||
575 | // grab input focus | 584 | // grab input focus |
@@ -632,7 +641,8 @@ void Menu::move(int x, int y) { | |||
632 | if (alpha() < 255) | 641 | if (alpha() < 255) |
633 | clearWindow(); | 642 | clearWindow(); |
634 | 643 | ||
635 | if (m_which_sub != -1) | 644 | if (validIndex(m_which_sub) && |
645 | menuitems[m_which_sub]->submenu()->isVisible()) | ||
636 | drawSubmenu(m_which_sub); | 646 | drawSubmenu(m_which_sub); |
637 | } | 647 | } |
638 | 648 | ||
@@ -846,6 +856,10 @@ void Menu::handleEvent(XEvent &event) { | |||
846 | } else if (event.type == FocusIn) { | 856 | } else if (event.type == FocusIn) { |
847 | if (s_focused != this) | 857 | if (s_focused != this) |
848 | s_focused = this; | 858 | s_focused = this; |
859 | // if there's a submenu open, focus it instead | ||
860 | if (validIndex(m_which_sub) && | ||
861 | menuitems[m_which_sub]->submenu()->isVisible()) | ||
862 | menuitems[m_which_sub]->submenu()->grabInputFocus(); | ||
849 | } | 863 | } |
850 | } | 864 | } |
851 | 865 | ||
@@ -881,7 +895,8 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { | |||
881 | if (m_moving) { | 895 | if (m_moving) { |
882 | m_moving = false; | 896 | m_moving = false; |
883 | 897 | ||
884 | if (m_which_sub != -1) | 898 | if (validIndex(m_which_sub) && |
899 | menuitems[m_which_sub]->submenu()->isVisible()) | ||
885 | drawSubmenu(m_which_sub); | 900 | drawSubmenu(m_which_sub); |
886 | 901 | ||
887 | if (alpha() < 255) { | 902 | if (alpha() < 255) { |
@@ -933,7 +948,8 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { | |||
933 | // clear current highlighted item | 948 | // clear current highlighted item |
934 | clearItem(m_active_index); | 949 | clearItem(m_active_index); |
935 | 950 | ||
936 | if (m_which_sub >= 0) | 951 | if (validIndex(m_which_sub) && |
952 | menuitems[m_which_sub]->submenu()->isVisible()) | ||
937 | drawSubmenu(m_which_sub); | 953 | drawSubmenu(m_which_sub); |
938 | } else { | 954 | } else { |
939 | // we dont call ::move here 'cause we dont want to update transparency | 955 | // we dont call ::move here 'cause we dont want to update transparency |