Add anygeometry patch

This commit is contained in:
2024-06-03 14:05:55 +01:00
parent 708cb32c3a
commit e47294c9fd
4 changed files with 170 additions and 6 deletions

View File

@@ -45,6 +45,11 @@ typedef struct {
signed char appcursor; /* application cursor */
} Key;
typedef enum {
PixelGeometry,
CellGeometry
} Geometry;
/* X modifiers */
#define XK_ANY_MOD UINT_MAX
#define XK_NO_MOD 0
@@ -1127,7 +1132,7 @@ xicdestroy(XIC xim, XPointer client, XPointer call)
}
void
xinit(int cols, int rows)
xinit(int w, int h)
{
XGCValues gcvalues;
Cursor cursor;
@@ -1152,8 +1157,16 @@ xinit(int cols, int rows)
xloadcols();
/* adjust fixed window geometry */
win.w = 2 * borderpx + cols * win.cw;
win.h = 2 * borderpx + rows * win.ch;
switch (geometry) {
case CellGeometry:
win.w = 2 * borderpx + w * win.cw;
win.h = 2 * borderpx + h * win.ch;
break;
case PixelGeometry:
win.w = w;
win.h = h;
break;
}
if (xw.gm & XNegative)
xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
if (xw.gm & YNegative)
@@ -2068,6 +2081,12 @@ main(int argc, char *argv[])
case 'g':
xw.gm = XParseGeometry(EARGF(usage()),
&xw.l, &xw.t, &cols, &rows);
geometry = CellGeometry;
break;
case 'G':
xw.gm = XParseGeometry(EARGF(usage()),
&xw.l, &xw.t, &width, &height);
geometry = PixelGeometry;
break;
case 'i':
xw.isfixed = 1;
@@ -2104,10 +2123,19 @@ run:
setlocale(LC_CTYPE, "");
XSetLocaleModifiers("");
switch (geometry) {
case CellGeometry:
xinit(cols, rows);
break;
case PixelGeometry:
xinit(width, height);
cols = (win.w - 2 * borderpx) / win.cw;
rows = (win.h - 2 * borderpx) / win.ch;
break;
}
cols = MAX(cols, 1);
rows = MAX(rows, 1);
tnew(cols, rows);
xinit(cols, rows);
xsetenv();
selinit();
run();