]>
Dogcows Code - chaz/openbox/blob - actions.cc
1d4a5bb691a3ce4cbe4fbaef8dd62da6277a04fa
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
);
77 ButtonData
*data
= new_button_data(e
.window
, e
.time
, state
, e
.button
,
78 w
->mcontext(), MousePress
);
79 Openbox::instance
->bindings()->fireButton(data
);
80 Py_DECREF((PyObject
*)data
);
82 if (_button
) return; // won't count toward CLICK events
88 void OBActions::buttonReleaseHandler(const XButtonEvent
&e
)
90 OtkEventHandler::buttonReleaseHandler(e
);
93 OBWidget
*w
= dynamic_cast<OBWidget
*>
94 (Openbox::instance
->findHandler(e
.window
));
95 assert(w
); // everything should be a widget
97 // not for the button we're watching?
98 if (_button
!= e
.button
) return;
102 // find the area of the window
103 XWindowAttributes attr
;
104 if (!XGetWindowAttributes(otk::OBDisplay::display
, e
.window
, &attr
)) return;
106 // if not on the window any more, it isnt a CLICK
107 if (!(e
.same_screen
&& e
.x
>= 0 && e
.y
>= 0 &&
108 e
.x
< attr
.width
&& e
.y
< attr
.height
))
111 // run the CLICK python hook
112 // kill off the Button1Mask etc, only want the modifiers
113 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
114 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
115 ButtonData
*data
= new_button_data(e
.window
, e
.time
, state
, e
.button
,
116 w
->mcontext(), MouseClick
);
117 Openbox::instance
->bindings()->fireButton(data
);
120 // XXX: dont load this every time!!@*
122 if (!python_get_long("double_click_delay", &dblclick
))
125 if (e
.time
- _release
.time
< (unsigned)dblclick
&&
126 _release
.win
== e
.window
&& _release
.button
== e
.button
) {
128 // run the DOUBLECLICK python hook
129 data
->action
= MouseDoubleClick
;
130 Openbox::instance
->bindings()->fireButton(data
);
132 // reset so you cant triple click for 2 doubleclicks
137 // save the button release, might be part of a double click
138 _release
.win
= e
.window
;
139 _release
.button
= e
.button
;
140 _release
.time
= e
.time
;
143 Py_DECREF((PyObject
*)data
);
147 void OBActions::enterHandler(const XCrossingEvent
&e
)
149 OtkEventHandler::enterHandler(e
);
151 // run the ENTER python hook
152 EventData
*data
= new_event_data(e
.window
, EventEnterWindow
, e
.state
);
153 Openbox::instance
->bindings()->fireEvent(data
);
154 Py_DECREF((PyObject
*)data
);
158 void OBActions::leaveHandler(const XCrossingEvent
&e
)
160 OtkEventHandler::leaveHandler(e
);
162 // run the LEAVE python hook
163 EventData
*data
= new_event_data(e
.window
, EventLeaveWindow
, e
.state
);
164 Openbox::instance
->bindings()->fireEvent(data
);
165 Py_DECREF((PyObject
*)data
);
169 void OBActions::keyPressHandler(const XKeyEvent
&e
)
171 OtkEventHandler::keyPressHandler(e
);
173 // kill off the Button1Mask etc, only want the modifiers
174 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
175 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
176 Openbox::instance
->bindings()->fireKey(state
, e
.keycode
, e
.time
);
180 void OBActions::motionHandler(const XMotionEvent
&e
)
182 OtkEventHandler::motionHandler(e
);
184 if (!e
.same_screen
) return; // this just gets stupid
186 int x_root
= e
.x_root
, y_root
= e
.y_root
;
188 // compress changes to a window into a single change
190 while (XCheckTypedEvent(otk::OBDisplay::display
, e
.type
, &ce
)) {
191 if (ce
.xmotion
.window
!= e
.window
) {
192 XPutBackEvent(otk::OBDisplay::display
, &ce
);
200 OBWidget
*w
= dynamic_cast<OBWidget
*>
201 (Openbox::instance
->findHandler(e
.window
));
202 assert(w
); // everything should be a widget
204 // run the MOTION python hook
205 // kill off the Button1Mask etc, only want the modifiers
206 unsigned int state
= e
.state
& (ControlMask
| ShiftMask
| Mod1Mask
|
207 Mod2Mask
| Mod3Mask
| Mod4Mask
| Mod5Mask
);
208 unsigned int button
= _posqueue
[0]->button
;
209 MotionData
*data
= new_motion_data(e
.window
, e
.time
, state
, button
,
210 w
->mcontext(), MouseMotion
,
211 x_root
, y_root
, _posqueue
[0]->pos
,
212 _posqueue
[0]->clientarea
);
213 Openbox::instance
->bindings()->fireButton((ButtonData
*)data
);
214 Py_DECREF((PyObject
*)data
);
217 void OBActions::mapRequestHandler(const XMapRequestEvent
&e
)
219 OtkEventHandler::mapRequestHandler(e
);
220 // do this in OBScreen::manageWindow
223 void OBActions::unmapHandler(const XUnmapEvent
&e
)
225 OtkEventHandler::unmapHandler(e
);
226 // do this in OBScreen::unmanageWindow
229 void OBActions::destroyHandler(const XDestroyWindowEvent
&e
)
231 OtkEventHandler::destroyHandler(e
);
232 // do this in OBScreen::unmanageWindow
This page took 0.042375 seconds and 3 git commands to generate.