]> Dogcows Code - chaz/openbox/blobdiff - src/client.cc
separate off execute, since its not a callback function
[chaz/openbox] / src / client.cc
index 88e218a4965d5526a71605cd9a878cd6eb73bdb1..d150cf8b4b54f391333432c5d6ff6af684e4378f 100644 (file)
@@ -98,9 +98,11 @@ OBClient::~OBClient()
 {
   const otk::OBProperty *property = Openbox::instance->property();
 
-  // these values should not be persisted across a window unmapping/mapping
-  property->erase(_window, otk::OBProperty::net_wm_desktop);
-  property->erase(_window, otk::OBProperty::net_wm_state);
+  if (Openbox::instance->state() != Openbox::State_Exiting) {
+    // these values should not be persisted across a window unmapping/mapping
+    property->erase(_window, otk::OBProperty::net_wm_desktop);
+    property->erase(_window, otk::OBProperty::net_wm_state);
+  }
 }
 
 
@@ -537,10 +539,11 @@ void OBClient::setWMState(long state)
 
 void OBClient::setDesktop(long target)
 {
-  assert(target >= 0);
+  printf("Setting desktop %ld\n", target);
+  assert(target >= 0 || target == (signed)0xffffffff);
   //assert(target == 0xffffffff || target < MAX);
-  
-  // XXX: move the window to the new desktop
+
+  // XXX: move the window to the new desktop (and set root property)
   _desktop = target;
 }
 
@@ -766,10 +769,16 @@ void OBClient::clientMessageHandler(const XClientMessageEvent &e)
       setDesktop(e.data.l[0]); // use the found event
     else
       setDesktop(e.data.l[0]); // use the original event
-  }
-  else if (e.message_type == property->atom(otk::OBProperty::net_wm_state))
+  } else if (e.message_type == property->atom(otk::OBProperty::net_wm_state)) {
     // can't compress these
     setState((StateAction)e.data.l[0], e.data.l[1], e.data.l[2]);
+  } else if (e.message_type ==
+             property->atom(otk::OBProperty::net_close_window)) {
+    close();
+  } else if (e.message_type ==
+             property->atom(otk::OBProperty::net_active_window)) {
+    focus();
+  }
 }
 
 
@@ -926,9 +935,28 @@ void OBClient::shade(bool shade)
 
 bool OBClient::focus()
 {
-  if (!_can_focus || _focused) return false;
+  if (!(_can_focus || _focus_notify) || _focused) return false;
+
+  if (_can_focus)
+    XSetInputFocus(otk::OBDisplay::display, _window, RevertToNone, CurrentTime);
+
+  if (_focus_notify) {
+    XEvent ce;
+    const otk::OBProperty *property = Openbox::instance->property();
+    
+    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_take_focus);
+    ce.xclient.data.l[1] = Openbox::instance->lastTime();
+    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);
+  }
 
-  XSetInputFocus(otk::OBDisplay::display, _window, RevertToNone, CurrentTime);
   return true;
 }
 
This page took 0.021262 seconds and 4 git commands to generate.