aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PATCHES2
-rw-r--r--config.def.h13
-rw-r--r--x.c68
3 files changed, 23 insertions, 60 deletions
diff --git a/PATCHES b/PATCHES
index a2aaf4d..48d2e2c 100644
--- a/PATCHES
+++ b/PATCHES
@@ -1,4 +1,4 @@
-st-anygeometry-0.8.1.diff
+st-anysize-20220718-baa9357.diff (modified to so that text does not jitter like st-expected-anysize-0.9.diff but better)
st-boxdraw_v2-0.8.5.diff
st-clipboard-20180309-c5ba9c0.diff
st-csi_22_23-0.8.5.diff
diff --git a/config.def.h b/config.def.h
index c535ee0..5a1a8ed 100644
--- a/config.def.h
+++ b/config.def.h
@@ -154,12 +154,6 @@ static unsigned int defaultrcs = 257;
static unsigned int cursorshape = 2;
/*
- * Whether to use pixel geometry or cell geometry
- */
-
-static Geometry geometry = CellGeometry;
-
-/*
* Default columns and rows numbers
*/
@@ -167,13 +161,6 @@ static unsigned int cols = 80;
static unsigned int rows = 24;
/*
- * Default width and height (including borders!)
- */
-
-static unsigned int width = 564;
-static unsigned int height = 364;
-
-/*
* Default colour and shape of the mouse cursor
*/
static unsigned int mouseshape = XC_xterm;
diff --git a/x.c b/x.c
index 41aebdf..e9047c0 100644
--- a/x.c
+++ b/x.c
@@ -53,11 +53,6 @@ enum undercurl_slope_type {
UNDERCURL_SLOPE_BOTTOM_CAP = 3
};
-typedef enum {
- PixelGeometry,
- CellGeometry
-} Geometry;
-
/* X modifiers */
#define XK_ANY_MOD UINT_MAX
#define XK_NO_MOD 0
@@ -97,6 +92,7 @@ typedef XftGlyphFontSpec GlyphFontSpec;
typedef struct {
int tw, th; /* tty width and height */
int w, h; /* window width and height */
+ int hborderpx, vborderpx;
int ch; /* char height */
int cw; /* char width */
int mode; /* window state/mode flags */
@@ -349,7 +345,7 @@ ttysend(const Arg *arg)
int
evcol(XEvent *e)
{
- int x = e->xbutton.x - borderpx;
+ int x = e->xbutton.x - win.hborderpx;
LIMIT(x, 0, win.tw - 1);
return x / win.cw;
}
@@ -357,7 +353,7 @@ evcol(XEvent *e)
int
evrow(XEvent *e)
{
- int y = e->xbutton.y - borderpx;
+ int y = e->xbutton.y - win.vborderpx;
LIMIT(y, 0, win.th - 1);
return y / win.ch;
}
@@ -759,6 +755,9 @@ cresize(int width, int height)
col = MAX(1, col);
row = MAX(1, row);
+ win.hborderpx = (win.w - col * win.cw);
+ win.vborderpx = (win.h - row * win.ch);
+
tresize(col, row);
xresize(col, row);
ttyresize(win.tw, win.th);
@@ -889,8 +888,8 @@ xhints(void)
sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
sizeh->height = win.h;
sizeh->width = win.w;
- sizeh->height_inc = win.ch;
- sizeh->width_inc = win.cw;
+ sizeh->height_inc = 1;
+ sizeh->width_inc = 1;
sizeh->base_height = 2 * borderpx;
sizeh->base_width = 2 * borderpx;
sizeh->min_height = win.ch + 2 * borderpx;
@@ -1147,7 +1146,7 @@ xicdestroy(XIC xim, XPointer client, XPointer call)
}
void
-xinit(int w, int h)
+xinit(int cols, int rows)
{
XGCValues gcvalues;
Cursor cursor;
@@ -1172,16 +1171,8 @@ xinit(int w, int h)
xloadcols();
/* adjust fixed window geometry */
- 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;
- }
+ win.w = win.hborderpx + 2 * borderpx + cols * win.cw;
+ win.h = win.vborderpx + 2 * borderpx + rows * win.ch;
if (xw.gm & XNegative)
xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
if (xw.gm & YNegative)
@@ -1549,17 +1540,17 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
/* Intelligent cleaning up of the borders. */
if (x == 0) {
- xclear(0, (y == 0)? 0 : winy, borderpx,
+ xclear(0, (y == 0)? 0 : winy, win.hborderpx,
winy + win.ch +
- ((winy + win.ch >= borderpx + win.th)? win.h : 0));
+ ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
}
- if (winx + width >= borderpx + win.tw) {
+ if (winx + width >= win.hborderpx + win.tw) {
xclear(winx + width, (y == 0)? 0 : winy, win.w,
- ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch)));
+ ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
}
if (y == 0)
- xclear(winx, 0, winx + width, borderpx);
- if (winy + win.ch >= borderpx + win.th)
+ xclear(winx, 0, winx + width, win.vborderpx);
+ if (winy + win.ch >= win.vborderpx + win.th)
xclear(winx, winy + win.ch, winx + width, win.h);
/* Clean up the region we want to draw to. */
@@ -2007,16 +1998,16 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
case 3: /* Blinking Underline */
case 4: /* Steady Underline */
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + (cy + 1) * win.ch - \
+- borderpx + cx * win.cw,
+- borderpx + (cy + 1) * win.ch - \
cursorthickness,
win.cw, cursorthickness);
break;
case 5: /* Blinking bar */
case 6: /* Steady bar */
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + cy * win.ch,
+- borderpx + cx * win.cw,
+- borderpx + cy * win.ch,
cursorthickness, win.ch);
break;
}
@@ -2525,12 +2516,6 @@ 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;
@@ -2567,19 +2552,10 @@ 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();