[wiki] [sites] add anygeometry patch || José Miguel Sánchez García

From: <git_AT_suckless.org>
Date: Thu, 13 Aug 2020 13:17:24 +0200

commit 21f31b43185f92741250c4737f31de181be88c56
Author: José Miguel Sánchez García <soy.jmi2k_AT_gmail.com>
Date: Thu Aug 13 11:17:09 2020 +0000

    add anygeometry patch

diff --git a/st.suckless.org/patches/anygeometry/index.md b/st.suckless.org/patches/anygeometry/index.md
new file mode 100644
index 00000000..5ca74a37
--- /dev/null
+++ b/st.suckless.org/patches/anygeometry/index.md
_AT_@ -0,0 +1,24 @@
+anygeometry
+===========
+
+Description
+-----------
+From `anysize` patch:
+
+> By default, st's window size always snaps to the nearest multiple of the
+> character size plus a fixed inner border (set with borderpx in config.h). When
+> the size of st does not perfectly match the space allocated to it (when using
+> a tiling WM, for example), unsightly gaps will appear between st and other
+> apps, or between instances of st.
+
+This patch allows you to set st's width and height as pixels instead of cells,
+both from the command line (with the new parameter `-G`) or the config file
+(variables `geometry`, `width` and `height`).
+
+Download
+--------
+* [st-anygeometry-0.8.1.diff](st-anygeometry-0.8.1.diff)
+
+Authors
+-------
+* José Miguel Sánchez García - <soy.jmi2k_AT_gmail.com>
diff --git a/st.suckless.org/patches/anygeometry/st-anygeometry-0.8.1.diff b/st.suckless.org/patches/anygeometry/st-anygeometry-0.8.1.diff
new file mode 100644
index 00000000..b04d36c6
--- /dev/null
+++ b/st.suckless.org/patches/anygeometry/st-anygeometry-0.8.1.diff
_AT_@ -0,0 +1,123 @@
+From 6a5a862569912e34febe2dbd5244062013840204 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jos=C3=A9=20Miguel=20S=C3=A1nchez=20Garc=C3=ADa?=
+ <soy.jmi2k_AT_gmail.com>
+Date: Thu, 13 Aug 2020 11:02:01 +0000
+Subject: [PATCH] add -G to set pixel-based geometry
+
+---
+ config.def.h | 13 +++++++++++++
+ x.c | 36 ++++++++++++++++++++++++++++++++----
+ 2 files changed, 45 insertions(+), 4 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 6f05dce..bea316a 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -141,6 +141,12 @@ 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
+ */
+_AT_@ -148,6 +154,13 @@ static unsigned int cursorshape = 2;
+ 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
+ */
+diff --git a/x.c b/x.c
+index 210f184..29e35d0 100644
+--- a/x.c
++++ b/x.c
+_AT_@ -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
+_AT_@ -1096,7 +1101,7 @@ xicdestroy(XIC xim, XPointer client, XPointer call)
+ }
+
+ void
+-xinit(int cols, int rows)
++xinit(int w, int h)
+ {
+ XGCValues gcvalues;
+ Cursor cursor;
+_AT_@ -1121,8 +1126,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)
+_AT_@ -2001,6 +2014,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;
+_AT_@ -2037,10 +2056,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();
+--
+2.28.0
+
Received on Thu Aug 13 2020 - 13:17:24 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 13 2020 - 13:24:47 CEST