now we know the state of windows

This commit is contained in:
Dana Jansens 2002-07-12 00:40:05 +00:00
parent cf3d512a99
commit 0a9130b6c7
3 changed files with 45 additions and 4 deletions

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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; }
};