From 7175ac2b5aec7aface6a2f86df32dd0386e0cc05 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 7 Jan 2003 01:54:26 +0000 Subject: [PATCH] windows stay on their desktops --- src/client.cc | 23 +++++++++++++++++++---- src/openbox_wrap.cc | 22 ++++++++++++++++++++-- src/screen.cc | 21 ++++++++++++++++----- src/screen.hh | 4 +++- 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/src/client.cc b/src/client.cc index 298e5f56..c3ab3c63 100644 --- a/src/client.cc +++ b/src/client.cc @@ -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 } diff --git a/src/openbox_wrap.cc b/src/openbox_wrap.cc index 428426b8..a9b7cf3c 100644 --- a/src/openbox_wrap.cc +++ b/src/openbox_wrap.cc @@ -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 }, diff --git a/src/screen.cc b/src/screen.cc index 896f3808..d925ff5c 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -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, diff --git a/src/screen.hh b/src/screen.hh index aea9d293..f27e41f1 100644 --- a/src/screen.hh +++ b/src/screen.hh @@ -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. /*! -- 2.45.2