]> Dogcows Code - chaz/openbox/blobdiff - src/client.cc
add click_raise global var
[chaz/openbox] / src / client.cc
index a0dc6d76b159202ff0a7587f44a22689a891acf4..e626081ce19e871a2fe37e25653f5f257ee69ed0 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);
 }
 
 
@@ -835,8 +840,87 @@ void OBClient::move(int x, int y)
 }
 
 
+void OBClient::close()
+{
+  XEvent ce;
+  const otk::OBProperty *property = Openbox::instance->property();
+
+  if (!(_functions & Func_Close)) return;
+
+  // XXX: itd be cool to do timeouts and shit here for killing the client's
+  //      process off
+
+  ce.xclient.type = ClientMessage;
+  ce.xclient.message_type =  property->atom(otk::OBProperty::wm_protocols);
+  ce.xclient.display = otk::OBDisplay::display;
+  ce.xclient.window = _window;
+  ce.xclient.format = 32;
+  ce.xclient.data.l[0] = property->atom(otk::OBProperty::wm_delete_window);
+  ce.xclient.data.l[1] = CurrentTime;
+  ce.xclient.data.l[2] = 0l;
+  ce.xclient.data.l[3] = 0l;
+  ce.xclient.data.l[4] = 0l;
+  XSendEvent(otk::OBDisplay::display, _window, False, NoEventMask, &ce);
+}
+
+
+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 &e)
+{
+#ifdef    DEBUG
+  printf("FocusIn for 0x%lx\n", e.window);
+#endif // DEBUG
+  
+  OtkEventHandler::focusHandler(e);
+
+  frame->focus();
+  _focused = true;
+
+  Openbox::instance->setFocusedClient(this);
+}
+
+
+void OBClient::unfocusHandler(const XFocusChangeEvent &e)
+{
+#ifdef    DEBUG
+  printf("FocusOut for 0x%lx\n", e.window);
+#endif // DEBUG
+  
+  OtkEventHandler::unfocusHandler(e);
+
+  frame->unfocus();
+  _focused = false;
+
+  if (Openbox::instance->focusedClient() == this) {
+    printf("UNFOCUSED!\n");
+    Openbox::instance->setFocusedClient(this);
+  }
+}
+
+
 void OBClient::configureRequestHandler(const XConfigureRequestEvent &e)
 {
+#ifdef    DEBUG
+  printf("ConfigureRequest for 0x%lx\n", e.window);
+#endif // DEBUG
+  
   OtkEventHandler::configureRequestHandler(e);
 
   // XXX: if we are iconic (or shaded? (fvwm does that)) ignore the event
@@ -923,4 +1007,26 @@ void OBClient::destroyHandler(const XDestroyWindowEvent &e)
 }
 
 
+void OBClient::reparentHandler(const XReparentEvent &e)
+{
+  // this is when the client is first taken captive in the frame
+  if (e.parent == frame->plate()) return;
+
+#ifdef    DEBUG
+  printf("ReparentNotify for 0x%lx\n", e.window);
+#endif // DEBUG
+
+  OtkEventHandler::reparentHandler(e);
+
+  /*
+    This event is quite rare and is usually handled in unmapHandler.
+    However, if the window is unmapped when the reparent event occurs,
+    the window manager never sees it because an unmap event is not sent
+    to an already unmapped window.
+  */
+
+  // this deletes us etc
+  Openbox::instance->screen(_screen)->unmanageWindow(this);
+}
+
 }
This page took 0.025747 seconds and 4 git commands to generate.