70 lines
1.9 KiB
Diff
70 lines
1.9 KiB
Diff
--- x.c.orig Fri Mar 13 08:07:14 2026
|
|
+++ x.c Fri Mar 13 08:10:58 2026
|
|
@@ -251,6 +251,7 @@
|
|
static char *opt_line = NULL;
|
|
static char *opt_name = NULL;
|
|
static char *opt_title = NULL;
|
|
+static int opt_pixelgeom = 0;
|
|
|
|
static uint buttons; /* bit field of pressed buttons */
|
|
|
|
@@ -1147,6 +1148,15 @@
|
|
usedfont = (opt_font == NULL)? font : opt_font;
|
|
xloadfonts(usedfont, 0);
|
|
|
|
+ /* -p: convert stashed pixel dimensions to cols/rows */
|
|
+ if (opt_pixelgeom && win.w > 0 && win.h > 0) {
|
|
+ cols = MAX(1, (win.w - 2 * borderpx) / win.cw);
|
|
+ rows = MAX(1, (win.h - 2 * borderpx) / win.ch);
|
|
+ tresize(cols, rows);
|
|
+ win.w = 2 * borderpx + cols * win.cw;
|
|
+ win.h = 2 * borderpx + rows * win.ch;
|
|
+ }
|
|
+
|
|
/* colors */
|
|
xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
|
|
xloadcols();
|
|
@@ -2026,11 +2036,11 @@
|
|
void
|
|
usage(void)
|
|
{
|
|
- die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]"
|
|
+ die("usage: %s [-aipv] [-c class] [-f font] [-g geometry]"
|
|
" [-n name] [-o file]\n"
|
|
" [-T title] [-t title] [-w windowid]"
|
|
" [[-e] command [args ...]]\n"
|
|
- " %s [-aiv] [-c class] [-f font] [-g geometry]"
|
|
+ " %s [-aipv] [-c class] [-f font] [-g geometry]"
|
|
" [-n name] [-o file]\n"
|
|
" [-T title] [-t title] [-w windowid] -l line"
|
|
" [stty_args ...]\n", argv0, argv0);
|
|
@@ -2061,6 +2071,9 @@
|
|
xw.gm = XParseGeometry(EARGF(usage()),
|
|
&xw.l, &xw.t, &cols, &rows);
|
|
break;
|
|
+ case 'p':
|
|
+ opt_pixelgeom = 1;
|
|
+ break;
|
|
case 'i':
|
|
xw.isfixed = 1;
|
|
break;
|
|
@@ -2096,6 +2109,18 @@
|
|
|
|
setlocale(LC_CTYPE, "");
|
|
XSetLocaleModifiers("");
|
|
+ if (opt_pixelgeom && cols > 0 && rows > 0) {
|
|
+ /*
|
|
+ * -p: cols/rows from -g are pixel dimensions.
|
|
+ * Stash them in win.w/win.h; use default 80x24
|
|
+ * for the initial tnew() allocation. xinit() will
|
|
+ * compute the real cols/rows after font loading.
|
|
+ */
|
|
+ win.w = cols;
|
|
+ win.h = rows;
|
|
+ cols = 80;
|
|
+ rows = 24;
|
|
+ }
|
|
cols = MAX(cols, 1);
|
|
rows = MAX(rows, 1);
|
|
tnew(cols, rows);
|