aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Menu.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2007-12-18 05:09:20 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2007-12-18 05:09:20 (GMT)
commit31df2d8bd618cae590d9b0e76aee11021d4c77d3 (patch)
tree3be26fb88b0e0178a728bd9968eea2e93f62b6f6 /src/FbTk/Menu.cc
parentc39af52bfca7f6962048a102597d88337c949b67 (diff)
downloadfluxbox_pavel-31df2d8bd618cae590d9b0e76aee11021d4c77d3.zip
fluxbox_pavel-31df2d8bd618cae590d9b0e76aee11021d4c77d3.tar.bz2
make MenuItem responsible for decision to close menu when clicked
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r--src/FbTk/Menu.cc21
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
201int Menu::insert(const FbString &label, RefCount<Command> &cmd, int pos) { 201int 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
205int Menu::insert(const FbString &label, int pos) { 205int 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
209int Menu::insert(const FbString &label, Menu *submenu, int pos) { 209int 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
213int Menu::insert(MenuItem *item, int pos) { 213int 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
525void Menu::hide(bool force) { 525void 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
571void Menu::internal_hide(bool first) { 571void 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
1278void Menu::hideShownMenu(bool force) { 1279void 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