window shading

This commit is contained in:
Dana Jansens 2003-01-03 23:51:06 +00:00
parent e6ae9e51f7
commit 7417e2b54e
5 changed files with 134 additions and 4 deletions

View file

@ -79,4 +79,20 @@ def lower_win(data):
screen = Openbox_screen(openbox, OBClient_screen(client))
OBScreen_restack(screen, 0, client)
def toggle_shade(data):
client = Openbox_findClient(openbox, data.window())
if not client: return
print "toggle_shade"
OBClient_shade(client, not OBClient_shaded(client))
def shade(data):
client = Openbox_findClient(openbox, data.window())
if not client: return
OBClient_shade(client, 1)
def unshade(data):
client = Openbox_findClient(openbox, data.window())
if not client: return
OBClient_shade(client, 0)
print "Loaded builtins.py"

View file

@ -249,7 +249,7 @@ void OBClient::getState()
const otk::OBProperty *property = Openbox::instance->property();
_modal = _shaded = _max_horz = _max_vert = _fullscreen = _above = _below =
false;
_skip_taskbar = _skip_pager = false;
unsigned long *state;
unsigned long num = (unsigned) -1;
@ -262,6 +262,12 @@ void OBClient::getState()
else if (state[i] ==
property->atom(otk::OBProperty::net_wm_state_shaded))
_shaded = true;
else if (state[i] ==
property->atom(otk::OBProperty::net_wm_state_skip_taskbar))
_skip_taskbar = true;
else if (state[i] ==
property->atom(otk::OBProperty::net_wm_state_skip_pager))
_skip_pager = true;
else if (state[i] ==
property->atom(otk::OBProperty::net_wm_state_fullscreen))
_fullscreen = true;
@ -564,6 +570,12 @@ void OBClient::setState(StateAction action, long data1, long data2)
action = _max_horz ? State_Remove : State_Add;
else if (state == property->atom(otk::OBProperty::net_wm_state_shaded))
action = _shaded ? State_Remove : State_Add;
else if (state ==
property->atom(otk::OBProperty::net_wm_state_skip_taskbar))
action = _skip_taskbar ? State_Remove : State_Add;
else if (state ==
property->atom(otk::OBProperty::net_wm_state_skip_pager))
action = _skip_pager ? State_Remove : State_Add;
else if (state ==
property->atom(otk::OBProperty::net_wm_state_fullscreen))
action = _fullscreen ? State_Remove : State_Add;
@ -593,6 +605,12 @@ void OBClient::setState(StateAction action, long data1, long data2)
if (_shaded) continue;
_shaded = true;
// XXX: hide the client window
} else if (state ==
property->atom(otk::OBProperty::net_wm_state_skip_taskbar)) {
_skip_taskbar = true;
} else if (state ==
property->atom(otk::OBProperty::net_wm_state_skip_pager)) {
_skip_pager = true;
} else if (state ==
property->atom(otk::OBProperty::net_wm_state_fullscreen)) {
if (_fullscreen) continue;
@ -629,6 +647,12 @@ void OBClient::setState(StateAction action, long data1, long data2)
if (!_shaded) continue;
_shaded = false;
// XXX: show the client window
} else if (state ==
property->atom(otk::OBProperty::net_wm_state_skip_taskbar)) {
_skip_taskbar = false;
} else if (state ==
property->atom(otk::OBProperty::net_wm_state_skip_pager)) {
_skip_pager = false;
} else if (state ==
property->atom(otk::OBProperty::net_wm_state_fullscreen)) {
if (!_fullscreen) continue;
@ -849,6 +873,57 @@ void OBClient::close()
}
void OBClient::changeState()
{
const otk::OBProperty *property = Openbox::instance->property();
unsigned long state[2];
state[0] = _wmstate;
state[1] = None;
property->set(_window, otk::OBProperty::wm_state, otk::OBProperty::wm_state,
state, 2);
Atom netstate[10];
int num = 0;
if (_modal)
netstate[num++] = property->atom(otk::OBProperty::net_wm_state_modal);
if (_shaded)
netstate[num++] = property->atom(otk::OBProperty::net_wm_state_shaded);
if (_iconic)
netstate[num++] = property->atom(otk::OBProperty::net_wm_state_hidden);
if (_skip_taskbar)
netstate[num++] =
property->atom(otk::OBProperty::net_wm_state_skip_taskbar);
if (_skip_pager)
netstate[num++] = property->atom(otk::OBProperty::net_wm_state_skip_pager);
if (_fullscreen)
netstate[num++] = property->atom(otk::OBProperty::net_wm_state_fullscreen);
if (_max_vert)
netstate[num++] =
property->atom(otk::OBProperty::net_wm_state_maximized_vert);
if (_max_horz)
netstate[num++] =
property->atom(otk::OBProperty::net_wm_state_maximized_horz);
if (_above)
netstate[num++] = property->atom(otk::OBProperty::net_wm_state_above);
if (_below)
netstate[num++] = property->atom(otk::OBProperty::net_wm_state_below);
property->set(_window, otk::OBProperty::net_wm_state,
otk::OBProperty::Atom_Atom, netstate, num);
}
void OBClient::shade(bool shade)
{
if (shade == _shaded) return; // already done
_wmstate = shade ? IconicState : NormalState;
_shaded = shade;
changeState();
frame->adjustSize();
}
bool OBClient::focus()
{
if (!_can_focus || _focused) return false;

View file

@ -252,6 +252,10 @@ private:
bool _max_vert;
//! The window is maximized to fill the screen horizontally
bool _max_horz;
//! The window should not be displayed by pagers
bool _skip_pager;
//! The window should not be displayed by taskbars
bool _skip_taskbar;
//! The window is a 'fullscreen' window, and should be on top of all others
bool _fullscreen;
//! The window should be on top of other windows of the same type
@ -316,6 +320,9 @@ private:
void updateClass();
// XXX: updateTransientFor();
//! Change the client's state hints to match the class' data
void changeState();
public:
#ifndef SWIG
//! Constructs a new OBClient object around a specified window id
@ -433,12 +440,19 @@ public:
//! Request the client to close its window.
void close();
//! Shades or unshades the client window
/*!
@param shade true if the window should be shaded; false if it should be
unshaded.
*/
void shade(bool shade);
//! 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);
virtual void propertyHandler(const XPropertyEvent &e);

View file

@ -296,8 +296,12 @@ void OBFrame::adjustSize()
// position/size all the windows
resize(_innersize.left + _innersize.right + _client->area().width(),
_innersize.top + _innersize.bottom + _client->area().height());
if (_client->shaded())
resize(_innersize.left + _innersize.right + _client->area().width(),
_titlebar.height());
else
resize(_innersize.left + _innersize.right + _client->area().width(),
_innersize.top + _innersize.bottom + _client->area().height());
_plate.setGeometry(_innersize.left - cbwidth, _innersize.top - cbwidth,
_client->area().width(), _client->area().height());

View file

@ -2312,6 +2312,26 @@ static PyObject *_wrap_OBClient_close(PyObject *self, PyObject *args) {
}
static PyObject *_wrap_OBClient_shade(PyObject *self, PyObject *args) {
PyObject *resultobj;
ob::OBClient *arg1 = (ob::OBClient *) 0 ;
bool arg2 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"OO:OBClient_shade",&obj0,&obj1)) goto fail;
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__OBClient,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
arg2 = (bool) PyInt_AsLong(obj1);
if (PyErr_Occurred()) SWIG_fail;
(arg1)->shade(arg2);
Py_INCREF(Py_None); resultobj = Py_None;
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap_OBClient_focus(PyObject *self, PyObject *args) {
PyObject *resultobj;
ob::OBClient *arg1 = (ob::OBClient *) 0 ;
@ -2729,6 +2749,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_shade", _wrap_OBClient_shade, 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 },