From 03fc8ed5ec1a6f70ee5fb205c4bf9d4f15cd9f01 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 11 Oct 2002 10:20:33 +0000 Subject: state shaded and sticky fixed --- src/Ewmh.cc | 47 +++++++++++++++++++++++++++++++++++++++++++---- src/Ewmh.hh | 5 +++-- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/Ewmh.cc b/src/Ewmh.cc index 0d5885b..f715ccc 100644 --- a/src/Ewmh.cc +++ b/src/Ewmh.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Ewmh.cc,v 1.1 2002/10/02 16:26:05 fluxgen Exp $ +// $Id: Ewmh.cc,v 1.2 2002/10/11 10:20:33 fluxgen Exp $ #include "Ewmh.hh" @@ -63,7 +63,8 @@ void Ewmh::initForScreen(const BScreen &screen) { //set supported atoms Atom atomsupported[] = { m_net_wm_state, - m_net_wm_state_sticky, + // states that we support: + m_net_wm_state_sticky, m_net_wm_state_shaded, m_net_client_list, @@ -186,7 +187,21 @@ void Ewmh::updateWorkspace(FluxboxWindow &win) { } bool Ewmh::checkClientMessage(const XClientMessageEvent &ce, BScreen *screen, FluxboxWindow *win) { - + if (win != 0) { + if (ce.message_type == m_net_wm_state) { + if (ce.data.l[0] == STATE_REMOVE) { + setState(*win, ce.data.l[1], false); + setState(*win, ce.data.l[2], false); + } else if (ce.data.l[0] == STATE_ADD) { + setState(*win, ce.data.l[1], true); + setState(*win, ce.data.l[2], true); + } else if (ce.data.l[0] == STATE_TOGGLE) { + toggleState(*win, ce.data.l[1]); + toggleState(*win, ce.data.l[2]); + } + } + } + return false; } @@ -212,7 +227,8 @@ void Ewmh::createAtoms() { m_net_wm_name = XInternAtom(disp, "_NET_WM_NAME", False); m_net_wm_desktop = XInternAtom(disp, "_NET_WM_DESKTOP", False); m_net_wm_window_type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False); - + + // state atom and the supported state atoms m_net_wm_state = XInternAtom(disp, "_NET_WM_STATE", False); m_net_wm_state_sticky = XInternAtom(disp, "_NET_WM_STATE_STICKY", False); m_net_wm_state_shaded = XInternAtom(disp, "_NET_WM_STATE_SHADED", False); @@ -226,3 +242,26 @@ void Ewmh::createAtoms() { m_net_wm_ping = XInternAtom(disp, "_NET_WM_PING", False); } +// set window state +void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) const { + + if (state == m_net_wm_state_sticky) { // STICKY + if (value && !win.isStuck() || + (!value && win.isStuck())) + win.stick(); + } else if (state == m_net_wm_state_shaded) { // SHADED + if ((value && !win.isShaded()) || + (!value && win.isShaded())) + win.shade(); + } + +} + +// toggle window state +void Ewmh::toggleState(FluxboxWindow &win, Atom state) const { + if (state == m_net_wm_state_sticky) { + win.stick(); + } else if (state == m_net_wm_state_shaded) + win.shade(); +} + diff --git a/src/Ewmh.hh b/src/Ewmh.hh index 2344045..672665a 100644 --- a/src/Ewmh.hh +++ b/src/Ewmh.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Ewmh.hh,v 1.1 2002/10/02 16:26:05 fluxgen Exp $ +// $Id: Ewmh.hh,v 1.2 2002/10/11 10:20:33 fluxgen Exp $ #include "AtomHandler.hh" @@ -50,7 +50,8 @@ private: enum { STATE_REMOVE = 0, STATE_ADD = 1, STATE_TOGGLE = 2}; - void setState(FluxboxWindow &win, Atom flags) const; + void setState(FluxboxWindow &win, Atom state, bool value) const; + void toggleState(FluxboxWindow &win, Atom state) const; void createAtoms(); // root window properties -- cgit v0.11.2