diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2014-08-25 12:49:20 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2014-08-25 12:49:20 +0000 |
commit | 74d02b4b0830e12c80b303b4bc615617c24577ed (patch) | |
tree | c9398d11b28d789080f8e7e929903ced091f7603 /app/cwm | |
parent | 771c1604293674a050b800a31229045fbd3ba6c4 (diff) |
Implement _NET_WM_STATE_STICKY, bound to CM-s by default; allows any
client to 'stick' to all desktops (ewmh speak) or groups - this
currently has the same affect as setting a client's group to 'nogroup',
with the exception that the client can also be in a group, so when
un-sticking, the client will go back to its original group/desktop.
Diffstat (limited to 'app/cwm')
-rw-r--r-- | app/cwm/calmwm.h | 8 | ||||
-rw-r--r-- | app/cwm/client.c | 19 | ||||
-rw-r--r-- | app/cwm/conf.c | 5 | ||||
-rw-r--r-- | app/cwm/cwm.1 | 6 | ||||
-rw-r--r-- | app/cwm/cwmrc.5 | 6 | ||||
-rw-r--r-- | app/cwm/group.c | 4 | ||||
-rw-r--r-- | app/cwm/kbfunc.c | 8 | ||||
-rw-r--r-- | app/cwm/xutil.c | 10 |
8 files changed, 55 insertions, 11 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index aa23bca40..bf4e98a21 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.263 2014/08/24 15:37:45 okan Exp $ + * $OpenBSD: calmwm.h,v 1.264 2014/08/25 12:49:19 okan Exp $ */ #ifndef _CALMWM_H_ @@ -180,6 +180,7 @@ struct client_ctx { #define CLIENT_WM_TAKE_FOCUS 0x0200 #define CLIENT_URGENCY 0x0400 #define CLIENT_FULLSCREEN 0x0800 +#define CLIENT_STICKY 0x1000 #define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP) #define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) @@ -349,7 +350,8 @@ enum { _NET_WM_DESKTOP, _NET_CLOSE_WINDOW, _NET_WM_STATE, -#define _NET_WM_STATES_NITEMS 4 +#define _NET_WM_STATES_NITEMS 5 + _NET_WM_STATE_STICKY, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_FULLSCREEN, @@ -396,6 +398,7 @@ void client_set_wm_state(struct client_ctx *, long); void client_setactive(struct client_ctx *); void client_setname(struct client_ctx *); int client_snapcalc(int, int, int, int, int); +void client_sticky(struct client_ctx *); void client_transient(struct client_ctx *); void client_unhide(struct client_ctx *); void client_urgency(struct client_ctx *); @@ -464,6 +467,7 @@ void kbfunc_client_nogroup(struct client_ctx *, void kbfunc_client_raise(struct client_ctx *, union arg *); void kbfunc_client_rcycle(struct client_ctx *, union arg *); void kbfunc_client_search(struct client_ctx *, union arg *); +void kbfunc_client_sticky(struct client_ctx *, union arg *); void kbfunc_client_vmaximize(struct client_ctx *, union arg *); void kbfunc_cmdexec(struct client_ctx *, union arg *); diff --git a/app/cwm/client.c b/app/cwm/client.c index d613375ba..5e2d2c4d1 100644 --- a/app/cwm/client.c +++ b/app/cwm/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.173 2014/08/20 15:15:29 okan Exp $ + * $OpenBSD: client.c,v 1.174 2014/08/25 12:49:19 okan Exp $ */ #include <sys/param.h> @@ -239,6 +239,17 @@ client_freeze(struct client_ctx *cc) } void +client_sticky(struct client_ctx *cc) +{ + if (cc->flags & CLIENT_STICKY) + cc->flags &= ~CLIENT_STICKY; + else + cc->flags |= CLIENT_STICKY; + + xu_ewmh_set_net_wm_state(cc); +} + +void client_fullscreen(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; @@ -468,6 +479,9 @@ client_ptrsave(struct client_ctx *cc) void client_hide(struct client_ctx *cc) { + if (cc->flags & CLIENT_STICKY) + return; + XUnmapWindow(X_Dpy, cc->win); cc->active = 0; @@ -481,6 +495,9 @@ client_hide(struct client_ctx *cc) void client_unhide(struct client_ctx *cc) { + if (cc->flags & CLIENT_STICKY) + return; + XMapRaised(X_Dpy, cc->win); cc->flags &= ~CLIENT_HIDDEN; diff --git a/app/cwm/conf.c b/app/cwm/conf.c index 194c58baa..dccaf8b0b 100644 --- a/app/cwm/conf.c +++ b/app/cwm/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.176 2014/08/24 15:49:58 okan Exp $ + * $OpenBSD: conf.c,v 1.177 2014/08/25 12:49:19 okan Exp $ */ #include <sys/param.h> @@ -204,6 +204,7 @@ static const struct { { "CM-g", "grouptoggle" }, { "CM-f", "fullscreen" }, { "CM-m", "maximize" }, + { "CM-s", "sticky" }, { "CM-equal", "vmaximize" }, { "CMS-equal", "hmaximize" }, { "CMS-f", "freeze" }, @@ -389,6 +390,7 @@ static const struct { { "rcycleingroup", kbfunc_client_cycle, CWM_WIN, {.i = CWM_RCYCLE|CWM_INGROUP} }, { "grouptoggle", kbfunc_client_grouptoggle, CWM_WIN, {0}}, + { "sticky", kbfunc_client_sticky, CWM_WIN, {0} }, { "fullscreen", kbfunc_client_fullscreen, CWM_WIN, {0} }, { "maximize", kbfunc_client_maximize, CWM_WIN, {0} }, { "vmaximize", kbfunc_client_vmaximize, CWM_WIN, {0} }, @@ -678,6 +680,7 @@ static char *ewmhints[] = { "_NET_WM_DESKTOP", "_NET_CLOSE_WINDOW", "_NET_WM_STATE", + "_NET_WM_STATE_STICKY", "_NET_WM_STATE_MAXIMIZED_VERT", "_NET_WM_STATE_MAXIMIZED_HORZ", "_NET_WM_STATE_FULLSCREEN", diff --git a/app/cwm/cwm.1 b/app/cwm/cwm.1 index 91743045d..f75eda171 100644 --- a/app/cwm/cwm.1 +++ b/app/cwm/cwm.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwm.1,v 1.50 2014/02/01 00:25:04 okan Exp $ +.\" $OpenBSD: cwm.1,v 1.51 2014/08/25 12:49:19 okan Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 1 2014 $ +.Dd $Mdocdate: August 25 2014 $ .Dt CWM 1 .Os .Sh NAME @@ -90,6 +90,8 @@ Cycle through active groups. Reverse cycle through active groups. .It Ic CMS-f Toggle freezing geometry of current window. +.It Ic CM-s +Toggle stickiness of current window. .It Ic CM-f Toggle full-screen mode of current window. .It Ic CM-m diff --git a/app/cwm/cwmrc.5 b/app/cwm/cwmrc.5 index 86cc090a6..18479783e 100644 --- a/app/cwm/cwmrc.5 +++ b/app/cwm/cwmrc.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwmrc.5,v 1.58 2014/01/29 21:17:33 okan Exp $ +.\" $OpenBSD: cwmrc.5,v 1.59 2014/08/25 12:49:19 okan Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 29 2014 $ +.Dd $Mdocdate: August 25 2014 $ .Dt CWMRC 5 .Os .Sh NAME @@ -341,6 +341,8 @@ Raise current window. Label current window. .It freeze Freeze current window geometry. +.It sticky +Stick current window to all groups (same as assigning to nogroup). .It fullscreen Full-screen current window (gap + border removed). .It maximize diff --git a/app/cwm/group.c b/app/cwm/group.c index e341c8cff..473aff8f8 100644 --- a/app/cwm/group.c +++ b/app/cwm/group.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: group.c,v 1.94 2014/08/24 15:37:45 okan Exp $ + * $OpenBSD: group.c,v 1.95 2014/08/25 12:49:19 okan Exp $ */ #include <sys/param.h> @@ -207,6 +207,8 @@ group_hidden_state(struct group_ctx *gc) int hidden = 0, same = 0; TAILQ_FOREACH(cc, &gc->clients, group_entry) { + if (cc->flags & CLIENT_STICKY) + continue; if (hidden == ((cc->flags & CLIENT_HIDDEN) ? 1 : 0)) same++; } diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c index c7b48be10..46d43cf82 100644 --- a/app/cwm/kbfunc.c +++ b/app/cwm/kbfunc.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: kbfunc.c,v 1.95 2014/01/30 15:41:11 okan Exp $ + * $OpenBSD: kbfunc.c,v 1.96 2014/08/25 12:49:19 okan Exp $ */ #include <sys/param.h> @@ -433,6 +433,12 @@ kbfunc_client_movetogroup(struct client_ctx *cc, union arg *arg) } void +kbfunc_client_sticky(struct client_ctx *cc, union arg *arg) +{ + client_sticky(cc); +} + +void kbfunc_client_fullscreen(struct client_ctx *cc, union arg *arg) { client_fullscreen(cc); diff --git a/app/cwm/xutil.c b/app/cwm/xutil.c index 368dc404f..a5c1302e6 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.87 2014/08/22 19:04:00 okan Exp $ + * $OpenBSD: xutil.c,v 1.88 2014/08/25 12:49:19 okan Exp $ */ #include <sys/param.h> @@ -326,6 +326,9 @@ xu_ewmh_handle_net_wm_state_msg(struct client_ctx *cc, int action, int property; void (*toggle)(struct client_ctx *); } handlers[] = { + { _NET_WM_STATE_STICKY, + CLIENT_STICKY, + client_sticky }, { _NET_WM_STATE_MAXIMIZED_VERT, CLIENT_VMAXIMIZED, client_vmaximize }, @@ -367,6 +370,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[_NET_WM_STATE_STICKY]) + client_sticky(cc); if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_HORZ]) client_hmaximize(cc); if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_VERT]) @@ -391,10 +396,13 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc) if (oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ] && oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT] && oatoms[i] != ewmh[_NET_WM_STATE_FULLSCREEN] && + oatoms[i] != ewmh[_NET_WM_STATE_STICKY] && oatoms[i] != ewmh[_NET_WM_STATE_DEMANDS_ATTENTION]) atoms[j++] = oatoms[i]; } free(oatoms); + if (cc->flags & CLIENT_STICKY) + atoms[j++] = ewmh[_NET_WM_STATE_STICKY]; if (cc->flags & CLIENT_FULLSCREEN) atoms[j++] = ewmh[_NET_WM_STATE_FULLSCREEN]; else { |