focus works

This commit is contained in:
Dana Jansens 2002-12-26 18:15:23 +00:00
parent 236f68056d
commit 8c0fe026fe
4 changed files with 33 additions and 6 deletions

View file

@ -33,6 +33,7 @@ def def_click_root(action, win, type, modifiers, button, time):
if type == Type_Root: if type == Type_Root:
if button == Button1: if button == Button1:
print "nothing probly.." print "nothing probly.."
OBClient_unfocus(Openbox_focusedClient(openbox))
elif button == Button2: elif button == Button2:
print "workspace menu" print "workspace menu"
elif button == Button3: elif button == Button3:

View file

@ -866,13 +866,22 @@ void OBClient::close()
bool OBClient::focus() bool OBClient::focus()
{ {
if (!_can_focus) return false; if (!_can_focus || _focused) return false;
XSetInputFocus(otk::OBDisplay::display, _window, RevertToNone, CurrentTime); XSetInputFocus(otk::OBDisplay::display, _window, RevertToNone, CurrentTime);
return true; return true;
} }
void OBClient::unfocus()
{
if (!_focused) return;
assert(Openbox::instance->focusedClient() == this);
Openbox::instance->setFocusedClient(0);
}
void OBClient::focusHandler(const XFocusChangeEvent &) void OBClient::focusHandler(const XFocusChangeEvent &)
{ {
frame->focus(); frame->focus();
@ -887,11 +896,8 @@ void OBClient::unfocusHandler(const XFocusChangeEvent &)
frame->unfocus(); frame->unfocus();
_focused = false; _focused = false;
if (Openbox::instance->focusedClient() == this) { if (Openbox::instance->focusedClient() == this)
printf("UNFOCUSING\n");
Openbox::instance->setFocusedClient(0); Openbox::instance->setFocusedClient(0);
} else
printf("UNFOCUSED ALREADY COULDNT UNFOCUS\n");
} }

View file

@ -436,6 +436,9 @@ public:
//! Attempt to focus the client window //! Attempt to focus the client window
bool focus(); bool focus();
//! Remove focus from the client window
void unfocus();
virtual void focusHandler(const XFocusChangeEvent &e); virtual void focusHandler(const XFocusChangeEvent &e);
virtual void unfocusHandler(const XFocusChangeEvent &e); virtual void unfocusHandler(const XFocusChangeEvent &e);

View file

@ -1,6 +1,6 @@
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org). * 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 * 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 * 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) { static PyObject *_wrap_OBClient_focusHandler(PyObject *self, PyObject *args) {
PyObject *resultobj; PyObject *resultobj;
ob::OBClient *arg1 = (ob::OBClient *) 0 ; ob::OBClient *arg1 = (ob::OBClient *) 0 ;
@ -2580,6 +2596,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"OBClient_resize", _wrap_OBClient_resize, METH_VARARGS }, { (char *)"OBClient_resize", _wrap_OBClient_resize, METH_VARARGS },
{ (char *)"OBClient_close", _wrap_OBClient_close, METH_VARARGS }, { (char *)"OBClient_close", _wrap_OBClient_close, METH_VARARGS },
{ (char *)"OBClient_focus", _wrap_OBClient_focus, 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_focusHandler", _wrap_OBClient_focusHandler, METH_VARARGS },
{ (char *)"OBClient_unfocusHandler", _wrap_OBClient_unfocusHandler, METH_VARARGS }, { (char *)"OBClient_unfocusHandler", _wrap_OBClient_unfocusHandler, METH_VARARGS },
{ (char *)"OBClient_propertyHandler", _wrap_OBClient_propertyHandler, METH_VARARGS }, { (char *)"OBClient_propertyHandler", _wrap_OBClient_propertyHandler, METH_VARARGS },