all repos — fluxbox @ 4545f4dac81f61b7e99769006888a8688eeb542c

custom fork of the fluxbox windowmanager

support OnWinButton, OnMinButton & OnMaxButton

... actions in keys.
This allows to override the default behavior as well as adding actions
for the mouse wheel.
Special casing of the two "geometry" related buttons (eg. to perform
smart maximization, reverse the partial maximzation, add shading to the
min button or whatnot)
All other buttons have a rather dedicated meaning and are only really
interesting for adding mouse wheels or eg. the window menu on rmb
clicks.

Needs docu.
Thomas Lübking thomas.luebking@gmail.com
commit

4545f4dac81f61b7e99769006888a8688eeb542c

parent

7fd13acab19dd449343fe8357946aa0c97d97f77

3 files changed, 40 insertions(+), 5 deletions(-)

jump to
M src/Keys.ccsrc/Keys.cc

@@ -400,6 +400,12 @@ else if (arg == "onwindow")

context |= ON_WINDOW; else if (arg == "ontitlebar") context |= ON_TITLEBAR; + else if (arg == "onwinbutton") + context |= ON_WINBUTTON; + else if (arg == "onminbutton") + context |= ON_MINBUTTON; // one char diff, oh great ... ... blast! + else if (arg == "onmaxbutton") + context |= ON_MAXBUTTON; else if (arg == "onwindowborder") context |= ON_WINDOWBORDER; else if (arg == "onleftgrip")
M src/Keys.hhsrc/Keys.hh

@@ -53,7 +53,10 @@ ON_WINDOWBORDER = 1 << 6,

ON_LEFTGRIP = 1 << 7, ON_RIGHTGRIP = 1 << 8, ON_TAB = 1 << 9, - ON_SLIT = 1 << 10 + ON_SLIT = 1 << 10, + ON_WINBUTTON = 1 << 11, + ON_MINBUTTON = 1 << 12, + ON_MAXBUTTON = 1 << 13 // and so on... };
M src/WinButton.ccsrc/WinButton.cc

@@ -20,6 +20,8 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER

// DEALINGS IN THE SOFTWARE. #include "WinButton.hh" +#include "fluxbox.hh" +#include "Keys.hh" #include "Window.hh" #include "WindowCmd.hh" #include "Screen.hh"

@@ -27,6 +29,8 @@ #include "WinClient.hh"

#include "WinButtonTheme.hh" #include "FbTk/App.hh" #include "FbTk/Color.hh" +#include "FbTk/Command.hh" +#include "FbTk/RefCount.hh" #ifdef SHAPE #include <X11/extensions/shape.h>

@@ -56,11 +60,33 @@ FbTk::Button::exposeEvent(event);

drawType(); } -void WinButton::buttonReleaseEvent(XButtonEvent &event) { - WinClient *old = WindowCmd<void>::client(); +void WinButton::buttonReleaseEvent(XButtonEvent &be) { + bool didCustomAction = false; + if (isPressed() && be.button > 0 && be.button <= 5 && + be.x >= -static_cast<signed>(borderWidth()) && + be.x <= static_cast<signed>(width()+borderWidth()) && + be.y >= -static_cast<signed>(borderWidth()) && + be.y <= static_cast<signed>(height()+borderWidth())) { + int context = Keys::ON_WINBUTTON; + if (m_type == MINIMIZE) + context = Keys::ON_MINBUTTON; + if (m_type == MAXIMIZE) + context = Keys::ON_MAXBUTTON; + Keys *k = Fluxbox::instance()->keys(); + didCustomAction = k->doAction(be.type, be.state, be.button, context, &m_listen_to.winClient(), be.time); + } + static FbTk::RefCount<FbTk::Command<void> > noop = FbTk::RefCount<FbTk::Command<void> >(0); + FbTk::RefCount<FbTk::Command<void> > oldCmd; + if (didCustomAction) { + oldCmd = command(be.button); + setOnClick(noop, be.button); + } + WinClient *oldClient = WindowCmd<void>::client(); WindowCmd<void>::setWindow(&m_listen_to); - FbTk::Button::buttonReleaseEvent(event); - WindowCmd<void>::setClient(old); + FbTk::Button::buttonReleaseEvent(be); + WindowCmd<void>::setClient(oldClient); + if (didCustomAction) + setOnClick(oldCmd, be.button); } // when someone else tries to set the background, we may override it