From 056ff3b50cddd39b6f45969c17611dc3bf396ae9 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 4 Jan 2003 08:41:42 +0000 Subject: [PATCH] better focus passing around for now --- scripts/builtins.py | 22 +++++++--------------- src/client.cc | 16 ++++++++++++++++ src/client.hh | 19 +++++++++++++++++++ src/openbox_wrap.cc | 36 ++++++++++++++++++++++++++++++++++++ src/screen.cc | 13 ++++++++++--- 5 files changed, 88 insertions(+), 18 deletions(-) diff --git a/scripts/builtins.py b/scripts/builtins.py index 3b91248c..45f73d56 100644 --- a/scripts/builtins.py +++ b/scripts/builtins.py @@ -12,11 +12,9 @@ def focus(data): client = Openbox_findClient(openbox, data.window()) if not client: return type = OBClient_type(client) - # these types of windows dont get focus from window enter events - if data.action() == EventEnterWindow: - if (type == OBClient_Type_Dock or \ - type == OBClient_Type_Desktop): - return + # !normal windows dont get focus from window enter events + if data.action() == EventEnterWindow and not OBClient_normal(client): + return OBClient_focus(client) def move(data): @@ -25,11 +23,8 @@ def move(data): client = Openbox_findClient(openbox, data.window()) if not client: return - type = OBClient_type(client) - # these types of windows dont get moved - if type == OBClient_Type_Dock or \ - type == OBClient_Type_Desktop: - return + # !normal windows dont get moved + if not OBClient_normal(client): return dx = data.xroot() - data.pressx() dy = data.yroot() - data.pressy() @@ -41,11 +36,8 @@ def resize(data): client = Openbox_findClient(openbox, data.window()) if not client: return - type = OBClient_type(client) - # these types of windows dont get resized - if type == OBClient_Type_Dock or \ - type == OBClient_Type_Desktop: - return + # !normal windows dont get moved + if not OBClient_normal(client): return px = data.pressx() py = data.pressy() diff --git a/src/client.cc b/src/client.cc index a2106d86..381305f7 100644 --- a/src/client.cc +++ b/src/client.cc @@ -966,6 +966,22 @@ 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 diff --git a/src/client.hh b/src/client.hh index f782a355..b64878ee 100644 --- a/src/client.hh +++ b/src/client.hh @@ -352,6 +352,16 @@ public: //! Returns the type of the window, one of the OBClient::WindowType values inline WindowType type() const { return _type; } + //! Returns if the window should be treated as a normal window. + /*! + Some windows (desktops, docks, splash screens) have special rules applied + to them in a number of places regarding focus or user interaction. + */ + inline bool normal() const { + return ! (_type == Type_Desktop || _type == Type_Dock || + _type == Type_Splash); + } + //! Returns the desktop on which the window resides /*! This value is a 0-based index.
@@ -458,6 +468,15 @@ public: //! Request the client to close its window. void close(); + //! Sets the window's stacking layer + /*! + @param l An integer specifying the layer.
+ '0' - the normal layer
+ '> 0' - the 'above' layer
+ '< 0' - the 'below' layer + */ + void setStackLayer(int l); + //! Shades or unshades the client window /*! @param shade true if the window should be shaded; false if it should be diff --git a/src/openbox_wrap.cc b/src/openbox_wrap.cc index c3d014d6..a60d48e0 100644 --- a/src/openbox_wrap.cc +++ b/src/openbox_wrap.cc @@ -1853,6 +1853,23 @@ static PyObject *_wrap_OBClient_type(PyObject *self, PyObject *args) { } +static PyObject *_wrap_OBClient_normal(PyObject *self, PyObject *args) { + PyObject *resultobj; + ob::OBClient *arg1 = (ob::OBClient *) 0 ; + bool result; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:OBClient_normal",&obj0)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; + result = (bool)((ob::OBClient const *)arg1)->normal(); + + resultobj = PyInt_FromLong((long)result); + return resultobj; + fail: + return NULL; +} + + static PyObject *_wrap_OBClient_desktop(PyObject *self, PyObject *args) { PyObject *resultobj; ob::OBClient *arg1 = (ob::OBClient *) 0 ; @@ -2311,6 +2328,23 @@ static PyObject *_wrap_OBClient_close(PyObject *self, PyObject *args) { } +static PyObject *_wrap_OBClient_setStackLayer(PyObject *self, PyObject *args) { + PyObject *resultobj; + ob::OBClient *arg1 = (ob::OBClient *) 0 ; + int arg2 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"Oi:OBClient_setStackLayer",&obj0,&arg2)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; + (arg1)->setStackLayer(arg2); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + static PyObject *_wrap_OBClient_shade(PyObject *self, PyObject *args) { PyObject *resultobj; ob::OBClient *arg1 = (ob::OBClient *) 0 ; @@ -2701,6 +2735,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"OBClient_screen", _wrap_OBClient_screen, METH_VARARGS }, { (char *)"OBClient_window", _wrap_OBClient_window, METH_VARARGS }, { (char *)"OBClient_type", _wrap_OBClient_type, METH_VARARGS }, + { (char *)"OBClient_normal", _wrap_OBClient_normal, METH_VARARGS }, { (char *)"OBClient_desktop", _wrap_OBClient_desktop, METH_VARARGS }, { (char *)"OBClient_title", _wrap_OBClient_title, METH_VARARGS }, { (char *)"OBClient_iconTitle", _wrap_OBClient_iconTitle, METH_VARARGS }, @@ -2726,6 +2761,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"OBClient_move", _wrap_OBClient_move, METH_VARARGS }, { (char *)"OBClient_resize", _wrap_OBClient_resize, METH_VARARGS }, { (char *)"OBClient_close", _wrap_OBClient_close, METH_VARARGS }, + { (char *)"OBClient_setStackLayer", _wrap_OBClient_setStackLayer, METH_VARARGS }, { (char *)"OBClient_shade", _wrap_OBClient_shade, METH_VARARGS }, { (char *)"OBClient_focus", _wrap_OBClient_focus, METH_VARARGS }, { (char *)"OBClient_unfocus", _wrap_OBClient_unfocus, METH_VARARGS }, diff --git a/src/screen.cc b/src/screen.cc index bebc82d1..d9067aa0 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -518,6 +518,9 @@ void OBScreen::manageWindow(Window window) setClientList(); Openbox::instance->bindings()->grabButtons(true, client); + + // XXX: make this optional or more intelligent + client->focus(); } @@ -533,9 +536,13 @@ void OBScreen::unmanageWindow(OBClient *client) // pass around focus if this window was focused XXX do this better! if (Openbox::instance->focusedClient() == client) { OBClient *newfocus = 0; - if (!_stacking.empty()) - newfocus = _stacking.front(); - if (! (newfocus && newfocus->focus())) + ClientList::iterator it, end = _stacking.end(); + for (it = _stacking.begin(); it != end; ++it) + if ((*it)->normal() && (*it)->focus()) { + newfocus = *it; + break; + } + if (!newfocus) client->unfocus(); } -- 2.39.2