diff options
author | okan <okan> | 2013-05-21 00:29:20 +0000 |
---|---|---|
committer | okan <okan> | 2013-05-21 00:29:20 +0000 |
commit | 421bf22ac7a165f0f4d5608ffa22c887ff857d53 (patch) | |
tree | 10a4b2aac13d42ef16e8296c1ef72dcba27f2dea | |
parent | c2042cd5238e74bcc3763a1e90917425eb41964e (diff) | |
download | cwm-421bf22ac7a165f0f4d5608ffa22c887ff857d53.tar.gz cwm-421bf22ac7a165f0f4d5608ffa22c887ff857d53.tar.xz cwm-421bf22ac7a165f0f4d5608ffa22c887ff857d53.zip |
handle _NET_WM_STATE ClientMessage; from Alexander Polakov.
-rw-r--r-- | calmwm.h | 7 | ||||
-rw-r--r-- | xevents.c | 4 | ||||
-rw-r--r-- | xutil.c | 37 |
3 files changed, 48 insertions, 0 deletions
diff --git a/calmwm.h b/calmwm.h index e525cbf..b925c2c 100644 --- a/calmwm.h +++ b/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/xevents.c b/xevents.c index b13548b..1c6ffaf 100644 --- a/xevents.c +++ b/xevents.c @@ -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/xutil.c b/xutil.c index 95bb0d4..2c678dd 100644 --- a/xutil.c +++ b/xutil.c @@ -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; |