]>
Dogcows Code - chaz/openbox/blob - otk/eventdispatcher.cc
73c329e8d27df340fb76e37b96ec775da33950ea
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), _focus(None
)
16 _focus_e
.xfocus
.mode
= NotifyNormal
;
17 _focus_e
.xfocus
.detail
= NotifyNonlinear
;
20 OtkEventDispatcher::~OtkEventDispatcher()
24 void OtkEventDispatcher::clearAllHandlers(void)
29 void OtkEventDispatcher::registerHandler(Window id
, OtkEventHandler
*handler
)
31 _map
.insert(std::pair
<Window
, OtkEventHandler
*>(id
, handler
));
34 void OtkEventDispatcher::clearHandler(Window id
)
39 void OtkEventDispatcher::dispatchEvents(void)
41 OtkEventMap::iterator it
;
43 Window focus
= _focus
;
44 Window unfocus
= None
;
46 while (XPending(OBDisplay::display
)) {
47 XNextEvent(OBDisplay::display
, &e
);
50 printf("Event %d window %lx\n", e
.type
, e
.xany
.window
);
53 // these ConfigureRequests require some special attention
54 if (e
.type
== ConfigureRequest
) {
55 // find the actual window! e.xany.window is the parent window
56 it
= _map
.find(e
.xconfigurerequest
.window
);
59 it
->second
->handle(e
);
61 // unhandled configure requests must be used to configure the window
65 xwc
.x
= e
.xconfigurerequest
.x
;
66 xwc
.y
= e
.xconfigurerequest
.y
;
67 xwc
.width
= e
.xconfigurerequest
.width
;
68 xwc
.height
= e
.xconfigurerequest
.height
;
69 xwc
.border_width
= e
.xconfigurerequest
.border_width
;
70 xwc
.sibling
= e
.xconfigurerequest
.above
;
71 xwc
.stack_mode
= e
.xconfigurerequest
.detail
;
73 XConfigureWindow(otk::OBDisplay::display
, e
.xconfigurerequest
.window
,
74 e
.xconfigurerequest
.value_mask
, &xwc
);
76 // madly compress all focus events
77 } else if (e
.type
== FocusIn
) {
78 // any other types are not ones we're interested in
79 if (e
.xfocus
.detail
== NotifyNonlinear
) {
80 if (e
.xfocus
.window
!= focus
) {
82 focus
= e
.xfocus
.window
;
85 } else if (e
.type
== FocusOut
) {
86 // any other types are not ones we're interested in
87 if (e
.xfocus
.detail
== NotifyNonlinear
) {
88 if (e
.xfocus
.window
== focus
) {
99 if (focus
!= _focus
) {
100 _focus_e
.xfocus
.type
= FocusIn
;
101 _focus_e
.xfocus
.window
= focus
;
105 if (unfocus
!= None
) {
106 _focus_e
.xfocus
.type
= FocusOut
;
107 _focus_e
.xfocus
.window
= unfocus
;
112 void OtkEventDispatcher::dispatch(const XEvent
&e
) {
113 OtkEventHandler
*handler
;
114 OtkEventMap::iterator it
;
116 it
= _map
.find(e
.xany
.window
);
118 if (it
!= _map
.end())
119 handler
= it
->second
;
130 OtkEventHandler
*OtkEventDispatcher::findHandler(Window win
)
132 OtkEventMap::iterator it
= _map
.find(win
);
133 if (it
!= _map
.end())
This page took 0.041948 seconds and 4 git commands to generate.