]> Dogcows Code - chaz/openbox/blobdiff - src/client.cc
make the frame window override-redirect
[chaz/openbox] / src / client.cc
index 3ac9002c8fe860d650b0d11cab98fc406f59e7a3..ddecfc62b7cd48e6d26cd6be04c6da962f09d443 100644 (file)
@@ -539,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;
 }
 
@@ -550,6 +551,7 @@ void OBClient::setDesktop(long target)
 void OBClient::setState(StateAction action, long data1, long data2)
 {
   const otk::OBProperty *property = Openbox::instance->property();
+  bool restack = false, shadestate = _shaded;
 
   if (!(action == State_Add || action == State_Remove ||
         action == State_Toggle))
@@ -605,8 +607,8 @@ void OBClient::setState(StateAction action, long data1, long data2)
       } else if (state ==
                  property->atom(otk::OBProperty::net_wm_state_shaded)) {
         if (_shaded) continue;
-        _shaded = true;
-        // XXX: hide the client window
+        // shade when we're all thru here
+        shadestate = true;
       } else if (state ==
                  property->atom(otk::OBProperty::net_wm_state_skip_taskbar)) {
         _skip_taskbar = true;
@@ -617,17 +619,17 @@ void OBClient::setState(StateAction action, long data1, long data2)
                  property->atom(otk::OBProperty::net_wm_state_fullscreen)) {
         if (_fullscreen) continue;
         _fullscreen = true;
-        // XXX: raise the window n shit
+        restack = false;
       } else if (state ==
                  property->atom(otk::OBProperty::net_wm_state_above)) {
         if (_above) continue;
         _above = true;
-        // XXX: raise the window n shit
+        restack = true;
       } else if (state ==
                  property->atom(otk::OBProperty::net_wm_state_below)) {
         if (_below) continue;
         _below = true;
-        // XXX: lower the window n shit
+        restack = true;
       }
 
     } else { // action == State_Remove
@@ -647,8 +649,8 @@ void OBClient::setState(StateAction action, long data1, long data2)
       } else if (state ==
                  property->atom(otk::OBProperty::net_wm_state_shaded)) {
         if (!_shaded) continue;
-        _shaded = false;
-        // XXX: show the client window
+        // unshade when we're all thru here
+        shadestate = false;
       } else if (state ==
                  property->atom(otk::OBProperty::net_wm_state_skip_taskbar)) {
         _skip_taskbar = false;
@@ -659,22 +661,26 @@ void OBClient::setState(StateAction action, long data1, long data2)
                  property->atom(otk::OBProperty::net_wm_state_fullscreen)) {
         if (!_fullscreen) continue;
         _fullscreen = false;
-        // XXX: lower the window to its proper layer
+        restack = true;
       } else if (state ==
                  property->atom(otk::OBProperty::net_wm_state_above)) {
         if (!_above) continue;
         _above = false;
-        // XXX: lower the window to its proper layer
+        restack = true;
       } else if (state ==
                  property->atom(otk::OBProperty::net_wm_state_below)) {
         if (!_below) continue;
         _below = false;
-        // XXX: raise the window to its proper layer
+        restack = true;
       }
     }
   }
-  calcLayer();
-  Openbox::instance->screen(_screen)->restack(true, this); // raise
+  if (shadestate != _shaded)
+    shade(shadestate);
+  if (restack) {
+    calcLayer();
+    Openbox::instance->screen(_screen)->restack(true, this); // raise
+  }
 }
 
 
@@ -768,10 +774,17 @@ 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();
+    Openbox::instance->screen(_screen)->restack(true, this); // raise
+  }
 }
 
 
@@ -928,9 +941,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.027793 seconds and 4 git commands to generate.