+ // won't try focus if the client doesn't want it, or if the window isn't
+ // visible on the screen
+ if (!(frame->isVisible() && (_can_focus || _focus_notify))) return false;
+
+ if (_focused) return true;
+
+ if (_can_focus)
+ XSetInputFocus(**otk::display, _window,
+ RevertToNone, CurrentTime);
+
+ if (_focus_notify) {
+ XEvent ce;
+ const otk::Property *property = openbox->property();
+
+ ce.xclient.type = ClientMessage;
+ ce.xclient.message_type = property->atom(otk::Property::wm_protocols);
+ ce.xclient.display = **otk::display;
+ ce.xclient.window = _window;
+ ce.xclient.format = 32;
+ ce.xclient.data.l[0] = property->atom(otk::Property::wm_take_focus);
+ ce.xclient.data.l[1] = openbox->lastTime();
+ ce.xclient.data.l[2] = 0l;
+ ce.xclient.data.l[3] = 0l;
+ ce.xclient.data.l[4] = 0l;
+ XSendEvent(**otk::display, _window, False, NoEventMask, &ce);
+ }
+
+ return true;
+}
+
+
+void Client::unfocus() const
+{
+ if (!_focused) return;
+
+ assert(openbox->focusedClient() == this);
+ openbox->setFocusedClient(0);
+}
+
+
+void Client::focusHandler(const XFocusChangeEvent &e)
+{
+#ifdef DEBUG
+// printf("FocusIn for 0x%lx\n", e.window);
+#endif // DEBUG
+
+ otk::EventHandler::focusHandler(e);
+
+ frame->focus();
+ _focused = true;
+
+ openbox->setFocusedClient(this);
+}
+
+
+void Client::unfocusHandler(const XFocusChangeEvent &e)
+{
+#ifdef DEBUG
+// printf("FocusOut for 0x%lx\n", e.window);
+#endif // DEBUG
+
+ otk::EventHandler::unfocusHandler(e);
+
+ frame->unfocus();
+ _focused = false;
+
+ if (openbox->focusedClient() == this)
+ openbox->setFocusedClient(0);
+}
+
+
+void Client::configureRequestHandler(const XConfigureRequestEvent &e)
+{
+#ifdef DEBUG
+ printf("ConfigureRequest for 0x%lx\n", e.window);
+#endif // DEBUG
+
+ otk::EventHandler::configureRequestHandler(e);