]>
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 unsigned int OBActions::DOUBLECLICKDELAY
= 300;
21 OBActions::OBActions()
24 // XXX: load a configuration out of somewhere
29 OBActions::~OBActions()
34 void OBActions::buttonPressHandler(const XButtonEvent
&e
)
36 OtkEventHandler::buttonPressHandler(e
);
38 // run the PRESS python hook
39 OBWidget
*w
= dynamic_cast<OBWidget
*>
40 (Openbox::instance
->findHandler(e
.window
));
42 python_callback(Action_ButtonPress
, e
.window
,
43 (OBWidget::WidgetType
)(w
? w
->type():-1),
44 e
.state
, e
.button
, e
.x_root
, e
.y_root
, e
.time
);
46 if (_button
) return; // won't count toward CLICK events
52 void OBActions::buttonReleaseHandler(const XButtonEvent
&e
)
54 OtkEventHandler::buttonReleaseHandler(e
);
56 OBWidget
*w
= dynamic_cast<OBWidget
*>
57 (Openbox::instance
->findHandler(e
.window
));
59 // run the RELEASE python hook
60 python_callback(Action_ButtonRelease
, e
.window
,
61 (OBWidget::WidgetType
)(w
? w
->type():-1),
62 e
.state
, e
.button
, e
.x_root
, e
.y_root
, e
.time
);
64 // not for the button we're watching?
65 if (_button
!= e
.button
) return;
69 // find the area of the window
70 XWindowAttributes attr
;
71 if (!XGetWindowAttributes(otk::OBDisplay::display
, e
.window
, &attr
)) return;
73 // if not on the window any more, it isnt a CLICK
74 if (!(e
.same_screen
&& e
.x
>= 0 && e
.y
>= 0 &&
75 e
.x
< attr
.width
&& e
.y
< attr
.height
))
78 // run the CLICK python hook
79 python_callback(Action_Click
, e
.window
,
80 (OBWidget::WidgetType
)(w
? w
->type():-1),
81 e
.state
, e
.button
, e
.time
);
83 if (e
.time
- _release
.time
< DOUBLECLICKDELAY
&&
84 _release
.win
== e
.window
&& _release
.button
== e
.button
) {
86 // run the DOUBLECLICK python hook
87 python_callback(Action_DoubleClick
, e
.window
,
88 (OBWidget::WidgetType
)(w
? w
->type():-1),
89 e
.state
, e
.button
, e
.time
);
91 // reset so you cant triple click for 2 doubleclicks
96 // save the button release, might be part of a double click
97 _release
.win
= e
.window
;
98 _release
.button
= e
.button
;
99 _release
.time
= e
.time
;
104 void OBActions::enterHandler(const XCrossingEvent
&e
)
106 OtkEventHandler::enterHandler(e
);
108 OBWidget
*w
= dynamic_cast<OBWidget
*>
109 (Openbox::instance
->findHandler(e
.window
));
111 // run the ENTER python hook
112 python_callback(Action_EnterWindow
, e
.window
,
113 (OBWidget::WidgetType
)(w
? w
->type():-1), e
.state
);
117 void OBActions::leaveHandler(const XCrossingEvent
&e
)
119 OtkEventHandler::leaveHandler(e
);
121 OBWidget
*w
= dynamic_cast<OBWidget
*>
122 (Openbox::instance
->findHandler(e
.window
));
124 // run the LEAVE python hook
125 python_callback(Action_LeaveWindow
, e
.window
,
126 (OBWidget::WidgetType
)(w
? w
->type():-1), e
.state
);
130 void OBActions::keyPressHandler(const XKeyEvent
&e
)
132 // OBWidget *w = dynamic_cast<OBWidget*>
133 // (Openbox::instance->findHandler(e.window));
135 Openbox::instance
->bindings()->fire(e
.window
, e
.state
, e
.keycode
, e
.time
);
139 void OBActions::motionHandler(const XMotionEvent
&e
)
141 if (!e
.same_screen
) return; // this just gets stupid
143 int x_root
= e
.x_root
, y_root
= e
.y_root
;
145 // compress changes to a window into a single change
147 while (XCheckTypedEvent(otk::OBDisplay::display
, e
.type
, &ce
)) {
148 if (ce
.xmotion
.window
!= e
.window
) {
149 XPutBackEvent(otk::OBDisplay::display
, &ce
);
158 OBWidget
*w
= dynamic_cast<OBWidget
*>
159 (Openbox::instance
->findHandler(e
.window
));
161 // XXX: i can envision all sorts of crazy shit with this.. gestures, etc
162 // maybe that should all be done via python tho.. (or radial menus!)
163 // run the simple MOTION python hook for now...
164 python_callback(Action_MouseMotion
, e
.window
,
165 (OBWidget::WidgetType
)(w
? w
->type():-1),
166 e
.state
, e
.x_root
, e
.y_root
, e
.time
);
169 void OBActions::mapRequestHandler(const XMapRequestEvent
&e
)
173 void OBActions::unmapHandler(const XUnmapEvent
&e
)
177 void OBActions::destroyHandler(const XDestroyWindowEvent
&e
)
This page took 0.03969 seconds and 4 git commands to generate.