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:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+8
-3
@@ -287,11 +287,16 @@ static void setup_window() {
|
||||
screen = DefaultScreen(dpy);
|
||||
int sw = DisplayWidth(dpy, screen);
|
||||
int scrH = DisplayHeight(dpy, screen);
|
||||
winW = sw;
|
||||
winH = scrH - TOPBAR; // fill the area below the status bar
|
||||
// dwm draws a `borderpx` border around every client (src/sxmo-dwm/config.h).
|
||||
// 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 (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);
|
||||
XStoreName(dpy, win, "Snake");
|
||||
XClassHint* ch = XAllocClassHint();
|
||||
|
||||
@@ -329,11 +329,16 @@ static void setup_window() {
|
||||
screen = DefaultScreen(dpy);
|
||||
int sw = DisplayWidth(dpy, screen);
|
||||
int scrH = DisplayHeight(dpy, screen);
|
||||
winW = sw;
|
||||
winH = scrH - TOPBAR; // fill the area below the status bar
|
||||
// dwm draws a `borderpx` border around every client (src/sxmo-dwm/config.h).
|
||||
// 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 (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);
|
||||
XStoreName(dpy, win, "Tetris");
|
||||
XClassHint* ch = XAllocClassHint();
|
||||
|
||||
Reference in New Issue
Block a user