From 8c0fe026fe45d5cccfb0175f698d088d3eb9bc13 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 26 Dec 2002 18:15:23 +0000 Subject: [PATCH] focus works --- scripts/clicks.py | 1 + src/client.cc | 16 +++++++++++----- src/client.hh | 3 +++ src/openbox_wrap.cc | 19 ++++++++++++++++++- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/scripts/clicks.py b/scripts/clicks.py index 39effd53..217fa289 100644 --- a/scripts/clicks.py +++ b/scripts/clicks.py @@ -33,6 +33,7 @@ def def_click_root(action, win, type, modifiers, button, time): if type == Type_Root: if button == Button1: print "nothing probly.." + OBClient_unfocus(Openbox_focusedClient(openbox)) elif button == Button2: print "workspace menu" elif button == Button3: diff --git a/src/client.cc b/src/client.cc index 2f966cee..74783eed 100644 --- a/src/client.cc +++ b/src/client.cc @@ -866,13 +866,22 @@ void OBClient::close() bool OBClient::focus() { - if (!_can_focus) return false; + if (!_can_focus || _focused) return false; XSetInputFocus(otk::OBDisplay::display, _window, RevertToNone, CurrentTime); return true; } +void OBClient::unfocus() +{ + if (!_focused) return; + + assert(Openbox::instance->focusedClient() == this); + Openbox::instance->setFocusedClient(0); +} + + void OBClient::focusHandler(const XFocusChangeEvent &) { frame->focus(); @@ -887,11 +896,8 @@ void OBClient::unfocusHandler(const XFocusChangeEvent &) frame->unfocus(); _focused = false; - if (Openbox::instance->focusedClient() == this) { - printf("UNFOCUSING\n"); + if (Openbox::instance->focusedClient() == this) Openbox::instance->setFocusedClient(0); - } else - printf("UNFOCUSED ALREADY COULDNT UNFOCUS\n"); } diff --git a/src/client.hh b/src/client.hh index 61f7b071..8f0dc4f1 100644 --- a/src/client.hh +++ b/src/client.hh @@ -436,6 +436,9 @@ public: //! Attempt to focus the client window bool focus(); + + //! Remove focus from the client window + void unfocus(); virtual void focusHandler(const XFocusChangeEvent &e); virtual void unfocusHandler(const XFocusChangeEvent &e); diff --git a/src/openbox_wrap.cc b/src/openbox_wrap.cc index 12cd7e20..5cf5d8ea 100644 --- a/src/openbox_wrap.cc +++ b/src/openbox_wrap.cc @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.17u-20021222-0248 + * Version 1.3.17u-20021226-0459 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -2260,6 +2260,22 @@ static PyObject *_wrap_OBClient_focus(PyObject *self, PyObject *args) { } +static PyObject *_wrap_OBClient_unfocus(PyObject *self, PyObject *args) { + PyObject *resultobj; + ob::OBClient *arg1 = (ob::OBClient *) 0 ; + PyObject * obj0 = 0 ; + + if(!PyArg_ParseTuple(args,(char *)"O:OBClient_unfocus",&obj0)) goto fail; + if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail; + (arg1)->unfocus(); + + Py_INCREF(Py_None); resultobj = Py_None; + return resultobj; + fail: + return NULL; +} + + static PyObject *_wrap_OBClient_focusHandler(PyObject *self, PyObject *args) { PyObject *resultobj; ob::OBClient *arg1 = (ob::OBClient *) 0 ; @@ -2580,6 +2596,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"OBClient_resize", _wrap_OBClient_resize, METH_VARARGS }, { (char *)"OBClient_close", _wrap_OBClient_close, METH_VARARGS }, { (char *)"OBClient_focus", _wrap_OBClient_focus, METH_VARARGS }, + { (char *)"OBClient_unfocus", _wrap_OBClient_unfocus, METH_VARARGS }, { (char *)"OBClient_focusHandler", _wrap_OBClient_focusHandler, METH_VARARGS }, { (char *)"OBClient_unfocusHandler", _wrap_OBClient_unfocusHandler, METH_VARARGS }, { (char *)"OBClient_propertyHandler", _wrap_OBClient_propertyHandler, METH_VARARGS }, -- 2.45.2