]> Dogcows Code - chaz/openbox/blobdiff - src/client.cc
focus works
[chaz/openbox] / src / client.cc
index a22a18a6481afd40d9a4b650805fe04dcfcf976b..74783eedac3c5e875ed47d9ff489bd1ed6834bd8 100644 (file)
@@ -40,6 +40,8 @@ OBClient::OBClient(int screen, Window window)
   _wmstate = NormalState;
   // no default decors or functions, each has to be enabled
   _decorations = _functions = 0;
+  // start unfocused
+  _focused = false;
   
   getArea();
   getDesktop();
@@ -460,6 +462,9 @@ void OBClient::updateTitle()
 
   if (_title.empty())
     _title = _("Unnamed Window");
+
+  if (frame)
+    frame->setTitle(_title);
 }
 
 
@@ -859,6 +864,43 @@ void OBClient::close()
 }
 
 
+bool OBClient::focus()
+{
+  if (!_can_focus || _focused) return false;
+
+  XSetInputFocus(otk::OBDisplay::display, _window, RevertToNone, CurrentTime);
+  return true;
+}
+
+
+void OBClient::unfocus()
+{
+  if (!_focused) return;
+
+  assert(Openbox::instance->focusedClient() == this);
+  Openbox::instance->setFocusedClient(0);
+}
+
+
+void OBClient::focusHandler(const XFocusChangeEvent &)
+{
+  frame->focus();
+  _focused = true;
+
+  Openbox::instance->setFocusedClient(this);
+}
+
+
+void OBClient::unfocusHandler(const XFocusChangeEvent &)
+{
+  frame->unfocus();
+  _focused = false;
+
+  if (Openbox::instance->focusedClient() == this)
+    Openbox::instance->setFocusedClient(0);
+}
+
+
 void OBClient::configureRequestHandler(const XConfigureRequestEvent &e)
 {
   OtkEventHandler::configureRequestHandler(e);
This page took 0.020859 seconds and 4 git commands to generate.