diff --git a/src/Keys.cc b/src/Keys.cc index 072cba9e..846edea0 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -400,6 +400,12 @@ bool Keys::addBinding(const string &linebuffer) { 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") diff --git a/src/Keys.hh b/src/Keys.hh index 7a6b3b8f..a12efdbc 100644 --- a/src/Keys.hh +++ b/src/Keys.hh @@ -53,7 +53,10 @@ public: 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... }; diff --git a/src/WinButton.cc b/src/WinButton.cc index c790a03e..0cd2cfbe 100644 --- a/src/WinButton.cc +++ b/src/WinButton.cc @@ -20,6 +20,8 @@ // 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 "WinButtonTheme.hh" #include "FbTk/App.hh" #include "FbTk/Color.hh" +#include "FbTk/Command.hh" +#include "FbTk/RefCount.hh" #ifdef SHAPE #include @@ -56,11 +60,33 @@ void WinButton::exposeEvent(XExposeEvent &event) { drawType(); } -void WinButton::buttonReleaseEvent(XButtonEvent &event) { - WinClient *old = WindowCmd::client(); +void WinButton::buttonReleaseEvent(XButtonEvent &be) { + bool didCustomAction = false; + if (isPressed() && be.button > 0 && be.button <= 5 && + be.x >= -static_cast(borderWidth()) && + be.x <= static_cast(width()+borderWidth()) && + be.y >= -static_cast(borderWidth()) && + be.y <= static_cast(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 > noop = FbTk::RefCount >(0); + FbTk::RefCount > oldCmd; + if (didCustomAction) { + oldCmd = command(be.button); + setOnClick(noop, be.button); + } + WinClient *oldClient = WindowCmd::client(); WindowCmd::setWindow(&m_listen_to); - FbTk::Button::buttonReleaseEvent(event); - WindowCmd::setClient(old); + FbTk::Button::buttonReleaseEvent(be); + WindowCmd::setClient(oldClient); + if (didCustomAction) + setOnClick(oldCmd, be.button); } // when someone else tries to set the background, we may override it