]>
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 EventDispatcher::EventDispatcher()
14 : _fallback(0), _master(0)
18 EventDispatcher::~EventDispatcher()
22 void EventDispatcher::clearAllHandlers(void)
27 void EventDispatcher::registerHandler(Window id
, EventHandler
*handler
)
29 _map
.insert(std::pair
<Window
, EventHandler
*>(id
, handler
));
32 void EventDispatcher::clearHandler(Window id
)
37 void EventDispatcher::dispatchEvents(void)
41 while (XPending(**display
)) {
42 XNextEvent(**display
, &e
);
45 printf("Event %d window %lx\n", e
.type
, e
.xany
.window
);
48 if (e
.type
== FocusIn
|| e
.type
== FocusOut
) {
49 // focus events are a beast all their own.. yuk, hate, etc.
57 win
= e
.xunmap
.window
;
60 win
= e
.xdestroywindow
.window
;
62 case ConfigureRequest
:
63 win
= e
.xconfigurerequest
.window
;
69 // grab the lasttime and hack up the modifiers
73 _lasttime
= e
.xbutton
.time
;
74 e
.xbutton
.state
&= ~(LockMask
| display
->numLockMask() |
75 display
->scrollLockMask());
78 e
.xkey
.state
&= ~(LockMask
| display
->numLockMask() |
79 display
->scrollLockMask());
82 _lasttime
= e
.xmotion
.time
;
83 e
.xmotion
.state
&= ~(LockMask
| display
->numLockMask() |
84 display
->scrollLockMask());
87 _lasttime
= e
.xproperty
.time
;
91 _lasttime
= e
.xcrossing
.time
;
100 void EventDispatcher::dispatchFocus(const XEvent
&e
)
102 // ignore focus changes from grabs
103 if (e
.xfocus
.mode
== NotifyGrab
) // ||
104 // From Metacity, from WindowMaker, ignore all funky pointer root events
105 // its commented out cuz I don't think we need this at all. If problems
106 // arise we can look into it
107 //e.xfocus.detail > NotifyNonlinearVirtual)
110 if (e
.type
== FocusIn
) {
111 //printf("Got FocusIn!\n");
113 // send a FocusIn to whatever was just focused
114 dispatch(e
.xfocus
.window
, e
);
115 //printf("Sent FocusIn 0x%lx\n", e.xfocus.window);
117 } else if (e
.type
== FocusOut
) {
118 //printf("Got FocusOut!\n");
120 // FocusOut events just make us look for FocusIn events. They are ignored
123 if (XCheckTypedEvent(**display
, FocusIn
, &fi
)) {
124 //printf("Found FocusIn\n");
126 // dont unfocus the window we just focused!
127 if (fi
.xfocus
.window
== e
.xfocus
.window
)
131 dispatch(e
.xfocus
.window
, e
);
132 //printf("Sent FocusOut 0x%lx\n", e.xfocus.window);
136 void EventDispatcher::dispatch(Window win
, const XEvent
&e
)
138 EventHandler
*handler
= 0;
139 EventMap::iterator it
;
141 // master gets everything first
145 // find handler for the chosen window
148 if (it
!= _map
.end()) {
149 // if we found a handler
150 handler
= it
->second
;
151 } else if (e
.type
== ConfigureRequest
) {
152 // unhandled configure requests must be used to configure the window
156 xwc
.x
= e
.xconfigurerequest
.x
;
157 xwc
.y
= e
.xconfigurerequest
.y
;
158 xwc
.width
= e
.xconfigurerequest
.width
;
159 xwc
.height
= e
.xconfigurerequest
.height
;
160 xwc
.border_width
= e
.xconfigurerequest
.border_width
;
161 xwc
.sibling
= e
.xconfigurerequest
.above
;
162 xwc
.stack_mode
= e
.xconfigurerequest
.detail
;
164 XConfigureWindow(**display
, e
.xconfigurerequest
.window
,
165 e
.xconfigurerequest
.value_mask
, &xwc
);
167 // grab a falback if it exists
175 EventHandler
*EventDispatcher::findHandler(Window win
)
177 EventMap::iterator it
= _map
.find(win
);
178 if (it
!= _map
.end())
This page took 0.039871 seconds and 4 git commands to generate.