]>
Dogcows Code - chaz/openbox/blob - otk/eventdispatcher.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
7 #include "eventdispatcher.hh"
13 OtkEventDispatcher::OtkEventDispatcher()
14 : _fallback(0), _master(0)
18 OtkEventDispatcher::~OtkEventDispatcher()
22 void OtkEventDispatcher::clearAllHandlers(void)
27 void OtkEventDispatcher::registerHandler(Window id
, OtkEventHandler
*handler
)
29 _map
.insert(std::pair
<Window
, OtkEventHandler
*>(id
, handler
));
32 void OtkEventDispatcher::clearHandler(Window id
)
37 void OtkEventDispatcher::dispatchEvents(void)
41 while (XPending(OBDisplay::display
)) {
42 XNextEvent(OBDisplay::display
, &e
);
45 printf("Event %d window %lx\n", e
.type
, e
.xany
.window
);
53 win
= e
.xunmap
.window
;
56 win
= e
.xdestroywindow
.window
;
58 case ConfigureRequest
:
59 win
= e
.xconfigurerequest
.window
;
65 // grab the lasttime and hack up the modifiers
69 _lasttime
= e
.xbutton
.time
;
70 e
.xbutton
.state
&= ~(LockMask
| OBDisplay::numLockMask() |
71 OBDisplay::scrollLockMask());
74 e
.xkey
.state
&= ~(LockMask
| OBDisplay::numLockMask() |
75 OBDisplay::scrollLockMask());
78 _lasttime
= e
.xmotion
.time
;
79 e
.xmotion
.state
&= ~(LockMask
| OBDisplay::numLockMask() |
80 OBDisplay::scrollLockMask());
83 _lasttime
= e
.xproperty
.time
;
87 _lasttime
= e
.xcrossing
.time
;
91 if (e
.type
== FocusIn
|| e
.type
== FocusOut
)
92 // any other types are not ones we're interested in
93 if (e
.xfocus
.detail
!= NotifyNonlinear
)
96 if (e
.type
== FocusOut
) {
98 // send a FocusIn first if one exists
99 while (XCheckTypedEvent(OBDisplay::display
, FocusIn
, &fi
)) {
100 // any other types are not ones we're interested in
101 printf("found focusin\n");
102 if (fi
.xfocus
.detail
== NotifyNonlinear
) {
103 printf("sending focusin\n");
104 dispatch(fi
.xfocus
.window
, fi
);
114 void OtkEventDispatcher::dispatch(Window win
, const XEvent
&e
)
116 OtkEventHandler
*handler
= 0;
117 OtkEventMap::iterator it
;
119 // master gets everything first
123 // find handler for the chosen window
126 if (it
!= _map
.end()) {
127 // if we found a handler
128 handler
= it
->second
;
129 } else if (e
.type
== ConfigureRequest
) {
130 // unhandled configure requests must be used to configure the window
134 xwc
.x
= e
.xconfigurerequest
.x
;
135 xwc
.y
= e
.xconfigurerequest
.y
;
136 xwc
.width
= e
.xconfigurerequest
.width
;
137 xwc
.height
= e
.xconfigurerequest
.height
;
138 xwc
.border_width
= e
.xconfigurerequest
.border_width
;
139 xwc
.sibling
= e
.xconfigurerequest
.above
;
140 xwc
.stack_mode
= e
.xconfigurerequest
.detail
;
142 XConfigureWindow(otk::OBDisplay::display
, e
.xconfigurerequest
.window
,
143 e
.xconfigurerequest
.value_mask
, &xwc
);
145 // grab a falback if it exists
153 OtkEventHandler
*OtkEventDispatcher::findHandler(Window win
)
155 OtkEventMap::iterator it
= _map
.find(win
);
156 if (it
!= _map
.end())
This page took 0.042245 seconds and 4 git commands to generate.