summary refs log tree commit diff
path: root/screen.c
diff options
context:
space:
mode:
authorokan <okan>2016-10-04 20:15:55 +0000
committerokan <okan>2016-10-04 20:15:55 +0000
commita37606c63ff059a458023ddef1bd6e8926497f18 (patch)
tree32d184fc7e04a98f172708d24e595fa96f1f5137 /screen.c
parent5c13775d31ce277bba94c68daff12cf50224aba0 (diff)
downloadcwm-a37606c63ff059a458023ddef1bd6e8926497f18.tar.gz
cwm-a37606c63ff059a458023ddef1bd6e8926497f18.tar.xz
cwm-a37606c63ff059a458023ddef1bd6e8926497f18.zip
When removing xrandr regions, ensure clients are within the bounds of
the screen; adapted from an ancient diff from Sviatoslav Chagaev. Things
in this area will likely change, but put this in so it works now and
serves as a reminder.
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/screen.c b/screen.c
index 79e7cc5..b9f1ac9 100644
--- a/screen.c
+++ b/screen.c
@@ -229,3 +229,26 @@ screen_apply_gap(struct screen_ctx *sc, struct geom geom)
 
 	return(geom);
 }
+
+/* Bring back clients which are beyond the screen. */
+void
+screen_assert_clients_within(struct screen_ctx *sc)
+{
+	struct client_ctx	*cc;
+	int			 top, left, right, bottom;
+
+	TAILQ_FOREACH(cc, &sc->clientq, entry) {
+		if (cc->sc != sc)
+			continue;
+		top = cc->geom.y;
+		left = cc->geom.x;
+		right = cc->geom.x + cc->geom.w + (cc->bwidth * 2) - 1;
+		bottom = cc->geom.y + cc->geom.h + (cc->bwidth * 2) - 1;
+		if ((top > sc->view.h || left > sc->view.w) ||
+		    (bottom < 0 || right < 0)) {
+			cc->geom.x = sc->gap.left;
+			cc->geom.y = sc->gap.top;
+			client_move(cc);
+		}
+	}
+}