]>
Dogcows Code - chaz/openbox/blob - otk/eventdispatcher.cc
38d395d7e57cca1f643598a843e6f006336c2bfe
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 if (fi
.xfocus
.detail
== NotifyNonlinear
) {
102 dispatch(fi
.xfocus
.window
, fi
);
112 void OtkEventDispatcher::dispatch(Window win
, const XEvent
&e
)
114 OtkEventHandler
*handler
= 0;
115 OtkEventMap::iterator it
;
117 // master gets everything first
121 // find handler for the chosen window
124 if (it
!= _map
.end()) {
125 // if we found a handler
126 handler
= it
->second
;
127 } else if (e
.type
== ConfigureRequest
) {
128 // unhandled configure requests must be used to configure the window
132 xwc
.x
= e
.xconfigurerequest
.x
;
133 xwc
.y
= e
.xconfigurerequest
.y
;
134 xwc
.width
= e
.xconfigurerequest
.width
;
135 xwc
.height
= e
.xconfigurerequest
.height
;
136 xwc
.border_width
= e
.xconfigurerequest
.border_width
;
137 xwc
.sibling
= e
.xconfigurerequest
.above
;
138 xwc
.stack_mode
= e
.xconfigurerequest
.detail
;
140 XConfigureWindow(otk::OBDisplay::display
, e
.xconfigurerequest
.window
,
141 e
.xconfigurerequest
.value_mask
, &xwc
);
143 // grab a falback if it exists
151 OtkEventHandler
*OtkEventDispatcher::findHandler(Window win
)
153 OtkEventMap::iterator it
= _map
.find(win
);
154 if (it
!= _map
.end())
This page took 0.044051 seconds and 4 git commands to generate.