]>
Dogcows Code - chaz/openbox/blob - otk/eventdispatcher.cc
c80f3857a41a77ab7fd9ccb5f5571d2d894def74
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
) {
83 focus
= e
.xfocus
.window
;
84 printf("FocusIn focus=%lx unfocus=%lx\n", focus
, unfocus
);
87 } else if (e
.type
== FocusOut
) {
88 // any other types are not ones we're interested in
89 if (e
.xfocus
.detail
== NotifyNonlinear
) {
90 if (e
.xfocus
.window
== focus
) {
93 printf("FocusIn focus=%lx unfocus=%lx\n", focus
, unfocus
);
102 if (focus
!= _focus
) {
103 _focus_e
.xfocus
.type
= FocusIn
;
104 _focus_e
.xfocus
.window
= focus
;
108 if (unfocus
!= None
) {
109 _focus_e
.xfocus
.type
= FocusOut
;
110 _focus_e
.xfocus
.window
= unfocus
;
115 void OtkEventDispatcher::dispatch(const XEvent
&e
) {
116 OtkEventHandler
*handler
;
117 OtkEventMap::iterator it
;
119 it
= _map
.find(e
.xany
.window
);
121 if (it
!= _map
.end())
122 handler
= it
->second
;
133 OtkEventHandler
*OtkEventDispatcher::findHandler(Window win
)
135 OtkEventMap::iterator it
= _map
.find(win
);
136 if (it
!= _map
.end())
This page took 0.0376 seconds and 4 git commands to generate.