+ while (!_shutdown) {
+ _timermanager.fire(!_sync); // wait if not in sync mode
+ dispatchEvents(); // from otk::EventDispatcher
+ XFlush(otk::Display::display); // flush here before we go wait for timers
+ }
+}
+
+
+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::display, _focused_screen->focuswindow(),
+ RevertToNone, CurrentTime);
+ }
+ // set the NET_ACTIVE_WINDOW hint for all screens
+ ScreenList::iterator it, end = _screens.end();
+ for (it = _screens.begin(); it != end; ++it) {
+ int num = (*it)->number();
+ Window root = otk::Display::screenInfo(num)->rootWindow();
+ _property->set(root, otk::Property::net_active_window,
+ otk::Property::Atom_Window,
+ (c && _focused_screen == *it) ? c->window() : None);