From: Dana Jansens Date: Fri, 3 Jan 2003 18:25:04 +0000 (+0000) Subject: share code for raising/lowering windows X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=13f2930de727539fce8bd759450706b6094d5a98;p=chaz%2Fopenbox share code for raising/lowering windows --- diff --git a/scripts/builtins.py b/scripts/builtins.py index 8c042117..29079126 100644 --- a/scripts/builtins.py +++ b/scripts/builtins.py @@ -68,10 +68,10 @@ def raise_win(data): client = Openbox_findClient(openbox, data.window()) if not client: return screen = Openbox_screen(openbox, OBClient_screen(client)) - OBScreen_raise(screen, client) + OBScreen_restack(screen, 1, client) def lower_win(data): client = Openbox_findClient(openbox, data.window()) if not client: return screen = Openbox_screen(openbox, OBClient_screen(client)) - OBScreen_lower(screen, client) + OBScreen_restack(screen, 0, client) diff --git a/src/client.cc b/src/client.cc index f648c2c8..2dec3855 100644 --- a/src/client.cc +++ b/src/client.cc @@ -649,7 +649,7 @@ void OBClient::setState(StateAction action, long data1, long data2) } } calcLayer(); - Openbox::instance->screen(_screen)->raise(this); + Openbox::instance->screen(_screen)->restack(true, this); // raise } diff --git a/src/openbox_wrap.cc b/src/openbox_wrap.cc index ffe61d6a..8ed3bc44 100644 --- a/src/openbox_wrap.cc +++ b/src/openbox_wrap.cc @@ -1560,36 +1560,21 @@ static PyObject *_wrap_OBScreen_unmanageWindow(PyObject *self, PyObject *args) { } -static PyObject *_wrap_OBScreen_raise(PyObject *self, PyObject *args) { +static PyObject *_wrap_OBScreen_restack(PyObject *self, PyObject *args) { PyObject *resultobj; ob::OBScreen *arg1 = (ob::OBScreen *) 0 ; - ob::OBClient *arg2 = (ob::OBClient *) 0 ; - PyObject * obj0 = 0 ; - PyObject * obj1 = 0 ; - - if(!PyArg_ParseTuple(args,(char *)"OO:OBScreen_raise",&obj0,&obj1)) goto fail; - if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBScreen,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; - if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; - (arg1)->raise(arg2); - - Py_INCREF(Py_None); resultobj = Py_None; - return resultobj; - fail: - return NULL; -} - - -static PyObject *_wrap_OBScreen_lower(PyObject *self, PyObject *args) { - PyObject *resultobj; - ob::OBScreen *arg1 = (ob::OBScreen *) 0 ; - ob::OBClient *arg2 = (ob::OBClient *) 0 ; + bool arg2 ; + ob::OBClient *arg3 = (ob::OBClient *) 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; - if(!PyArg_ParseTuple(args,(char *)"OO:OBScreen_lower",&obj0,&obj1)) goto fail; + if(!PyArg_ParseTuple(args,(char *)"OOO:OBScreen_restack",&obj0,&obj1,&obj2)) goto fail; if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBScreen,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; - if ((SWIG_ConvertPtr(obj1,(void **) &arg2, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; - (arg1)->lower(arg2); + arg2 = (bool) PyInt_AsLong(obj1); + if (PyErr_Occurred()) SWIG_fail; + if ((SWIG_ConvertPtr(obj2,(void **) &arg3, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; + (arg1)->restack(arg2,arg3); Py_INCREF(Py_None); resultobj = Py_None; return resultobj; @@ -2667,8 +2652,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"OBScreen_manageExisting", _wrap_OBScreen_manageExisting, METH_VARARGS }, { (char *)"OBScreen_manageWindow", _wrap_OBScreen_manageWindow, METH_VARARGS }, { (char *)"OBScreen_unmanageWindow", _wrap_OBScreen_unmanageWindow, METH_VARARGS }, - { (char *)"OBScreen_raise", _wrap_OBScreen_raise, METH_VARARGS }, - { (char *)"OBScreen_lower", _wrap_OBScreen_lower, METH_VARARGS }, + { (char *)"OBScreen_restack", _wrap_OBScreen_restack, METH_VARARGS }, { (char *)"OBScreen_swigregister", OBScreen_swigregister, METH_VARARGS }, { (char *)"MwmHints_flags_set", _wrap_MwmHints_flags_set, METH_VARARGS }, { (char *)"MwmHints_flags_get", _wrap_MwmHints_flags_get, METH_VARARGS }, diff --git a/src/screen.cc b/src/screen.cc index f510749c..f0b0eb3d 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -406,7 +406,7 @@ void OBScreen::manageWindow(Window window) clients.push_back(client); // this puts into the stacking order, then raises it _stacking.push_back(client); - raise(client); + restack(true, client); // update the root properties setClientList(); @@ -461,7 +461,7 @@ void OBScreen::unmanageWindow(OBClient *client) setClientList(); } -void OBScreen::raise(OBClient *client) +void OBScreen::restack(bool raise, OBClient *client) { const int layer = client->layer(); std::vector wins; @@ -473,33 +473,7 @@ void OBScreen::raise(OBClient *client) ClientList::iterator it = _stacking.begin(), end = _stacking.end(); // insert the windows above this window for (; it != end; ++it) { - if ((*it)->layer() <= layer) - break; - wins.push_back((*it)->frame->window()); - } - // insert our client - wins.push_back(client->frame->window()); - _stacking.insert(it, client); - // insert the remaining below this window - for (; it != end; ++it) - wins.push_back((*it)->frame->window()); - - XRestackWindows(otk::OBDisplay::display, &wins[0], wins.size()); -} - -void OBScreen::lower(OBClient *client) -{ - const int layer = client->layer(); - std::vector wins; - - _stacking.remove(client); - - // the stacking list is from highest to lowest - - ClientList::iterator it = _stacking.begin(), end = _stacking.end(); - // insert the windows above this window - for (; it != end; ++it) { - if ((*it)->layer() < layer) + if ((*it)->layer() < layer || (raise && (*it)->layer() == layer)) break; wins.push_back((*it)->frame->window()); } diff --git a/src/screen.hh b/src/screen.hh index ce6d6dea..5af79366 100644 --- a/src/screen.hh +++ b/src/screen.hh @@ -153,11 +153,9 @@ public: */ void unmanageWindow(OBClient *client); - //! Raises a client window above all others in its stacking layer - void raise(OBClient *client); - - //! Lowers a client window below all others in its stacking layer - void lower(OBClient *client); + //! Raises/Lowers a client window above/below all others in its stacking + //! layer + void restack(bool raise, OBClient *client); }; }