aboutsummaryrefslogtreecommitdiff
path: root/src/WinButton.cc
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2016-09-14 16:11:06 (GMT)
committerMathias Gumz <akira@fluxbox.org>2016-09-21 18:46:39 (GMT)
commit4545f4dac81f61b7e99769006888a8688eeb542c (patch)
tree975aabaae733dfec7039ad15caf5b11aa577fcac /src/WinButton.cc
parent7fd13acab19dd449343fe8357946aa0c97d97f77 (diff)
downloadfluxbox-4545f4dac81f61b7e99769006888a8688eeb542c.zip
fluxbox-4545f4dac81f61b7e99769006888a8688eeb542c.tar.bz2
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.
Diffstat (limited to 'src/WinButton.cc')
-rw-r--r--src/WinButton.cc34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/WinButton.cc b/src/WinButton.cc
index c790a03..0cd2cfb 100644
--- a/src/WinButton.cc
+++ b/src/WinButton.cc
@@ -20,6 +20,8 @@
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22#include "WinButton.hh" 22#include "WinButton.hh"
23#include "fluxbox.hh"
24#include "Keys.hh"
23#include "Window.hh" 25#include "Window.hh"
24#include "WindowCmd.hh" 26#include "WindowCmd.hh"
25#include "Screen.hh" 27#include "Screen.hh"
@@ -27,6 +29,8 @@
27#include "WinButtonTheme.hh" 29#include "WinButtonTheme.hh"
28#include "FbTk/App.hh" 30#include "FbTk/App.hh"
29#include "FbTk/Color.hh" 31#include "FbTk/Color.hh"
32#include "FbTk/Command.hh"
33#include "FbTk/RefCount.hh"
30 34
31#ifdef SHAPE 35#ifdef SHAPE
32#include <X11/extensions/shape.h> 36#include <X11/extensions/shape.h>
@@ -56,11 +60,33 @@ void WinButton::exposeEvent(XExposeEvent &event) {
56 drawType(); 60 drawType();
57} 61}
58 62
59void WinButton::buttonReleaseEvent(XButtonEvent &event) { 63void WinButton::buttonReleaseEvent(XButtonEvent &be) {
60 WinClient *old = WindowCmd<void>::client(); 64 bool didCustomAction = false;
65 if (isPressed() && be.button > 0 && be.button <= 5 &&
66 be.x >= -static_cast<signed>(borderWidth()) &&
67 be.x <= static_cast<signed>(width()+borderWidth()) &&
68 be.y >= -static_cast<signed>(borderWidth()) &&
69 be.y <= static_cast<signed>(height()+borderWidth())) {
70 int context = Keys::ON_WINBUTTON;
71 if (m_type == MINIMIZE)
72 context = Keys::ON_MINBUTTON;
73 if (m_type == MAXIMIZE)
74 context = Keys::ON_MAXBUTTON;
75 Keys *k = Fluxbox::instance()->keys();
76 didCustomAction = k->doAction(be.type, be.state, be.button, context, &m_listen_to.winClient(), be.time);
77 }
78 static FbTk::RefCount<FbTk::Command<void> > noop = FbTk::RefCount<FbTk::Command<void> >(0);
79 FbTk::RefCount<FbTk::Command<void> > oldCmd;
80 if (didCustomAction) {
81 oldCmd = command(be.button);
82 setOnClick(noop, be.button);
83 }
84 WinClient *oldClient = WindowCmd<void>::client();
61 WindowCmd<void>::setWindow(&m_listen_to); 85 WindowCmd<void>::setWindow(&m_listen_to);
62 FbTk::Button::buttonReleaseEvent(event); 86 FbTk::Button::buttonReleaseEvent(be);
63 WindowCmd<void>::setClient(old); 87 WindowCmd<void>::setClient(oldClient);
88 if (didCustomAction)
89 setOnClick(oldCmd, be.button);
64} 90}
65 91
66// when someone else tries to set the background, we may override it 92// when someone else tries to set the background, we may override it