summaryrefslogtreecommitdiff
path: root/app/cwm
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2013-05-21 00:29:21 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2013-05-21 00:29:21 +0000
commit9e635b3f4067cb2f7c6bd1378dcbb6f326050220 (patch)
treecc01e85b128d1e51420c1bce960f82eaa123d195 /app/cwm
parent3da9d21ee7f0ed816a8ac3ff59f4eeca7afbc209 (diff)
handle _NET_WM_STATE ClientMessage; from Alexander Polakov.
Diffstat (limited to 'app/cwm')
-rw-r--r--app/cwm/calmwm.h9
-rw-r--r--app/cwm/xevents.c6
-rw-r--r--app/cwm/xutil.c39
3 files changed, 51 insertions, 3 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index e7f6d0ef0..a80fde3ee 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/calmwm.h
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: calmwm.h,v 1.207 2013/05/20 21:13:58 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.208 2013/05/21 00:29:20 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -482,6 +482,8 @@ void xu_ewmh_net_desktop_names(struct screen_ctx *, char *,
void xu_ewmh_net_wm_desktop(struct client_ctx *);
Atom *xu_ewmh_get_net_wm_state(struct client_ctx *, int *);
+void xu_ewmh_handle_net_wm_state_msg(struct client_ctx *,
+ int, Atom , Atom);
void xu_ewmh_set_net_wm_state(struct client_ctx *);
void xu_ewmh_restore_net_wm_state(struct client_ctx *);
@@ -543,6 +545,11 @@ enum {
_NET_WM_STATE_MAXIMIZED_HORZ,
EWMH_NITEMS
};
+enum {
+ _NET_WM_STATE_REMOVE,
+ _NET_WM_STATE_ADD,
+ _NET_WM_STATE_TOGGLE
+};
struct atom_ctx {
char *name;
Atom atom;
diff --git a/app/cwm/xevents.c b/app/cwm/xevents.c
index 25927ec22..65d762822 100644
--- a/app/cwm/xevents.c
+++ b/app/cwm/xevents.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: xevents.c,v 1.81 2013/05/20 21:32:00 okan Exp $
+ * $OpenBSD: xevents.c,v 1.82 2013/05/21 00:29:20 okan Exp $
*/
/*
@@ -359,6 +359,10 @@ xev_handle_clientmessage(XEvent *ee)
client_ptrsave(old_cc);
client_ptrwarp(cc);
}
+ if (e->message_type == ewmh[_NET_WM_STATE].atom &&
+ e->format == 32)
+ xu_ewmh_handle_net_wm_state_msg(cc,
+ e->data.l[0], e->data.l[1], e->data.l[2]);
}
static void
diff --git a/app/cwm/xutil.c b/app/cwm/xutil.c
index 727370220..7872ee984 100644
--- a/app/cwm/xutil.c
+++ b/app/cwm/xutil.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: xutil.c,v 1.65 2013/05/20 21:13:58 okan Exp $
+ * $OpenBSD: xutil.c,v 1.66 2013/05/21 00:29:20 okan Exp $
*/
#include <sys/param.h>
@@ -440,6 +440,43 @@ xu_ewmh_get_net_wm_state(struct client_ctx *cc, int *n)
}
void
+xu_ewmh_handle_net_wm_state_msg(struct client_ctx *cc, int action,
+ Atom first, Atom second)
+{
+ int i;
+ static struct handlers {
+ int atom;
+ int property;
+ void (*toggle)(struct client_ctx *);
+ } handlers[] = {
+ { _NET_WM_STATE_MAXIMIZED_VERT,
+ CLIENT_VMAXIMIZED,
+ client_vmaximize },
+ { _NET_WM_STATE_MAXIMIZED_HORZ,
+ CLIENT_HMAXIMIZED,
+ client_hmaximize },
+ };
+
+ for (i = 0; i < nitems(handlers); i++) {
+ if (first != ewmh[handlers[i].atom].atom &&
+ second != ewmh[handlers[i].atom].atom)
+ continue;
+ switch (action) {
+ case _NET_WM_STATE_ADD:
+ if ((cc->flags & handlers[i].property) == 0)
+ handlers[i].toggle(cc);
+ break;
+ case _NET_WM_STATE_REMOVE:
+ if (cc->flags & handlers[i].property)
+ handlers[i].toggle(cc);
+ break;
+ case _NET_WM_STATE_TOGGLE:
+ handlers[i].toggle(cc);
+ }
+ }
+}
+
+void
xu_ewmh_restore_net_wm_state(struct client_ctx *cc)
{
Atom *atoms;