From 050ec08253369cf483d59875a86392661c682b23 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 21 Aug 2015 16:30:02 +0000 Subject: Add client freeze extension to _NET_WM_STATE Atom, allowing flag to persist. As usual with new Atoms, requires X restart. --- calmwm.h | 5 +++-- client.c | 4 +++- conf.c | 3 ++- xutil.c | 12 ++++++++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/calmwm.h b/calmwm.h index d919602..6b1ba88 100644 --- a/calmwm.h +++ b/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.297 2015/07/12 14:31:47 okan Exp $ + * $OpenBSD: calmwm.h,v 1.298 2015/08/21 16:30:02 okan Exp $ */ #ifndef _CALMWM_H_ @@ -364,7 +364,8 @@ enum { _NET_WM_DESKTOP, _NET_CLOSE_WINDOW, _NET_WM_STATE, -#define _NET_WM_STATES_NITEMS 6 +#define _NET_WM_STATES_NITEMS 7 + _CWM_WM_STATE_FREEZE, _NET_WM_STATE_STICKY, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ, diff --git a/client.c b/client.c index 4e9e566..dc63899 100644 --- a/client.c +++ b/client.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: client.c,v 1.200 2015/08/21 16:14:39 okan Exp $ + * $OpenBSD: client.c,v 1.201 2015/08/21 16:30:02 okan Exp $ */ #include @@ -237,6 +237,8 @@ client_toggle_freeze(struct client_ctx *cc) cc->flags &= ~CLIENT_FREEZE; else cc->flags |= CLIENT_FREEZE; + + xu_ewmh_set_net_wm_state(cc); } void diff --git a/conf.c b/conf.c index 34ebde9..f10120a 100644 --- a/conf.c +++ b/conf.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: conf.c,v 1.193 2015/08/21 15:55:39 okan Exp $ + * $OpenBSD: conf.c,v 1.194 2015/08/21 16:30:02 okan Exp $ */ #include @@ -680,6 +680,7 @@ static char *ewmhints[] = { "_NET_WM_DESKTOP", "_NET_CLOSE_WINDOW", "_NET_WM_STATE", + "_CWM_WM_STATE_FREEZE", "_NET_WM_STATE_STICKY", "_NET_WM_STATE_MAXIMIZED_VERT", "_NET_WM_STATE_MAXIMIZED_HORZ", diff --git a/xutil.c b/xutil.c index 2d4ab87..5124874 100644 --- a/xutil.c +++ b/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.99 2015/03/28 23:12:47 okan Exp $ + * $OpenBSD: xutil.c,v 1.100 2015/08/21 16:30:02 okan Exp $ */ #include @@ -374,6 +374,9 @@ xu_ewmh_handle_net_wm_state_msg(struct client_ctx *cc, int action, int property; void (*toggle)(struct client_ctx *); } handlers[] = { + { _CWM_WM_STATE_FREEZE, + CLIENT_FREEZE, + client_toggle_freeze }, { _NET_WM_STATE_STICKY, CLIENT_STICKY, client_toggle_sticky }, @@ -421,6 +424,8 @@ xu_ewmh_restore_net_wm_state(struct client_ctx *cc) atoms = xu_ewmh_get_net_wm_state(cc, &n); for (i = 0; i < n; i++) { + if (atoms[i] == ewmh[_CWM_WM_STATE_FREEZE]) + client_toggle_freeze(cc); if (atoms[i] == ewmh[_NET_WM_STATE_STICKY]) client_toggle_sticky(cc); if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_HORZ]) @@ -446,7 +451,8 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc) oatoms = xu_ewmh_get_net_wm_state(cc, &n); atoms = xreallocarray(NULL, (n + _NET_WM_STATES_NITEMS), sizeof(Atom)); for (i = j = 0; i < n; i++) { - if (oatoms[i] != ewmh[_NET_WM_STATE_STICKY] && + if (oatoms[i] != ewmh[_CWM_WM_STATE_FREEZE] && + oatoms[i] != ewmh[_NET_WM_STATE_STICKY] && oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ] && oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT] && oatoms[i] != ewmh[_NET_WM_STATE_HIDDEN] && @@ -455,6 +461,8 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc) atoms[j++] = oatoms[i]; } free(oatoms); + if (cc->flags & CLIENT_FREEZE) + atoms[j++] = ewmh[_CWM_WM_STATE_FREEZE]; if (cc->flags & CLIENT_STICKY) atoms[j++] = ewmh[_NET_WM_STATE_STICKY]; if (cc->flags & CLIENT_HIDDEN) -- cgit v1.2.3-2-gb3c3