summaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authormarkt <markt>2007-01-21 18:43:22 (GMT)
committermarkt <markt>2007-01-21 18:43:22 (GMT)
commitfeb56381d704d61255ca5b0f0ae60e3f4f5f9986 (patch)
treea0f7e1279e1c29b58af5a9eb9368c3e1c4f63202 /src/FbTk
parent5503545d8f3228dee6db0c7a1d9de18c77a92ca4 (diff)
downloadfluxbox_lack-feb56381d704d61255ca5b0f0ae60e3f4f5f9986.zip
fluxbox_lack-feb56381d704d61255ca5b0f0ae60e3f4f5f9986.tar.bz2
various changes to menu behavior
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/Menu.cc32
-rw-r--r--src/FbTk/Menu.hh2
2 files changed, 26 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
74namespace FbTk { 74namespace FbTk {
75 75
76static Menu *shown = 0; 76Menu *Menu::shown = 0;
77 77
78Menu *Menu::s_focused = 0; 78Menu *Menu::s_focused = 0;
79 79
@@ -365,12 +365,14 @@ void Menu::enterSubmenu() {
365} 365}
366 366
367void Menu::enterParent() { 367void 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
572void Menu::grabInputFocus() { 574void 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
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh
index 28eb70a..94a1e6f 100644
--- a/src/FbTk/Menu.hh
+++ b/src/FbTk/Menu.hh
@@ -160,6 +160,7 @@ public:
160 bool isItemSelectable(unsigned int index) const; 160 bool isItemSelectable(unsigned int index) const;
161 inline const MenuTheme &theme() const { return m_theme; } 161 inline const MenuTheme &theme() const { return m_theme; }
162 inline unsigned char alpha() const { return theme().alpha(); } 162 inline unsigned char alpha() const { return theme().alpha(); }
163 inline static Menu *shownMenu() { return shown; }
163 inline static Menu *focused() { return s_focused; } 164 inline static Menu *focused() { return s_focused; }
164 /// @return menuitem at index 165 /// @return menuitem at index
165 inline const MenuItem *find(unsigned int index) const { return menuitems[index]; } 166 inline const MenuItem *find(unsigned int index) const { return menuitems[index]; }
@@ -235,6 +236,7 @@ private:
235 int m_active_index; ///< current highlighted index 236 int m_active_index; ///< current highlighted index
236 237
237 Drawable m_root_pm; 238 Drawable m_root_pm;
239 static Menu *shown; ///< used for determining if there's a menu open at all
238 static Menu *s_focused; ///< holds current input focused menu, so one can determine if a menu is focused 240 static Menu *s_focused; ///< holds current input focused menu, so one can determine if a menu is focused
239 bool m_need_update; 241 bool m_need_update;
240 Timer m_submenu_timer; 242 Timer m_submenu_timer;