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.
This commit is contained in:
Thomas Lübking 2016-09-14 18:11:06 +02:00 committed by Mathias Gumz
parent 7fd13acab1
commit 4545f4dac8
3 changed files with 40 additions and 5 deletions

View file

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

View file

@ -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...
};

View file

@ -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 <X11/extensions/shape.h>
@ -56,11 +60,33 @@ void WinButton::exposeEvent(XExposeEvent &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