]>
Dogcows Code - chaz/openbox/blob - src/actions.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
8 #include "widgetbase.hh"
13 #include "bindings.hh"
14 #include "otk/display.hh"
20 const int Actions::BUTTONS
;
25 for (int i
=0; i
<BUTTONS
; ++i
)
26 _posqueue
[i
] = new ButtonPressAction();
32 for (int i
=0; i
<BUTTONS
; ++i
)
37 void Actions::insertPress(const XButtonEvent
&e
)
39 ButtonPressAction
*a
= _posqueue
[BUTTONS
- 1];
40 // rm'd the last one, shift them all down one
41 for (int i
= BUTTONS
-1; i
> 0; --i
) {
42 _posqueue
[i
] = _posqueue
[i
-1];
46 a
->pos
.setPoint(e
.x_root
, e
.y_root
);
48 Client
*c
= openbox
->findClient(e
.window
);
49 if (c
) a
->clientarea
= c
->area();
52 void Actions::removePress(const XButtonEvent
&e
)
55 ButtonPressAction
*a
= 0;
56 for (i
=0; i
<BUTTONS
-1; ++i
)
57 if (_posqueue
[i
]->button
== e
.button
) {
61 if (a
) { // found one, remove it and shift the rest up one
62 for (; i
< BUTTONS
-1; ++i
)
63 _posqueue
[i
] = _posqueue
[i
+1];
64 _posqueue
[BUTTONS
-1] = a
;
66 _posqueue
[BUTTONS
-1]->button
= 0;
69 void Actions::buttonPressHandler(const XButtonEvent
&e
)
71 otk::EventHandler::buttonPressHandler(e
);
74 // run the PRESS python hook
75 WidgetBase
*w
= dynamic_cast<WidgetBase
*>
76 (openbox
->findHandler(e
.window
));
79 // kill off the Button1Mask etc, only want the modifiers
80 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
81 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
83 Client
*c
= openbox
->findClient(e
.window
);
87 screen
= otk::display
->findScreen(e
.root
)->screen();
88 MouseData
data(screen
, c
, e
.time
, state
, e
.button
, w
->mcontext(),
90 openbox
->bindings()->fireButton(&data
);
92 if (_button
) return; // won't count toward CLICK events
96 if (w
->mcontext() == MC_Window
) {
98 Because of how events are grabbed on the client window, we can't get
99 ButtonRelease events, so instead we simply manufacture them here, so that
100 clicks/doubleclicks etc still work.
102 //XButtonEvent ev = e;
103 //ev.type = ButtonRelease;
104 buttonReleaseHandler(e
);
109 void Actions::buttonReleaseHandler(const XButtonEvent
&e
)
111 otk::EventHandler::buttonReleaseHandler(e
);
114 WidgetBase
*w
= dynamic_cast<WidgetBase
*>
115 (openbox
->findHandler(e
.window
));
118 // not for the button we're watching?
119 if (_button
!= e
.button
) return;
123 // find the area of the window
124 XWindowAttributes attr
;
125 if (!XGetWindowAttributes(**otk::display
, e
.window
, &attr
)) return;
127 // if not on the window any more, it isnt a CLICK
128 if (!(e
.same_screen
&& e
.x
>= 0 && e
.y
>= 0 &&
129 e
.x
< attr
.width
&& e
.y
< attr
.height
))
132 // run the CLICK python hook
133 // kill off the Button1Mask etc, only want the modifiers
134 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
135 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
137 Client
*c
= openbox
->findClient(e
.window
);
139 screen
= c
->screen();
141 screen
= otk::display
->findScreen(e
.root
)->screen();
142 MouseData
data(screen
, c
, e
.time
, state
, e
.button
, w
->mcontext(),
144 openbox
->bindings()->fireButton(&data
);
147 // XXX: dont load this every time!!@*
149 if (!python_get_long("double_click_delay", &dblclick
))
152 if (e
.time
- _release
.time
< (unsigned)dblclick
&&
153 _release
.win
== e
.window
&& _release
.button
== e
.button
) {
155 // run the DOUBLECLICK python hook
156 data
.action
= MouseDoubleClick
;
157 openbox
->bindings()->fireButton(&data
);
159 // reset so you cant triple click for 2 doubleclicks
164 // save the button release, might be part of a double click
165 _release
.win
= e
.window
;
166 _release
.button
= e
.button
;
167 _release
.time
= e
.time
;
172 void Actions::enterHandler(const XCrossingEvent
&e
)
174 otk::EventHandler::enterHandler(e
);
176 // run the ENTER python hook
178 Client
*c
= openbox
->findClient(e
.window
);
180 screen
= c
->screen();
182 screen
= otk::display
->findScreen(e
.root
)->screen();
183 EventData
data(screen
, c
, EventEnterWindow
, e
.state
);
184 openbox
->bindings()->fireEvent(&data
);
188 void Actions::leaveHandler(const XCrossingEvent
&e
)
190 otk::EventHandler::leaveHandler(e
);
192 // run the LEAVE python hook
194 Client
*c
= openbox
->findClient(e
.window
);
196 screen
= c
->screen();
198 screen
= otk::display
->findScreen(e
.root
)->screen();
199 EventData
data(screen
, c
, EventLeaveWindow
, e
.state
);
200 openbox
->bindings()->fireEvent(&data
);
204 void Actions::keyPressHandler(const XKeyEvent
&e
)
206 otk::EventHandler::keyPressHandler(e
);
208 // kill off the Button1Mask etc, only want the modifiers
209 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
210 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
211 openbox
->bindings()->
212 fireKey(otk::display
->findScreen(e
.root
)->screen(),
213 state
, e
.keycode
, e
.time
);
217 void Actions::motionHandler(const XMotionEvent
&e
)
219 otk::EventHandler::motionHandler(e
);
221 if (!e
.same_screen
) return; // this just gets stupid
223 int x_root
= e
.x_root
, y_root
= e
.y_root
;
225 // compress changes to a window into a single change
227 while (XCheckTypedEvent(**otk::display
, e
.type
, &ce
)) {
228 if (ce
.xmotion
.window
!= e
.window
) {
229 XPutBackEvent(**otk::display
, &ce
);
237 WidgetBase
*w
= dynamic_cast<WidgetBase
*>
238 (openbox
->findHandler(e
.window
));
241 // run the MOTION python hook
242 // kill off the Button1Mask etc, only want the modifiers
243 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
244 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
245 unsigned int button
= _posqueue
[0]->button
;
247 Client
*c
= openbox
->findClient(e
.window
);
249 screen
= c
->screen();
251 screen
= otk::display
->findScreen(e
.root
)->screen();
252 MouseData
data(screen
, c
, e
.time
, state
, button
, w
->mcontext(), MouseMotion
,
253 x_root
, y_root
, _posqueue
[0]->pos
, _posqueue
[0]->clientarea
);
254 openbox
->bindings()->fireButton(&data
);
257 void Actions::mapRequestHandler(const XMapRequestEvent
&e
)
259 otk::EventHandler::mapRequestHandler(e
);
260 // do this in Screen::manageWindow
263 void Actions::unmapHandler(const XUnmapEvent
&e
)
265 otk::EventHandler::unmapHandler(e
);
266 // do this in Screen::unmanageWindow
269 void Actions::destroyHandler(const XDestroyWindowEvent
&e
)
271 otk::EventHandler::destroyHandler(e
);
272 // do this in Screen::unmanageWindow
276 void Actions::xkbHandler(const XkbEvent
&e
)
281 otk::EventHandler::xkbHandler(e
);
283 switch (((XkbAnyEvent
*)&e
)->xkb_type
) {
285 w
= ((XkbBellNotifyEvent
*)&e
)->window
;
286 Client
*c
= openbox
->findClient(w
);
288 screen
= c
->screen();
290 screen
= openbox
->focusedScreen()->number();
291 EventData
data(screen
, c
, EventBell
, 0);
292 openbox
->bindings()->fireEvent(&data
);
This page took 0.048809 seconds and 4 git commands to generate.