]> Dogcows Code - chaz/openbox/commitdiff
windows stay on their desktops
authorDana Jansens <danakj@orodu.net>
Tue, 7 Jan 2003 01:54:26 +0000 (01:54 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 7 Jan 2003 01:54:26 +0000 (01:54 +0000)
src/client.cc
src/openbox_wrap.cc
src/screen.cc
src/screen.hh

index 298e5f56a64f90b4296bebd070a26730f60d3c6f..c3ab3c63a8740f25f677c38aa7c977fae1195b9b 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);
+  }
 }
 
 
@@ -653,8 +659,17 @@ void OBClient::setDesktop(long 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);
+  
+  
+  // XXX: move the window to the new desktop
 }
 
 
index 428426b8f466de5ed1195816dd2755894bb87355..a9b7cf3c774c3294effc345e44c7cf83c6d25b62 100644 (file)
@@ -1517,12 +1517,29 @@ static PyObject *_wrap_OBScreen_focuswindow(PyObject *self, PyObject *args) {
 static PyObject *_wrap_OBScreen_desktop(PyObject *self, PyObject *args) {
     PyObject *resultobj;
     ob::OBScreen *arg1 = (ob::OBScreen *) 0 ;
-    unsigned long result;
+    long result;
     PyObject * obj0  = 0 ;
     
     if(!PyArg_ParseTuple(args,(char *)"O:OBScreen_desktop",&obj0)) goto fail;
     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBScreen,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
-    result = (unsigned long)((ob::OBScreen const *)arg1)->desktop();
+    result = (long)((ob::OBScreen const *)arg1)->desktop();
+    
+    resultobj = PyInt_FromLong((long)result);
+    return resultobj;
+    fail:
+    return NULL;
+}
+
+
+static PyObject *_wrap_OBScreen_numDesktops(PyObject *self, PyObject *args) {
+    PyObject *resultobj;
+    ob::OBScreen *arg1 = (ob::OBScreen *) 0 ;
+    long result;
+    PyObject * obj0  = 0 ;
+    
+    if(!PyArg_ParseTuple(args,(char *)"O:OBScreen_numDesktops",&obj0)) goto fail;
+    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBScreen,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
+    result = (long)((ob::OBScreen const *)arg1)->numDesktops();
     
     resultobj = PyInt_FromLong((long)result);
     return resultobj;
@@ -2901,6 +2918,7 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"OBScreen_style", _wrap_OBScreen_style, METH_VARARGS },
         { (char *)"OBScreen_focuswindow", _wrap_OBScreen_focuswindow, METH_VARARGS },
         { (char *)"OBScreen_desktop", _wrap_OBScreen_desktop, METH_VARARGS },
+        { (char *)"OBScreen_numDesktops", _wrap_OBScreen_numDesktops, METH_VARARGS },
         { (char *)"OBScreen_updateStrut", _wrap_OBScreen_updateStrut, METH_VARARGS },
         { (char *)"OBScreen_manageExisting", _wrap_OBScreen_manageExisting, METH_VARARGS },
         { (char *)"OBScreen_manageWindow", _wrap_OBScreen_manageWindow, METH_VARARGS },
index 896f38081d15756f85a55fdeef1d16ab52a84a2e..d925ff5c603803b360a0b9d0db55ac34e41fd165 100644 (file)
@@ -502,9 +502,14 @@ void OBScreen::manageWindow(Window window)
   Openbox::instance->addClient(client->frame->grip_left(), client);
   Openbox::instance->addClient(client->frame->grip_right(), client);
 
+  bool shown = false;
+  
   // if on the current desktop.. (or all desktops)
-  if (client->desktop() == _desktop || client->desktop() == (signed)0xffffffff)
+  if (client->desktop() == _desktop ||
+      client->desktop() == (signed)0xffffffff) {
+    shown = true;
     client->frame->show();
+  }
  
   // XXX: handle any requested states such as maximized
 
@@ -520,9 +525,11 @@ void OBScreen::manageWindow(Window window)
 
   Openbox::instance->bindings()->grabButtons(true, client);
 
-  // XXX: make this optional or more intelligent
-  if (client->normal())
-    client->focus();
+  if (shown) {
+    // XXX: make this optional or more intelligent
+    if (client->normal())
+      client->focus();
+  }
 
   // call the python NEWWINDOW binding
   EventData *data = new_event_data(window, EventNewWindow, 0);
@@ -552,7 +559,7 @@ void OBScreen::unmanageWindow(OBClient *client)
     OBClient *newfocus = 0;
     OBClient::List::iterator it, end = _stacking.end();
     for (it = _stacking.begin(); it != end; ++it)
-      if ((*it)->normal() && (*it)->focus()) {
+      if ((*it)->desktop() == _desktop && (*it)->normal() && (*it)->focus()) {
         newfocus = *it;
         break;
       }
@@ -631,6 +638,8 @@ void OBScreen::changeDesktop(long desktop)
 
   if (!(desktop >= 0 && desktop < _num_desktops)) return;
 
+  printf("Moving to desktop %ld\n", desktop);
+  
   long old = _desktop;
   
   _desktop = desktop;
@@ -655,6 +664,8 @@ void OBScreen::changeNumDesktops(long num)
   
   if (!(num > 0)) return;
 
+  // XXX: move windows on desktops that will no longer exist!
+  
   _num_desktops = num;
   Openbox::instance->property()->set(_info->rootWindow(),
                                      otk::OBProperty::net_number_of_desktops,
index aea9d2936511d410baadba3ac673fc809c8e5a3c..f27e41f1f4fced166a3ca12ea920302b1177835a 100644 (file)
@@ -141,7 +141,9 @@ public:
   //!  An offscreen window which gets focus when nothing else has it
   inline Window focuswindow() const { return _focuswindow; }
   //! Returns the desktop being displayed
-  inline unsigned long desktop() const { return _desktop; }
+  inline long desktop() const { return _desktop; }
+  //! Returns the number of desktops
+  inline long numDesktops() const { return _num_desktops; }
 
   //! Update's the screen's combined strut of all the clients.
   /*!
This page took 0.032922 seconds and 4 git commands to generate.