From 0a9130b6c76bafb553e954feafa197897e6ecbdd Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 12 Jul 2002 00:40:05 +0000 Subject: [PATCH] now we know the state of windows --- util/epist/process.cc | 20 ++++++++++++++++---- util/epist/window.cc | 27 +++++++++++++++++++++++++++ util/epist/window.hh | 2 ++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/util/epist/process.cc b/util/epist/process.cc index dab1f16d..95588963 100644 --- a/util/epist/process.cc +++ b/util/epist/process.cc @@ -41,10 +41,22 @@ WindowList::iterator _active = _clients.end(); 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; } } diff --git a/util/epist/window.cc b/util/epist/window.cc index ebe458d4..a366fc49 100644 --- a/util/epist/window.cc +++ b/util/epist/window.cc @@ -25,13 +25,40 @@ #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; +} diff --git a/util/epist/window.hh b/util/epist/window.hh index 01cb2a80..140d63bc 100644 --- a/util/epist/window.hh +++ b/util/epist/window.hh @@ -53,6 +53,8 @@ public: 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; } }; -- 2.45.2