all repos — openbox @ 0a9130b6c76bafb553e954feafa197897e6ecbdd

openbox fork - make it a bit more like ryudo

now we know the state of windows
Dana Jansens danakj@orodu.net
commit

0a9130b6c76bafb553e954feafa197897e6ecbdd

parent

cf3d512a998151bd585906c7478b576d5d3877ff

3 files changed, 45 insertions(+), 4 deletions(-)

jump to
M util/epist/process.ccutil/epist/process.cc

@@ -41,10 +41,22 @@

void processEvent(const XEvent &e) { switch (e.type) { case PropertyNotify: - if (e.xproperty.atom == _xatom->getAtom(XAtom::net_active_window)) - updateActiveWindow(); - if (e.xproperty.atom == _xatom->getAtom(XAtom::net_client_list)) - updateClientList(); + if (e.xany.window == _root) { + // root window + if (e.xproperty.atom == _xatom->getAtom(XAtom::net_active_window)) + updateActiveWindow(); + if (e.xproperty.atom == _xatom->getAtom(XAtom::net_client_list)) + updateClientList(); + } else { + // a client window + WindowList::iterator it, end = _clients.end(); + for (it = _clients.begin(); it != end; ++it) + if (*it == e.xproperty.window) + break; + assert(it != end); // this means a client somehow got removed from the + // list! + it->updateState(); + } break; } }
M util/epist/window.ccutil/epist/window.cc

@@ -25,13 +25,40 @@ # include "../../config.h"

#endif // HAVE_CONFIG_H #include "window.hh" +#include "epist.hh" +#include "../../src/XAtom.hh" XWindow::XWindow(Window window) : _window(window) { + XSelectInput(_display, _window, PropertyChangeMask); + updateState(); } XWindow::~XWindow() { + XSelectInput(_display, _window, None); } +void XWindow::updateState() { + // set the defaults + _shaded = _iconic = _max_vert = _max_horz = false; + + unsigned long num = (unsigned) -1; + Atom *state; + if (! _xatom->getValue(_window, XAtom::net_wm_state, XAtom::atom, + num, &state)) + return; + for (unsigned long i = 0; i < num; ++i) { + if (state[i] == _xatom->getAtom(XAtom::net_wm_state_maximized_vert)) + _max_vert = true; + if (state[i] == _xatom->getAtom(XAtom::net_wm_state_maximized_horz)) + _max_horz = true; + if (state[i] == _xatom->getAtom(XAtom::net_wm_state_shaded)) + _shaded = true; + if (state[i] == _xatom->getAtom(XAtom::net_wm_state_hidden)) + _iconic = true; + } + + delete [] state; +}
M util/epist/window.hhutil/epist/window.hh

@@ -53,6 +53,8 @@ inline bool iconic() const { return _iconic; }

inline bool maxVert() const { return _max_vert; } inline bool maxHorz() const { return _max_horz; } + void updateState(); + bool operator == (const XWindow &w) const { return w._window == _window; } bool operator == (const Window &w) const { return w == _window; } };