foxygit / dotfiles Log in
commits tags

/fullscreen-monitor-fix.patch · 955 B

raw
diff --git a/src/sxwm.c b/src/sxwm.c
index eab858a..0610288 100644
--- a/src/sxwm.c
+++ b/src/sxwm.c
@@ -332,7 +332,18 @@ void apply_fullscreen(Client *c, Bool on)

 		c->fullscreen = True;

-		int mon = CLAMP(c->mon, 0, n_mons - 1);
+		/* c->mon is only set at map time (from the cursor's monitor) and
+		 * otherwise never kept in sync with the window's real position,
+		 * so a client moved by an external tool (xdotool, a pager) after
+		 * mapping would fullscreen onto the wrong monitor. Re-derive it
+		 * from the window's actual current geometry, same as the
+		 * restore-from-fullscreen path below already does. */
+		c->x = win_attr.x;
+		c->y = win_attr.y;
+		c->w = win_attr.width;
+		c->h = win_attr.height;
+		int mon = CLAMP(get_monitor_for(c), 0, n_mons - 1);
+		c->mon = mon;
 		/* make window fill mon */
 		XSetWindowBorderWidth(dpy, c->win, 0);
 		XMoveResizeWindow(dpy, c->win, mons[mon].x, mons[mon].y, mons[mon].w, mons[mon].h);