fix(games): inset windows so dwm's native border stays on-screen

dwm adds a borderpx (1) border around every client, so a window sized to
fill the usable area (240x296) overflowed the 240x320 screen by 2px on the
right and bottom, clipping the native window border. Offset the requested
position by the border width and shrink by 3*borderpx so the framed window
exactly meets the screen edges with the native border fully visible.
This commit is contained in:
Luxferre
2026-10-23 19:06:31 +03:00
parent 313e137d87
commit 70ef9860be
6 changed files with 16 additions and 6 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+8 -3
View File
@@ -287,11 +287,16 @@ static void setup_window() {
screen = DefaultScreen(dpy); screen = DefaultScreen(dpy);
int sw = DisplayWidth(dpy, screen); int sw = DisplayWidth(dpy, screen);
int scrH = DisplayHeight(dpy, screen); int scrH = DisplayHeight(dpy, screen);
winW = sw; // dwm draws a `borderpx` border around every client (src/sxmo-dwm/config.h).
winH = scrH - TOPBAR; // fill the area below the status bar // Size/position the window so that, once dwm adds its border back on each
// side, the framed window exactly meets the screen edges and the native
// border stays fully visible instead of being clipped off the right/bottom.
int bw = 1; // must match dwm borderpx
winW = sw - 3 * bw;
winH = (scrH - TOPBAR) - 3 * bw; // room for the status bar + border
if (winW < 96) winW = 96; if (winW < 96) winW = 96;
if (winH < 96) winH = 96; if (winH < 96) winH = 96;
win = XCreateWindow(dpy, RootWindow(dpy, screen), 0, 0, winW, winH, 0, win = XCreateWindow(dpy, RootWindow(dpy, screen), bw, TOPBAR + bw, winW, winH, 0,
CopyFromParent, InputOutput, CopyFromParent, 0, nullptr); CopyFromParent, InputOutput, CopyFromParent, 0, nullptr);
XStoreName(dpy, win, "Snake"); XStoreName(dpy, win, "Snake");
XClassHint* ch = XAllocClassHint(); XClassHint* ch = XAllocClassHint();
+8 -3
View File
@@ -329,11 +329,16 @@ static void setup_window() {
screen = DefaultScreen(dpy); screen = DefaultScreen(dpy);
int sw = DisplayWidth(dpy, screen); int sw = DisplayWidth(dpy, screen);
int scrH = DisplayHeight(dpy, screen); int scrH = DisplayHeight(dpy, screen);
winW = sw; // dwm draws a `borderpx` border around every client (src/sxmo-dwm/config.h).
winH = scrH - TOPBAR; // fill the area below the status bar // Size/position the window so that, once dwm adds its border back on each
// side, the framed window exactly meets the screen edges and the native
// border stays fully visible instead of being clipped off the right/bottom.
int bw = 1; // must match dwm borderpx
winW = sw - 3 * bw;
winH = (scrH - TOPBAR) - 3 * bw; // room for the status bar + border
if (winW < 96) winW = 96; if (winW < 96) winW = 96;
if (winH < 96) winH = 96; if (winH < 96) winH = 96;
win = XCreateWindow(dpy, RootWindow(dpy, screen), 0, 0, winW, winH, 0, win = XCreateWindow(dpy, RootWindow(dpy, screen), bw, TOPBAR + bw, winW, winH, 0,
CopyFromParent, InputOutput, CopyFromParent, 0, nullptr); CopyFromParent, InputOutput, CopyFromParent, 0, nullptr);
XStoreName(dpy, win, "Tetris"); XStoreName(dpy, win, "Tetris");
XClassHint* ch = XAllocClassHint(); XClassHint* ch = XAllocClassHint();