diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-18 06:52:30 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-18 06:52:30 (GMT) |
commit | 98c5cea5f59180a80d322cb9e45d0d9ea5381444 (patch) | |
tree | 0f3b8ce00cd4e0228e04f2b5cd18e5acdbee7524 /src/FbTk | |
parent | c01bd6e9fd98dd0f70ffc1d01df86e73719cd5e0 (diff) | |
download | fluxbox_paul-98c5cea5f59180a80d322cb9e45d0d9ea5381444.zip fluxbox_paul-98c5cea5f59180a80d322cb9e45d0d9ea5381444.tar.bz2 |
fix torn menus
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/Menu.cc | 27 | ||||
-rw-r--r-- | src/FbTk/Menu.hh | 2 |
2 files changed, 17 insertions, 12 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index bb51d92..485b56c 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -515,24 +515,28 @@ void Menu::show() { | |||
515 | menu.window.show(); | 515 | menu.window.show(); |
516 | raise(); | 516 | raise(); |
517 | 517 | ||
518 | if (shown && shown != this && shown != m_parent) | 518 | if (shown && shown != this) |
519 | shown->hide(); | 519 | shown->hide(); |
520 | shown = this; | 520 | shown = this; |
521 | 521 | ||
522 | } | 522 | } |
523 | 523 | ||
524 | 524 | ||
525 | void Menu::hide() { | 525 | void Menu::hide(bool force) { |
526 | 526 | ||
527 | if (!isVisible()) | 527 | if (!isVisible()) |
528 | return; | 528 | return; |
529 | 529 | ||
530 | // if parent is visible, go to first parent and hide it | 530 | // if parent is visible, go to first parent and hide it |
531 | Menu *p = this; | 531 | Menu *p = this; |
532 | while (p->m_parent && p->m_parent->isVisible()) | 532 | while (p && p->isVisible()) { |
533 | p = p->m_parent; | 533 | Menu *tmp = p->m_parent; |
534 | 534 | if (force || !p->m_torn) | |
535 | p->internal_hide(); | 535 | p->internal_hide(); |
536 | else | ||
537 | p->m_parent = 0; | ||
538 | p = tmp; | ||
539 | } | ||
536 | 540 | ||
537 | } | 541 | } |
538 | 542 | ||
@@ -570,12 +574,10 @@ void Menu::redrawFrame(FbDrawable &drawable) { | |||
570 | 574 | ||
571 | void Menu::internal_hide(bool first) { | 575 | void Menu::internal_hide(bool first) { |
572 | 576 | ||
573 | if (!first && m_torn) | ||
574 | return; | ||
575 | |||
576 | if (validIndex(m_which_sub)) { | 577 | if (validIndex(m_which_sub)) { |
577 | MenuItem *tmp = menuitems[m_which_sub]; | 578 | MenuItem *tmp = menuitems[m_which_sub]; |
578 | tmp->submenu()->internal_hide(false); | 579 | if (tmp && tmp->submenu() && tmp->submenu()->isVisible()) |
580 | tmp->submenu()->internal_hide(false); | ||
579 | } | 581 | } |
580 | 582 | ||
581 | // if we have an active index we need to redraw it | 583 | // if we have an active index we need to redraw it |
@@ -719,6 +721,7 @@ void Menu::drawSubmenu(unsigned int index) { | |||
719 | clearItem(index); | 721 | clearItem(index); |
720 | 722 | ||
721 | if (! item->submenu()->isVisible()) { | 723 | if (! item->submenu()->isVisible()) { |
724 | shown = item->submenu(); | ||
722 | item->showSubmenu(); | 725 | item->showSubmenu(); |
723 | item->submenu()->raise(); | 726 | item->submenu()->raise(); |
724 | } | 727 | } |
@@ -908,6 +911,8 @@ void Menu::motionNotifyEvent(XMotionEvent &me) { | |||
908 | if (! m_moving) { | 911 | if (! m_moving) { |
909 | // if not m_moving: start m_moving operation | 912 | // if not m_moving: start m_moving operation |
910 | m_moving = m_torn = true; | 913 | m_moving = m_torn = true; |
914 | if (m_parent) | ||
915 | m_parent->m_which_sub = -1; | ||
911 | // clear current highlighted item | 916 | // clear current highlighted item |
912 | clearItem(m_active_index); | 917 | clearItem(m_active_index); |
913 | 918 | ||
@@ -1033,7 +1038,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1033 | case XK_Escape: // close menu | 1038 | case XK_Escape: // close menu |
1034 | m_type_ahead.reset(); | 1039 | m_type_ahead.reset(); |
1035 | m_torn = false; | 1040 | m_torn = false; |
1036 | hide(); | 1041 | hide(true); |
1037 | break; | 1042 | break; |
1038 | case XK_BackSpace: | 1043 | case XK_BackSpace: |
1039 | if (m_type_ahead.stringSize() == 0) { | 1044 | if (m_type_ahead.stringSize() == 0) { |
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 53dc494..f16c443 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -124,7 +124,7 @@ public: | |||
124 | /// show menu | 124 | /// show menu |
125 | virtual void show(); | 125 | virtual void show(); |
126 | /// hide menu | 126 | /// hide menu |
127 | virtual void hide(); | 127 | virtual void hide(bool force = false); |
128 | virtual void clearWindow(); | 128 | virtual void clearWindow(); |
129 | #ifdef NOT_USED | 129 | #ifdef NOT_USED |
130 | void setActiveIndex(int index) { m_active_index = index; } | 130 | void setActiveIndex(int index) { m_active_index = index; } |