games: auto-size windows to available screen; dmenu shows Sys menu from any app
This commit is contained in:
@@ -23,8 +23,7 @@
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
static const int WIN_W = 224;
|
||||
static const int WIN_H = 292;
|
||||
static const int TOPBAR = 24;
|
||||
static const int PCOLS = 10;
|
||||
static const int PROWS = 20;
|
||||
static const int CELL = 14;
|
||||
@@ -87,7 +86,7 @@ static Window win;
|
||||
static GC gc;
|
||||
static Pixmap back;
|
||||
static int screen;
|
||||
static int winW = WIN_W, winH = WIN_H;
|
||||
static int winW = 240, winH = 296; // overridden at runtime from the actual screen
|
||||
static unsigned long C_BG, C_FG, C_HEAD, C_FOOD, C_DIM;
|
||||
|
||||
// ---- tetromino definitions (state 0 within a 4x4 box) ----
|
||||
@@ -328,6 +327,12 @@ static void setup_window() {
|
||||
dpy = XOpenDisplay(nullptr);
|
||||
if (!dpy) { fprintf(stderr, "tetris: cannot open display\n"); exit(1); }
|
||||
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
|
||||
if (winW < 96) winW = 96;
|
||||
if (winH < 96) winH = 96;
|
||||
win = XCreateWindow(dpy, RootWindow(dpy, screen), 0, 0, winW, winH, 0,
|
||||
CopyFromParent, InputOutput, CopyFromParent, 0, nullptr);
|
||||
XStoreName(dpy, win, "Tetris");
|
||||
|
||||
Reference in New Issue
Block a user