share code for raising/lowering windows

This commit is contained in:
Dana Jansens 2003-01-03 18:25:04 +00:00
parent 89e6d5c0e6
commit 13f2930de7
5 changed files with 19 additions and 63 deletions

View file

@ -68,10 +68,10 @@ def raise_win(data):
client = Openbox_findClient(openbox, data.window()) client = Openbox_findClient(openbox, data.window())
if not client: return if not client: return
screen = Openbox_screen(openbox, OBClient_screen(client)) screen = Openbox_screen(openbox, OBClient_screen(client))
OBScreen_raise(screen, client) OBScreen_restack(screen, 1, client)
def lower_win(data): def lower_win(data):
client = Openbox_findClient(openbox, data.window()) client = Openbox_findClient(openbox, data.window())
if not client: return if not client: return
screen = Openbox_screen(openbox, OBClient_screen(client)) screen = Openbox_screen(openbox, OBClient_screen(client))
OBScreen_lower(screen, client) OBScreen_restack(screen, 0, client)

View file

@ -649,7 +649,7 @@ void OBClient::setState(StateAction action, long data1, long data2)
} }
} }
calcLayer(); calcLayer();
Openbox::instance->screen(_screen)->raise(this); Openbox::instance->screen(_screen)->restack(true, this); // raise
} }

View file

@ -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; PyObject *resultobj;
ob::OBScreen *arg1 = (ob::OBScreen *) 0 ; ob::OBScreen *arg1 = (ob::OBScreen *) 0 ;
ob::OBClient *arg2 = (ob::OBClient *) 0 ; bool arg2 ;
ob::OBClient *arg3 = (ob::OBClient *) 0 ;
PyObject * obj0 = 0 ; PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ; PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"OO:OBScreen_raise",&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(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; arg2 = (bool) PyInt_AsLong(obj1);
(arg1)->raise(arg2); if (PyErr_Occurred()) SWIG_fail;
if ((SWIG_ConvertPtr(obj2,(void **) &arg3, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
Py_INCREF(Py_None); resultobj = Py_None; (arg1)->restack(arg2,arg3);
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 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"OO:OBScreen_lower",&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)->lower(arg2);
Py_INCREF(Py_None); resultobj = Py_None; Py_INCREF(Py_None); resultobj = Py_None;
return resultobj; return resultobj;
@ -2667,8 +2652,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"OBScreen_manageExisting", _wrap_OBScreen_manageExisting, METH_VARARGS }, { (char *)"OBScreen_manageExisting", _wrap_OBScreen_manageExisting, METH_VARARGS },
{ (char *)"OBScreen_manageWindow", _wrap_OBScreen_manageWindow, METH_VARARGS }, { (char *)"OBScreen_manageWindow", _wrap_OBScreen_manageWindow, METH_VARARGS },
{ (char *)"OBScreen_unmanageWindow", _wrap_OBScreen_unmanageWindow, METH_VARARGS }, { (char *)"OBScreen_unmanageWindow", _wrap_OBScreen_unmanageWindow, METH_VARARGS },
{ (char *)"OBScreen_raise", _wrap_OBScreen_raise, METH_VARARGS }, { (char *)"OBScreen_restack", _wrap_OBScreen_restack, METH_VARARGS },
{ (char *)"OBScreen_lower", _wrap_OBScreen_lower, METH_VARARGS },
{ (char *)"OBScreen_swigregister", OBScreen_swigregister, METH_VARARGS }, { (char *)"OBScreen_swigregister", OBScreen_swigregister, METH_VARARGS },
{ (char *)"MwmHints_flags_set", _wrap_MwmHints_flags_set, METH_VARARGS }, { (char *)"MwmHints_flags_set", _wrap_MwmHints_flags_set, METH_VARARGS },
{ (char *)"MwmHints_flags_get", _wrap_MwmHints_flags_get, METH_VARARGS }, { (char *)"MwmHints_flags_get", _wrap_MwmHints_flags_get, METH_VARARGS },

View file

@ -406,7 +406,7 @@ void OBScreen::manageWindow(Window window)
clients.push_back(client); clients.push_back(client);
// this puts into the stacking order, then raises it // this puts into the stacking order, then raises it
_stacking.push_back(client); _stacking.push_back(client);
raise(client); restack(true, client);
// update the root properties // update the root properties
setClientList(); setClientList();
@ -461,7 +461,7 @@ void OBScreen::unmanageWindow(OBClient *client)
setClientList(); setClientList();
} }
void OBScreen::raise(OBClient *client) void OBScreen::restack(bool raise, OBClient *client)
{ {
const int layer = client->layer(); const int layer = client->layer();
std::vector<Window> wins; std::vector<Window> wins;
@ -473,33 +473,7 @@ void OBScreen::raise(OBClient *client)
ClientList::iterator it = _stacking.begin(), end = _stacking.end(); ClientList::iterator it = _stacking.begin(), end = _stacking.end();
// insert the windows above this window // insert the windows above this window
for (; it != end; ++it) { for (; it != end; ++it) {
if ((*it)->layer() <= layer) if ((*it)->layer() < layer || (raise && (*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<Window> 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)
break; break;
wins.push_back((*it)->frame->window()); wins.push_back((*it)->frame->window());
} }

View file

@ -153,11 +153,9 @@ public:
*/ */
void unmanageWindow(OBClient *client); void unmanageWindow(OBClient *client);
//! Raises a client window above all others in its stacking layer //! Raises/Lowers a client window above/below all others in its stacking
void raise(OBClient *client); //! layer
void restack(bool raise, OBClient *client);
//! Lowers a client window below all others in its stacking layer
void lower(OBClient *client);
}; };
} }