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)
39 void OtkEventDispatcher::dispatchEvents(void)
42 OtkEventHandler *handler;
43 OtkEventMap::iterator it;
45 while (XPending(OBDisplay::display)) {
46 XNextEvent(OBDisplay::display, &e);
48 #if defined(DEBUG) && 0
49 printf("Event %d window %lx\n", e.type, e.xany.window);
52 // these ConfigureRequests require some special attention
53 if (e.type == ConfigureRequest) {
54 // find the actual window! e.xany.window is the parent window
55 it = _map.find(e.xconfigurerequest.window);
58 it->second->handle(e);
60 // unhandled configure requests must be used to configure the window
64 xwc.x = e.xconfigurerequest.x;
65 xwc.y = e.xconfigurerequest.y;
66 xwc.width = e.xconfigurerequest.width;
67 xwc.height = e.xconfigurerequest.height;
68 xwc.border_width = e.xconfigurerequest.border_width;
69 xwc.sibling = e.xconfigurerequest.above;
70 xwc.stack_mode = e.xconfigurerequest.detail;
72 XConfigureWindow(otk::OBDisplay::display, e.xconfigurerequest.window,
73 e.xconfigurerequest.value_mask, &xwc);
78 it = _map.find(e.xany.window);