]> Dogcows Code - chaz/openbox/blobdiff - src/client.cc
fixed condition that could cause 2 windows to look focused, and bad things to occur
[chaz/openbox] / src / client.cc
index 298e5f56a64f90b4296bebd070a26730f60d3c6f..72a98afbf7338f4602494380ac214abbb525683e 100644 (file)
@@ -91,9 +91,15 @@ void OBClient::getDesktop()
   // defaults to the current desktop
   _desktop = Openbox::instance->screen(_screen)->desktop();
 
-  property->get(_window, otk::OBProperty::net_wm_desktop,
-                otk::OBProperty::Atom_Cardinal,
-                (long unsigned*)&_desktop);
+  if (!property->get(_window, otk::OBProperty::net_wm_desktop,
+                     otk::OBProperty::Atom_Cardinal,
+                     (long unsigned*)&_desktop)) {
+    // make sure the hint exists
+    Openbox::instance->property()->set(_window,
+                                       otk::OBProperty::net_wm_desktop,
+                                       otk::OBProperty::Atom_Cardinal,
+                                       (unsigned)_desktop);
+  }
 }
 
 
@@ -649,12 +655,25 @@ void OBClient::setWMState(long state)
 
 void OBClient::setDesktop(long target)
 {
+  if (target == _desktop) return;
+  
   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 (and set root property)
+  if (!(target >= 0 || target == (signed)0xffffffff)) return;
+  
   _desktop = target;
+
+  Openbox::instance->property()->set(_window,
+                                     otk::OBProperty::net_wm_desktop,
+                                     otk::OBProperty::Atom_Cardinal,
+                                     (unsigned)_desktop);
+  
+  // 'move' the window to the new desktop
+  if (_desktop == Openbox::instance->screen(_screen)->desktop() ||
+      _desktop == (signed)0xffffffff)
+    frame->show();
+  else
+    frame->hide();
 }
 
 
@@ -1049,21 +1068,6 @@ void OBClient::changeState()
 }
 
 
-void OBClient::setStackLayer(int l)
-{
-  if (l == 0)
-    _above = _below = false;  // normal
-  else if (l > 0) {
-    _above = true;
-    _below = false; // above
-  } else {
-    _above = false;
-    _below = true;  // below
-  }
-  changeState();
-}
-
-
 void OBClient::shade(bool shade)
 {
   if (shade == _shaded) return; // already done
@@ -1077,10 +1081,12 @@ void OBClient::shade(bool shade)
 
 bool OBClient::focus()
 {
-  if (!(_can_focus || _focus_notify) || _focused) return false;
+  if (!(_can_focus || _focus_notify)) return false;
+  if (_focused) return true;
 
   if (_can_focus)
-    XSetInputFocus(otk::OBDisplay::display, _window, RevertToNone, CurrentTime);
+    XSetInputFocus(otk::OBDisplay::display, _window,
+                   RevertToNone, CurrentTime);
 
   if (_focus_notify) {
     XEvent ce;
This page took 0.025231 seconds and 4 git commands to generate.