summary refs log tree commit diff
path: root/xutil.c
diff options
context:
space:
mode:
authorokan <okan>2015-08-28 12:07:28 +0000
committerokan <okan>2015-08-28 12:07:28 +0000
commit3f0b6cf4ea53d80ef7e2d9a96f4d93bb209aa2b6 (patch)
treec5a24ee9a664320b85b6a7db1101376c08f4bc7d /xutil.c
parentc0f2d0cc756f5ec7076946179efe2399f026c60a (diff)
parent47a10cc05549b0a94e3606ca7be9fe626754d12d (diff)
downloadcwm-3f0b6cf4ea53d80ef7e2d9a96f4d93bb209aa2b6.tar.gz
cwm-3f0b6cf4ea53d80ef7e2d9a96f4d93bb209aa2b6.tar.xz
cwm-3f0b6cf4ea53d80ef7e2d9a96f4d93bb209aa2b6.zip
cvsimport
* refs/heads/master: (21 commits)
  Lost fix from r1.112; add comment.
  Mechanical change: group->gc
  Add consistent checks against NULL.
  Move client cycle grab/ungrab into a more relevant place; while here, update comments about why we need to grab/ungrab the keyboard.
  Re-add lost chunk in group_cycle from r1.113.
  Further simplify _NET_WM_DESKTOP handling using new group_assign().
  oops; remove left over debug print
  Allowing sending a valid 'nogroup' (0) group_ctx to group_assign() (since we init all groups), though assigning the client's group to NULL for 'sticky'; use this simplification in a few places (others to follow).
  Split out sticky mode checks and the restoring of a client's group and _NET_WM_DESKTOP from the config-based auto-grouping; no (intentional) behavior changes.  Needed for further work in cleaning up this area.
  Implement _NET_CLIENT_LIST_STACKING (from Thomas Admin), but bottom-to-top order, as per spec (notified Thomas as well).
  Don't allow freeze operations on fullscreen (consistent with what fullscreen does).
  Sort _NET_WM_STATE Atoms like the spec.
  Move CLIENT_STICKY logic from client hide/unhide to group hide/unhide; rationale being that clients should be able to hide/unhide independently of group switching.
  Add Xkb modifier to ignore mask; from Alexander Polakov.
  Fix whitespace.
  Add client freeze extension to _NET_WM_STATE Atom, allowing flag to persist. As usual with new Atoms, requires X restart.
  _NET_WM_STATE_STICKY implies only sticky at the group/desktop level, not position and size; based on discussion with a few.
  Instead of special casing the 'term' and 'lock' commands, go back to keeping them hidden; showing them has apparently caused confusion/angst.
  Leave command list order from .cwmrc alone; remove sort.
  Bring group and client cycle closer together.
  ...
Diffstat (limited to 'xutil.c')
-rw-r--r--xutil.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/xutil.c b/xutil.c
index 5294edc..c4db9f6 100644
--- a/xutil.c
+++ b/xutil.c
@@ -229,6 +229,27 @@ xu_ewmh_net_client_list(struct screen_ctx *sc)
 }
 
 void
+xu_ewmh_net_client_list_stacking(struct screen_ctx *sc)
+{
+	struct client_ctx	*cc;
+	Window			*winlist;
+	int			 i = 0, j;
+
+	TAILQ_FOREACH(cc, &sc->clientq, entry)
+		i++;
+	if (i == 0)
+		return;
+
+	j = i;
+	winlist = xreallocarray(NULL, i, sizeof(*winlist));
+	TAILQ_FOREACH(cc, &sc->clientq, entry)
+		winlist[--j] = cc->win;
+	XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CLIENT_LIST_STACKING],
+	    XA_WINDOW, 32, PropModeReplace, (unsigned char *)winlist, i);
+	free(winlist);
+}
+
+void
 xu_ewmh_net_active_window(struct screen_ctx *sc, Window w)
 {
 	XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_ACTIVE_WINDOW],
@@ -341,8 +362,8 @@ xu_ewmh_net_wm_desktop(struct client_ctx *cc)
 {
 	long	 num = 0xffffffff;
 
-	if (cc->group)
-		num = cc->group->num;
+	if (cc->gc)
+		num = cc->gc->num;
 
 	XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_DESKTOP],
 	    XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&num, 1);
@@ -392,6 +413,9 @@ xu_ewmh_handle_net_wm_state_msg(struct client_ctx *cc, int action,
 		{ _NET_WM_STATE_DEMANDS_ATTENTION,
 			CLIENT_URGENCY,
 			client_urgency },
+		{ _CWM_WM_STATE_FREEZE,
+			CLIENT_FREEZE,
+			client_toggle_freeze },
 	};
 
 	for (i = 0; i < nitems(handlers); i++) {
@@ -423,16 +447,18 @@ xu_ewmh_restore_net_wm_state(struct client_ctx *cc)
 	for (i = 0; i < n; i++) {
 		if (atoms[i] == ewmh[_NET_WM_STATE_STICKY])
 			client_toggle_sticky(cc);
-		if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_HORZ])
-			client_toggle_hmaximize(cc);
 		if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_VERT])
 			client_toggle_vmaximize(cc);
+		if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_HORZ])
+			client_toggle_hmaximize(cc);
 		if (atoms[i] == ewmh[_NET_WM_STATE_HIDDEN])
 			client_toggle_hidden(cc);
 		if (atoms[i] == ewmh[_NET_WM_STATE_FULLSCREEN])
 			client_toggle_fullscreen(cc);
 		if (atoms[i] == ewmh[_NET_WM_STATE_DEMANDS_ATTENTION])
 			client_urgency(cc);
+		if (atoms[i] == ewmh[_CWM_WM_STATE_FREEZE])
+			client_toggle_freeze(cc);
 	}
 	free(atoms);
 }
@@ -447,11 +473,12 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc)
 	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] &&
-		    oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ] &&
 		    oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT] &&
+		    oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ] &&
 		    oatoms[i] != ewmh[_NET_WM_STATE_HIDDEN] &&
 		    oatoms[i] != ewmh[_NET_WM_STATE_FULLSCREEN] &&
-		    oatoms[i] != ewmh[_NET_WM_STATE_DEMANDS_ATTENTION])
+		    oatoms[i] != ewmh[_NET_WM_STATE_DEMANDS_ATTENTION] &&
+		    oatoms[i] != ewmh[_CWM_WM_STATE_FREEZE])
 			atoms[j++] = oatoms[i];
 	}
 	free(oatoms);
@@ -462,13 +489,15 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc)
 	if (cc->flags & CLIENT_FULLSCREEN)
 		atoms[j++] = ewmh[_NET_WM_STATE_FULLSCREEN];
 	else {
-		if (cc->flags & CLIENT_HMAXIMIZED)
-			atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_HORZ];
 		if (cc->flags & CLIENT_VMAXIMIZED)
 			atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_VERT];
+		if (cc->flags & CLIENT_HMAXIMIZED)
+			atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_HORZ];
 	}
 	if (cc->flags & CLIENT_URGENCY)
 		atoms[j++] = ewmh[_NET_WM_STATE_DEMANDS_ATTENTION];
+	if (cc->flags & CLIENT_FREEZE)
+		atoms[j++] = ewmh[_CWM_WM_STATE_FREEZE];
 	if (j > 0)
 		XChangeProperty(X_Dpy, cc->win, ewmh[_NET_WM_STATE],
 		    XA_ATOM, 32, PropModeReplace, (unsigned char *)atoms, j);