From c01bd6e9fd98dd0f70ffc1d01df86e73719cd5e0 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Mon, 17 Dec 2007 21:44:17 -0800 Subject: holding control will now keep the menu open --- ChangeLog | 3 +++ src/AlphaMenu.hh | 5 +++-- src/BoolMenuItem.hh | 5 ++++- src/ClientMenu.cc | 6 ++++-- src/ClockTool.cc | 5 +++-- src/FbTk/Menu.cc | 4 ++-- src/FbTk/MenuItem.cc | 5 +++-- src/FbTk/MenuItem.hh | 2 +- src/FbTk/MultiButtonMenuItem.cc | 2 +- src/FbTk/MultiButtonMenuItem.hh | 2 +- src/FocusModelMenuItem.hh | 16 ++++++++++------ src/IconbarTool.cc | 10 ++++++---- src/IntResMenuItem.hh | 4 ++-- src/LayerMenu.hh | 4 ++-- src/Remember.cc | 5 +++-- src/Screen.cc | 8 +++++--- src/Slit.cc | 16 +++++++++------- src/Xinerama.hh | 4 ++-- 18 files changed, 64 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb02070..a43f8b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.0.1: +*07/12/18: + * Holding control while clicking on a menu item will now keep the menu open (Mark) + FbTk/Menu.cc MenuItem.cc/hh *07/12/17: * Fix startup items in apps file with specified screen number, bug #1843325 (thanks Martin) diff --git a/src/AlphaMenu.hh b/src/AlphaMenu.hh index 78dda9a..6323fe1 100644 --- a/src/AlphaMenu.hh +++ b/src/AlphaMenu.hh @@ -64,17 +64,18 @@ public: AlphaMenuSelectItem(const FbTk::FbString &label, AlphaObject *object, AlphaMenu &parent): FbTk::MenuItem(label), m_object(object), m_parent(parent) { setToggleItem(true); + setCloseOnClick(false); } bool isSelected() const { return m_object->getUseDefaultAlpha(); } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { bool newval = !m_object->getUseDefaultAlpha(); m_object->setUseDefaultAlpha(newval); // items 1 and 2 (the focused/unfocused values) are only enabled if we don't use default values m_parent.setItemEnabled(1, !newval); m_parent.setItemEnabled(2, !newval); m_parent.show(); // cheat to refreshing the window - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } void updateLabel() { diff --git a/src/BoolMenuItem.hh b/src/BoolMenuItem.hh index d10a7ac..c7e3d6c 100644 --- a/src/BoolMenuItem.hh +++ b/src/BoolMenuItem.hh @@ -44,7 +44,10 @@ public: } bool isSelected() const { return m_item; } // toggle state - void click(int button, int time) { setSelected(!m_item); FbTk::MenuItem::click(button, time); } + void click(int button, int time, unsigned int mods) { + setSelected(!m_item); + FbTk::MenuItem::click(button, time, mods); + } void setSelected(bool value) { m_item = value; FbTk::MenuItem::setSelected(m_item); diff --git a/src/ClientMenu.cc b/src/ClientMenu.cc index ae35aab..7248883 100644 --- a/src/ClientMenu.cc +++ b/src/ClientMenu.cc @@ -27,6 +27,7 @@ #include "Screen.hh" #include "Window.hh" #include "WindowCmd.hh" +#include #include "FbTk/MenuItem.hh" @@ -42,7 +43,7 @@ public: } ~ClientMenuItem() { m_client.titleSig().detach(menu()); } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { FluxboxWindow *fbwin = m_client.fbwindow(); if (fbwin == 0) return; @@ -53,7 +54,8 @@ public: m_client.focus(); fbwin->raise(); - parent->hide(); + if ((mods & ControlMask) == 0) + parent->hide(); } const std::string &label() const { return m_client.title(); } diff --git a/src/ClockTool.cc b/src/ClockTool.cc index b396999..0f4695b 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -61,9 +61,10 @@ public: setLabel( _FB_XTEXT(Toolbar, Clock24, "Clock: 24h", "set Clockmode to 24h") ); else setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") ); + setCloseOnClick(false); } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { std::string newformat = m_tool.timeFormat(); size_t pos = newformat.find("%k"); std::string newstr; @@ -112,7 +113,7 @@ public: setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") ); } // else some other strange format...so we don't do anything - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } private: ClockTool &m_tool; diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 3be0d14..bb51d92 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -888,7 +888,7 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) { if (m_active_index == w && isItemEnabled(w) && re.x > ix && re.x < (signed) (ix + menu.item_w) && re.y > iy && re.y < (signed) (iy + theme().itemHeight())) { - menuitems[w]->click(re.button, re.time); + menuitems[w]->click(re.button, re.time, re.state); } else { int old = m_active_index; m_active_index = w; @@ -1054,7 +1054,7 @@ void Menu::keyPressEvent(XKeyEvent &event) { else { // send fake button click int button = (event.state & ShiftMask) ? 3 : 1; - find(m_active_index)->click(button, event.time); + find(m_active_index)->click(button, event.time, event.state); m_need_update = true; updateMenu(); } diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc index 7d309f4..1e708d3 100644 --- a/src/FbTk/MenuItem.cc +++ b/src/FbTk/MenuItem.cc @@ -30,12 +30,13 @@ #include "App.hh" #include "StringUtil.hh" #include "Menu.hh" +#include namespace FbTk { -void MenuItem::click(int button, int time) { +void MenuItem::click(int button, int time, unsigned int mods) { if (m_command.get() != 0) { - if (m_menu && m_close_on_click) + if (m_menu && m_close_on_click && (mods & ControlMask) == 0) m_menu->hide(); // we need a local variable, since the command may destroy this object RefCount tmp(m_command); diff --git a/src/FbTk/MenuItem.hh b/src/FbTk/MenuItem.hh index 3b02f2e..b6777b7 100644 --- a/src/FbTk/MenuItem.hh +++ b/src/FbTk/MenuItem.hh @@ -138,7 +138,7 @@ public: @param button the button number @param time the time stamp */ - virtual void click(int button, int time); + virtual void click(int button, int time, unsigned int mods); /// must use this to show submenu to ensure consistency for object like window menu in ClientMenu (see Workspace.cc) virtual void showSubmenu(); RefCount &command() { return m_command; } diff --git a/src/FbTk/MultiButtonMenuItem.cc b/src/FbTk/MultiButtonMenuItem.cc index b3fa1aa..591c13d 100644 --- a/src/FbTk/MultiButtonMenuItem.cc +++ b/src/FbTk/MultiButtonMenuItem.cc @@ -52,7 +52,7 @@ void MultiButtonMenuItem::setCommand(int button, FbTk::RefCount & m_button_exe[button - 1] = cmd; } -void MultiButtonMenuItem::click(int button, int time) { +void MultiButtonMenuItem::click(int button, int time, unsigned int mods) { if (button <= 0 || button > static_cast(buttons()) || buttons() == 0) return; diff --git a/src/FbTk/MultiButtonMenuItem.hh b/src/FbTk/MultiButtonMenuItem.hh index 3e82d67..4bc1276 100644 --- a/src/FbTk/MultiButtonMenuItem.hh +++ b/src/FbTk/MultiButtonMenuItem.hh @@ -38,7 +38,7 @@ public: /// sets command to specified button void setCommand(int button, FbTk::RefCount &cmd); /// executes command for the button click - virtual void click(int button, int time); + virtual void click(int button, int time, unsigned int mods); /// @return number of buttons this instance handles inline unsigned int buttons() const { return m_buttons; } diff --git a/src/FocusModelMenuItem.hh b/src/FocusModelMenuItem.hh index fcf2243..91657e9 100644 --- a/src/FocusModelMenuItem.hh +++ b/src/FocusModelMenuItem.hh @@ -39,13 +39,15 @@ public: FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_focus_control(focus_control), - m_focusmodel(model) { } + m_focusmodel(model) { + setCloseOnClick(false); + } bool isEnabled() const { return m_focus_control.focusModel() != m_focusmodel; } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { m_focus_control.setFocusModel(m_focusmodel); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } private: @@ -61,13 +63,15 @@ public: FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_focus_control(focus_control), - m_tabfocusmodel(model) { } + m_tabfocusmodel(model) { + setCloseOnClick(false); + } bool isEnabled() const { return m_focus_control.tabFocusModel() != m_tabfocusmodel; } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { m_focus_control.setTabFocusModel(m_tabfocusmodel); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } private: diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 1e575dc..99907c7 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -108,11 +108,12 @@ public: string mode, FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { + setCloseOnClick(false); } bool isEnabled() const { return m_handler.mode() != m_mode; } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { m_handler.setMode(m_mode); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } private: @@ -126,11 +127,12 @@ public: Container::Alignment mode, FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { + setCloseOnClick(false); } bool isEnabled() const { return m_handler.alignment() != m_mode; } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { m_handler.setAlignment(m_mode); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } private: diff --git a/src/IntResMenuItem.hh b/src/IntResMenuItem.hh index e49681f..3de4b5f 100644 --- a/src/IntResMenuItem.hh +++ b/src/IntResMenuItem.hh @@ -49,7 +49,7 @@ public: return ret; } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { static int last_time = -201; int inc_val = 1; // check double click @@ -76,7 +76,7 @@ public: // update label updateLabel(); // call other commands - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); // show new value, which for us means forcing a full menu update // since the text is drawn onto the background! diff --git a/src/LayerMenu.hh b/src/LayerMenu.hh index 4f4a0a9..7882fd7 100644 --- a/src/LayerMenu.hh +++ b/src/LayerMenu.hh @@ -50,9 +50,9 @@ public: FbTk::MenuItem(label), m_object(object), m_layernum(layernum) {} bool isEnabled() const { return m_object->layerNumber() != m_layernum; } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { m_object->moveToLayer(m_layernum); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } private: diff --git a/src/Remember.cc b/src/Remember.cc index 827b1e3..2090008 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -99,6 +99,7 @@ public: FbTk::MenuItem(label), m_attrib(attrib) { setToggleItem(true); + setCloseOnClick(false); } bool isSelected() const { @@ -123,7 +124,7 @@ public: return false; } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { // reconfigure only does stuff if the apps file has changed Remember::instance().reconfigure(); if (WindowCmd::window() != 0) { @@ -134,7 +135,7 @@ public: } } Remember::instance().save(); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } private: diff --git a/src/Screen.cc b/src/Screen.cc index a74ba0e..f26a0e6 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -181,12 +181,14 @@ public: FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_screen(screen), - m_place(place) { } + m_place(place) { + setCloseOnClick(false); + } bool isEnabled() const { return m_screen.getTabPlacement() != m_place; } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { m_screen.saveTabPlacement(m_place); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } diff --git a/src/Slit.cc b/src/Slit.cc index b18dddc..0b952c5 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -184,6 +184,7 @@ public: setCommand(cmd); FbTk::MenuItem::setSelected(client.visible()); setToggleItem(true); + setCloseOnClick(false); } const string &label() const { return m_client.matchName(); @@ -191,7 +192,7 @@ public: bool isSelected() const { return m_client.visible(); } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { if (button == 4 || button == 2) { // wheel up m_slit.clientUp(&m_client); } else if (button == 5 || button == 3) { // wheel down @@ -199,7 +200,7 @@ public: } else { m_client.setVisible(!m_client.visible()); FbTk::MenuItem::setSelected(m_client.visible()); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } } private: @@ -214,16 +215,17 @@ public: m_slit(slit), m_label(label) { setLabel(m_label); // update label + setCloseOnClick(false); } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { // toggle direction if (m_slit.direction() == Slit::HORIZONTAL) m_slit.setDirection(Slit::VERTICAL); else m_slit.setDirection(Slit::HORIZONTAL); setLabel(m_label); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } void setLabel(const FbTk::FbString &label) { @@ -245,12 +247,12 @@ class PlaceSlitMenuItem: public FbTk::MenuItem { public: PlaceSlitMenuItem(const FbTk::FbString &label, Slit &slit, Slit::Placement place, FbTk::RefCount &cmd): FbTk::MenuItem(label, cmd), m_slit(slit), m_place(place) { - + setCloseOnClick(false); } bool isEnabled() const { return m_slit.placement() != m_place; } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { m_slit.setPlacement(m_place); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } private: Slit &m_slit; diff --git a/src/Xinerama.hh b/src/Xinerama.hh index 1cc15aa..f57c584 100644 --- a/src/Xinerama.hh +++ b/src/Xinerama.hh @@ -48,9 +48,9 @@ public: FbTk::MenuItem(label), m_object(object), m_headnum(headnum) {} bool isEnabled() const { return m_object.getOnHead() != m_headnum; } - void click(int button, int time) { + void click(int button, int time, unsigned int mods) { m_object.saveOnHead(m_headnum); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } private: -- cgit v0.11.2