diff options
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r-- | src/FbTk/Menu.cc | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 88240f1..3be0d14 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -199,15 +199,15 @@ Menu::~Menu() { | |||
199 | } | 199 | } |
200 | 200 | ||
201 | int Menu::insert(const FbString &label, RefCount<Command> &cmd, int pos) { | 201 | int Menu::insert(const FbString &label, RefCount<Command> &cmd, int pos) { |
202 | return insert(new MenuItem(label, cmd), pos); | 202 | return insert(new MenuItem(label, cmd, this), pos); |
203 | } | 203 | } |
204 | 204 | ||
205 | int Menu::insert(const FbString &label, int pos) { | 205 | int Menu::insert(const FbString &label, int pos) { |
206 | return insert(new MenuItem(label), pos); | 206 | return insert(new MenuItem(label, *this), pos); |
207 | } | 207 | } |
208 | 208 | ||
209 | int Menu::insert(const FbString &label, Menu *submenu, int pos) { | 209 | int Menu::insert(const FbString &label, Menu *submenu, int pos) { |
210 | return insert(new MenuItem(label, submenu), pos); | 210 | return insert(new MenuItem(label, submenu, this), pos); |
211 | } | 211 | } |
212 | 212 | ||
213 | int Menu::insert(MenuItem *item, int pos) { | 213 | int Menu::insert(MenuItem *item, int pos) { |
@@ -516,15 +516,15 @@ void Menu::show() { | |||
516 | raise(); | 516 | raise(); |
517 | 517 | ||
518 | if (shown && shown != this && shown != m_parent) | 518 | if (shown && shown != this && shown != m_parent) |
519 | shown->hide(true); | 519 | shown->hide(); |
520 | shown = this; | 520 | shown = this; |
521 | 521 | ||
522 | } | 522 | } |
523 | 523 | ||
524 | 524 | ||
525 | void Menu::hide(bool force) { | 525 | void Menu::hide() { |
526 | 526 | ||
527 | if (!isVisible() || m_torn && !force) | 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 |
@@ -570,6 +570,9 @@ void Menu::redrawFrame(FbDrawable &drawable) { | |||
570 | 570 | ||
571 | void Menu::internal_hide(bool first) { | 571 | void Menu::internal_hide(bool first) { |
572 | 572 | ||
573 | if (!first && m_torn) | ||
574 | return; | ||
575 | |||
573 | if (validIndex(m_which_sub)) { | 576 | if (validIndex(m_which_sub)) { |
574 | MenuItem *tmp = menuitems[m_which_sub]; | 577 | MenuItem *tmp = menuitems[m_which_sub]; |
575 | tmp->submenu()->internal_hide(false); | 578 | tmp->submenu()->internal_hide(false); |
@@ -815,8 +818,6 @@ void Menu::handleEvent(XEvent &event) { | |||
815 | if (event.type == FocusOut) { | 818 | if (event.type == FocusOut) { |
816 | if (s_focused == this) | 819 | if (s_focused == this) |
817 | s_focused = 0; | 820 | s_focused = 0; |
818 | if (shown == this && !m_torn) | ||
819 | hide(); | ||
820 | // I don't know why, but I get a FocusIn event when closing the menu with | 821 | // I don't know why, but I get a FocusIn event when closing the menu with |
821 | // the mouse over it -- probably an xorg bug, but it's easy to address here | 822 | // the mouse over it -- probably an xorg bug, but it's easy to address here |
822 | } else if (event.type == FocusIn && m_visible) { | 823 | } else if (event.type == FocusIn && m_visible) { |
@@ -1275,9 +1276,9 @@ void Menu::drawLine(int index, int size){ | |||
1275 | item->drawLine(menu.frame, theme(), size, item_x, item_y, menu.item_w); | 1276 | item->drawLine(menu.frame, theme(), size, item_x, item_y, menu.item_w); |
1276 | } | 1277 | } |
1277 | 1278 | ||
1278 | void Menu::hideShownMenu(bool force) { | 1279 | void Menu::hideShownMenu() { |
1279 | if (shown) | 1280 | if (shown) |
1280 | shown->hide(force); | 1281 | shown->hide(); |
1281 | } | 1282 | } |
1282 | 1283 | ||
1283 | }; // end namespace FbTk | 1284 | }; // end namespace FbTk |