better focus passing around for now

This commit is contained in:
Dana Jansens 2003-01-04 08:41:42 +00:00
parent ee1130f8ec
commit 056ff3b50c
5 changed files with 88 additions and 18 deletions

View file

@ -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()

View file

@ -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

View file

@ -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.<br>
@ -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.<br>
'0' - the normal layer<br>
'> 0' - the 'above' layer<br>
'< 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

View file

@ -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 },

View file

@ -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();
}