fix torn menus
Mark Tiefenbruck mark@fluxbox.org
2 files changed,
17 insertions(+),
12 deletions(-)
M
src/FbTk/Menu.cc
→
src/FbTk/Menu.cc
@@ -515,24 +515,28 @@ menu.window.showSubwindows();
menu.window.show(); raise(); - if (shown && shown != this && shown != m_parent) + if (shown && shown != this) shown->hide(); shown = this; } -void Menu::hide() { +void Menu::hide(bool force) { if (!isVisible()) return; // if parent is visible, go to first parent and hide it Menu *p = this; - while (p->m_parent && p->m_parent->isVisible()) - p = p->m_parent; - - p->internal_hide(); + while (p && p->isVisible()) { + Menu *tmp = p->m_parent; + if (force || !p->m_torn) + p->internal_hide(); + else + p->m_parent = 0; + p = tmp; + } }@@ -570,12 +574,10 @@ }
void Menu::internal_hide(bool first) { - if (!first && m_torn) - return; - if (validIndex(m_which_sub)) { MenuItem *tmp = menuitems[m_which_sub]; - tmp->submenu()->internal_hide(false); + if (tmp && tmp->submenu() && tmp->submenu()->isVisible()) + tmp->submenu()->internal_hide(false); } // if we have an active index we need to redraw it@@ -719,6 +721,7 @@ if (! m_moving)
clearItem(index); if (! item->submenu()->isVisible()) { + shown = item->submenu(); item->showSubmenu(); item->submenu()->raise(); }@@ -908,6 +911,8 @@
if (! m_moving) { // if not m_moving: start m_moving operation m_moving = m_torn = true; + if (m_parent) + m_parent->m_which_sub = -1; // clear current highlighted item clearItem(m_active_index);@@ -1033,7 +1038,7 @@ break;
case XK_Escape: // close menu m_type_ahead.reset(); m_torn = false; - hide(); + hide(true); break; case XK_BackSpace: if (m_type_ahead.stringSize() == 0) {
M
src/FbTk/Menu.hh
→
src/FbTk/Menu.hh
@@ -124,7 +124,7 @@ virtual void drawSubmenu(unsigned int index);
/// show menu virtual void show(); /// hide menu - virtual void hide(); + virtual void hide(bool force = false); virtual void clearWindow(); #ifdef NOT_USED void setActiveIndex(int index) { m_active_index = index; }