]>
Dogcows Code - chaz/openbox/blob - src/actions.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
12 #include "bindings.hh"
13 #include "otk/display.hh"
19 const int OBActions::BUTTONS
;
21 OBActions::OBActions()
24 for (int i
=0; i
<BUTTONS
; ++i
)
25 _posqueue
[i
] = new ButtonPressAction();
29 OBActions::~OBActions()
31 for (int i
=0; i
<BUTTONS
; ++i
)
36 void OBActions::insertPress(const XButtonEvent
&e
)
38 ButtonPressAction
*a
= _posqueue
[BUTTONS
- 1];
39 for (int i
=BUTTONS
-1; i
>0;)
40 _posqueue
[i
] = _posqueue
[--i
];
43 a
->pos
.setPoint(e
.x_root
, e
.y_root
);
45 OBClient
*c
= Openbox::instance
->findClient(e
.window
);
46 if (c
) a
->clientarea
= c
->area();
49 void OBActions::removePress(const XButtonEvent
&e
)
51 ButtonPressAction
*a
= 0;
52 for (int i
=0; i
<BUTTONS
; ++i
) {
53 if (_posqueue
[i
]->button
== e
.button
)
55 if (a
) // found one and removed it
56 _posqueue
[i
] = _posqueue
[i
+1];
59 _posqueue
[BUTTONS
-1] = a
;
64 void OBActions::buttonPressHandler(const XButtonEvent
&e
)
66 OtkEventHandler::buttonPressHandler(e
);
69 // run the PRESS python hook
70 OBWidget
*w
= dynamic_cast<OBWidget
*>
71 (Openbox::instance
->findHandler(e
.window
));
72 assert(w
); // everything should be a widget
74 // kill off the Button1Mask etc, only want the modifiers
75 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
76 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
78 new_button_data(otk::OBDisplay::findScreen(e
.root
)->screen(),
79 e
.window
, e
.time
, state
, e
.button
, w
->mcontext(),
81 Openbox::instance
->bindings()->fireButton(data
);
82 Py_DECREF((PyObject
*)data
);
84 if (_button
) return; // won't count toward CLICK events
90 void OBActions::buttonReleaseHandler(const XButtonEvent
&e
)
92 OtkEventHandler::buttonReleaseHandler(e
);
95 OBWidget
*w
= dynamic_cast<OBWidget
*>
96 (Openbox::instance
->findHandler(e
.window
));
97 assert(w
); // everything should be a widget
99 // not for the button we're watching?
100 if (_button
!= e
.button
) return;
104 // find the area of the window
105 XWindowAttributes attr
;
106 if (!XGetWindowAttributes(otk::OBDisplay::display
, e
.window
, &attr
)) return;
108 // if not on the window any more, it isnt a CLICK
109 if (!(e
.same_screen
&& e
.x
>= 0 && e
.y
>= 0 &&
110 e
.x
< attr
.width
&& e
.y
< attr
.height
))
113 // run the CLICK python hook
114 // kill off the Button1Mask etc, only want the modifiers
115 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
116 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
118 new_button_data(otk::OBDisplay::findScreen(e
.root
)->screen(),
119 e
.window
, e
.time
, state
, e
.button
, w
->mcontext(),
121 Openbox::instance
->bindings()->fireButton(data
);
124 // XXX: dont load this every time!!@*
126 if (!python_get_long("double_click_delay", &dblclick
))
129 if (e
.time
- _release
.time
< (unsigned)dblclick
&&
130 _release
.win
== e
.window
&& _release
.button
== e
.button
) {
132 // run the DOUBLECLICK python hook
133 data
->action
= MouseDoubleClick
;
134 Openbox::instance
->bindings()->fireButton(data
);
136 // reset so you cant triple click for 2 doubleclicks
141 // save the button release, might be part of a double click
142 _release
.win
= e
.window
;
143 _release
.button
= e
.button
;
144 _release
.time
= e
.time
;
147 Py_DECREF((PyObject
*)data
);
151 void OBActions::enterHandler(const XCrossingEvent
&e
)
153 OtkEventHandler::enterHandler(e
);
155 // run the ENTER python hook
157 new_event_data(otk::OBDisplay::findScreen(e
.root
)->screen(),
158 e
.window
, EventEnterWindow
, e
.state
);
159 Openbox::instance
->bindings()->fireEvent(data
);
160 Py_DECREF((PyObject
*)data
);
164 void OBActions::leaveHandler(const XCrossingEvent
&e
)
166 OtkEventHandler::leaveHandler(e
);
168 // run the LEAVE python hook
170 new_event_data(otk::OBDisplay::findScreen(e
.root
)->screen(),
171 e
.window
, EventLeaveWindow
, e
.state
);
172 Openbox::instance
->bindings()->fireEvent(data
);
173 Py_DECREF((PyObject
*)data
);
177 void OBActions::keyPressHandler(const XKeyEvent
&e
)
179 OtkEventHandler::keyPressHandler(e
);
181 // kill off the Button1Mask etc, only want the modifiers
182 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
183 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
184 Openbox::instance
->bindings()->
185 fireKey(otk::OBDisplay::findScreen(e
.root
)->screen(),
186 state
, e
.keycode
, e
.time
);
190 void OBActions::motionHandler(const XMotionEvent
&e
)
192 OtkEventHandler::motionHandler(e
);
194 if (!e
.same_screen
) return; // this just gets stupid
196 int x_root
= e
.x_root
, y_root
= e
.y_root
;
198 // compress changes to a window into a single change
200 while (XCheckTypedEvent(otk::OBDisplay::display
, e
.type
, &ce
)) {
201 if (ce
.xmotion
.window
!= e
.window
) {
202 XPutBackEvent(otk::OBDisplay::display
, &ce
);
210 OBWidget
*w
= dynamic_cast<OBWidget
*>
211 (Openbox::instance
->findHandler(e
.window
));
212 assert(w
); // everything should be a widget
214 // run the MOTION python hook
215 // kill off the Button1Mask etc, only want the modifiers
216 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
217 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
218 unsigned int button
= _posqueue
[0]->button
;
220 new_motion_data(otk::OBDisplay::findScreen(e
.root
)->screen(),
221 e
.window
, e
.time
, state
, button
, w
->mcontext(),
222 MouseMotion
, x_root
, y_root
, _posqueue
[0]->pos
,
223 _posqueue
[0]->clientarea
);
224 Openbox::instance
->bindings()->fireButton((ButtonData
*)data
);
225 Py_DECREF((PyObject
*)data
);
228 void OBActions::mapRequestHandler(const XMapRequestEvent
&e
)
230 OtkEventHandler::mapRequestHandler(e
);
231 // do this in OBScreen::manageWindow
234 void OBActions::unmapHandler(const XUnmapEvent
&e
)
236 OtkEventHandler::unmapHandler(e
);
237 // do this in OBScreen::unmanageWindow
240 void OBActions::destroyHandler(const XDestroyWindowEvent
&e
)
242 OtkEventHandler::destroyHandler(e
);
243 // do this in OBScreen::unmanageWindow
This page took 0.044063 seconds and 4 git commands to generate.