- while (!_doshutdown) {
- if (XPending(otk::OBDisplay::display)) {
- XEvent e;
- XNextEvent(otk::OBDisplay::display, &e);
- //process_event(&e);
- _xeventhandler.handle(e);
- } else {
- _timermanager.fire();
- }
+ while (true) {
+ dispatchEvents(); // from otk::EventDispatcher
+ XFlush(**otk::display); // flush here before we go wait for timers
+ // don't wait if we're to shutdown
+ if (_shutdown) break;
+ otk::Timer::dispatchTimers(!_sync); // wait if not in sync mode
+ }
+}
+
+
+void Openbox::addClient(Window window, Client *client)
+{
+ _clients[window] = client;
+}
+
+
+void Openbox::removeClient(Window window)
+{
+ _clients.erase(window);
+}
+
+
+Client *Openbox::findClient(Window window)
+{
+ /*
+ NOTE: we dont use _clients[] to find the value because that will insert
+ a new null into the hash, which really sucks when we want to clean up the
+ hash at shutdown!
+ */
+ ClientMap::iterator it = _clients.find(window);
+ if (it != _clients.end())
+ return it->second;
+ else
+ return (Client*) 0;
+}
+
+
+void Openbox::setFocusedClient(Client *c)
+{
+ _focused_client = c;
+ if (c) {
+ _focused_screen = _screens[c->screen()];
+ } else {
+ assert(_focused_screen);
+ XSetInputFocus(**otk::display, _focused_screen->focuswindow(),
+ RevertToNone, CurrentTime);