changeset 787:eecb13b34511 default tip

Put floating windows on random starting positions
author markus schnalke <meillo@marmaro.de>
date Fri, 18 Oct 2024 23:42:20 +0200 (4 months ago)
parents e65be4ffdbdc
children
files aewl.c
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/aewl.c	Thu Jun 14 00:00:00 2012 +0200
+++ b/aewl.c	Fri Oct 18 23:42:20 2024 +0200
@@ -1188,8 +1188,12 @@
 	c = emallocz(sizeof(Client));
 	c->tag = True;
 	c->win = w;
-	c->x = wa->x;
-	c->y = wa->y;
+	if (wa->width < sw) {
+		c->x = rand() % (sw - wa->width);
+	}
+	if (wa->height < sh) {
+		c->y = rand() % (sh - wa->height);
+	}
 	c->w = wa->width;
 	c->h = wa->height;
 	if(c->w == sw && c->h == sh) {
@@ -1277,6 +1281,10 @@
 		c->border = 0;
 	else
 		c->border = BORDERPX;
+	/* move outside window back to original place */
+	if(c->x > sw) {
+		c->x -= 2 * sw;
+	}
 	/* offscreen appearance fixes */
 	if(c->x > sw)
 		c->x = sw - c->w - 2 * c->border;