all repos — fluxbox @ c01bd6e9fd98dd0f70ffc1d01df86e73719cd5e0

custom fork of the fluxbox windowmanager

holding control will now keep the menu open
Mark Tiefenbruck mark@fluxbox.org
commit

c01bd6e9fd98dd0f70ffc1d01df86e73719cd5e0

parent

31df2d8bd618cae590d9b0e76aee11021d4c77d3

M ChangeLogChangeLog

@@ -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)
M src/AlphaMenu.hhsrc/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() {
M src/BoolMenuItem.hhsrc/BoolMenuItem.hh

@@ -44,7 +44,10 @@ setCloseOnClick(false);

} 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);
M src/ClientMenu.ccsrc/ClientMenu.cc

@@ -27,6 +27,7 @@ #include "Layer.hh"

#include "Screen.hh" #include "Window.hh" #include "WindowCmd.hh" +#include <X11/keysym.h> #include "FbTk/MenuItem.hh"

@@ -42,7 +43,7 @@ client.dieSig().attach(&menu);

} ~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 @@ FbTk::Menu *parent = menu();

m_client.focus(); fbwin->raise(); - parent->hide(); + if ((mods & ControlMask) == 0) + parent->hide(); } const std::string &label() const { return m_client.title(); }
M src/ClockTool.ccsrc/ClockTool.cc

@@ -61,9 +61,10 @@ m_tool.timeFormat().find("%T") != std::string::npos)

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 @@ else

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;
M src/FbTk/Menu.ccsrc/FbTk/Menu.cc

@@ -888,7 +888,7 @@ if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) {

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 @@ enterSubmenu();

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(); }
M src/FbTk/MenuItem.ccsrc/FbTk/MenuItem.cc

@@ -30,12 +30,13 @@ #include "Image.hh"

#include "App.hh" #include "StringUtil.hh" #include "Menu.hh" +#include <X11/keysym.h> 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<Command> tmp(m_command);
M src/FbTk/MenuItem.hhsrc/FbTk/MenuItem.hh

@@ -138,7 +138,7 @@ Called when the item was clicked with a specific button

@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> &command() { return m_command; }
M src/FbTk/MultiButtonMenuItem.ccsrc/FbTk/MultiButtonMenuItem.cc

@@ -52,7 +52,7 @@ return;

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<signed>(buttons()) || buttons() == 0) return;
M src/FbTk/MultiButtonMenuItem.hhsrc/FbTk/MultiButtonMenuItem.hh

@@ -38,7 +38,7 @@ virtual ~MultiButtonMenuItem();

/// sets command to specified button void setCommand(int button, FbTk::RefCount<FbTk::Command> &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; }
M src/FocusModelMenuItem.hhsrc/FocusModelMenuItem.hh

@@ -39,13 +39,15 @@ FocusControl::FocusModel model,

FbTk::RefCount<FbTk::Command> &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 @@ FocusControl::TabFocusModel model,

FbTk::RefCount<FbTk::Command> &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:
M src/IconbarTool.ccsrc/IconbarTool.cc

@@ -108,11 +108,12 @@ ToolbarModeMenuItem(const FbTk::FbString &label, IconbarTool &handler,

string mode, FbTk::RefCount<FbTk::Command> &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 @@ ToolbarAlignMenuItem(const FbTk::FbString &label, IconbarTool &handler,

Container::Alignment mode, FbTk::RefCount<FbTk::Command> &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:
M src/IntResMenuItem.hhsrc/IntResMenuItem.hh

@@ -49,7 +49,7 @@ delete [] buff;

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 @@

// 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!
M src/LayerMenu.hhsrc/LayerMenu.hh

@@ -50,9 +50,9 @@ int layernum):

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:
M src/Remember.ccsrc/Remember.cc

@@ -99,6 +99,7 @@ Remember::Attribute attrib) :

FbTk::MenuItem(label), m_attrib(attrib) { setToggleItem(true); + setCloseOnClick(false); } bool isSelected() const {

@@ -123,7 +124,7 @@ else

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<void>::window() != 0) {

@@ -134,7 +135,7 @@ Remember::instance().rememberAttrib(WindowCmd<void>::window()->winClient(), m_attrib);

} } Remember::instance().save(); - FbTk::MenuItem::click(button, time); + FbTk::MenuItem::click(button, time, mods); } private:
M src/Screen.ccsrc/Screen.cc

@@ -181,12 +181,14 @@ FbWinFrame::TabPlacement place,

FbTk::RefCount<FbTk::Command> &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); }
M src/Slit.ccsrc/Slit.cc

@@ -184,6 +184,7 @@ FbTk::MenuItem(client.matchName().c_str(), cmd), m_slit(slit), m_client(client) {

setCommand(cmd); FbTk::MenuItem::setSelected(client.visible()); setToggleItem(true); + setCloseOnClick(false); } const string &label() const { return m_client.matchName();

@@ -191,7 +192,7 @@ }

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 @@ m_slit.clientDown(&m_client);

} 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 @@ :FbTk::MenuItem(label,cmd),

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<FbTk::Command> &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;
M src/Xinerama.hhsrc/Xinerama.hh

@@ -48,9 +48,9 @@ XineramaHeadMenuItem(const FbTk::FbString &label, ItemType &object, int headnum):

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: