]> Dogcows Code - chaz/openbox/blob - otk/eventdispatcher.cc
add the swig generated files
[chaz/openbox] / otk / eventdispatcher.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif
6
7 #include "eventdispatcher.hh"
8 #include "display.hh"
9 #include <iostream>
10
11 namespace otk {
12
13 OtkEventDispatcher::OtkEventDispatcher()
14 : _fallback(0), _master(0)
15 {
16 }
17
18 OtkEventDispatcher::~OtkEventDispatcher()
19 {
20 }
21
22 void OtkEventDispatcher::clearAllHandlers(void)
23 {
24 _map.clear();
25 }
26
27 void OtkEventDispatcher::registerHandler(Window id, OtkEventHandler *handler)
28 {
29 _map.insert(std::pair<Window, OtkEventHandler*>(id, handler));
30 }
31
32 void OtkEventDispatcher::clearHandler(Window id)
33 {
34 _map.erase(id);
35 }
36
37 void OtkEventDispatcher::dispatchEvents(void)
38 {
39 XEvent e;
40 OtkEventHandler *handler;
41 OtkEventMap::iterator it;
42
43 while (XPending(OBDisplay::display)) {
44 XNextEvent(OBDisplay::display, &e);
45
46 #if 0
47 printf("Event %d window %lx\n", e.type, e.xany.window);
48 #endif
49
50 // these ConfigureRequests require some special attention
51 if (e.type == ConfigureRequest) {
52 // find the actual window! e.xany.window is the parent window
53 it = _map.find(e.xconfigurerequest.window);
54
55 if (it != _map.end())
56 it->second->handle(e);
57 else {
58 // unhandled configure requests must be used to configure the window
59 // directly
60 XWindowChanges xwc;
61
62 xwc.x = e.xconfigurerequest.x;
63 xwc.y = e.xconfigurerequest.y;
64 xwc.width = e.xconfigurerequest.width;
65 xwc.height = e.xconfigurerequest.height;
66 xwc.border_width = e.xconfigurerequest.border_width;
67 xwc.sibling = e.xconfigurerequest.above;
68 xwc.stack_mode = e.xconfigurerequest.detail;
69
70 XConfigureWindow(otk::OBDisplay::display, e.xconfigurerequest.window,
71 e.xconfigurerequest.value_mask, &xwc);
72 }
73 } else {
74 // normal events
75
76 it = _map.find(e.xany.window);
77
78 if (it != _map.end())
79 handler = it->second;
80 else
81 handler = _fallback;
82
83 if (handler)
84 handler->handle(e);
85 }
86
87 if (_master)
88 _master->handle(e);
89 }
90 }
91
92 OtkEventHandler *OtkEventDispatcher::findHandler(Window win)
93 {
94 OtkEventMap::iterator it = _map.find(win);
95 if (it != _map.end())
96 return it->second;
97 return 0;
98 }
99
100 }
This page took 0.037782 seconds and 4 git commands to generate.