sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 34359af5d4ebd52182f8138b6aee07c1142a44a2
parent a8d10ade0cf8162b514cb09363bd31fda863016c
Author: Malcolm VanOrder <mvanorder1390@gmail.com>
Date:   Tue,  4 Feb 2020 01:24:49 -0500

[st][patch] Apply modified xresources patch to version 0.8.2

Diffstat:
Ast.suckless.org/patches/xresources/st-xresources-20200204-cfdf3f0.diff | 197+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 197 insertions(+), 0 deletions(-)

diff --git a/st.suckless.org/patches/xresources/st-xresources-20200204-cfdf3f0.diff b/st.suckless.org/patches/xresources/st-xresources-20200204-cfdf3f0.diff @@ -0,0 +1,197 @@ +From cfdf3f0fcd81c3fe29bf4717d3276e078efc5787 Mon Sep 17 00:00:00 2001 +From: Malcolm VanOrder <mvanorder1390@gmail.com> +Date: Tue, 4 Feb 2020 00:29:16 -0500 +Subject: [PATCH] Apply modified xresources patch to version 0.8.2 + +Modified verion of https://git.suckless.org/sites/file/st.suckless.org/patches/xresources/st-xresources-20190105-3be4cf1.diff.html + +* Add doc strings for new functions +* Moved XOpenDisplay back into xinit +* Rename config_init to xresources_init and call it in xinit after + XOpenDisplay. + +Signed-off-by: Malcolm VanOrder <mvanorder1390@gmail.com> +--- + config.def.h | 36 +++++++++++++++++++++ + x.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++-- + 2 files changed, 124 insertions(+), 2 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 546edda..e1457af 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -150,6 +150,42 @@ static unsigned int mousebg = 0; + */ + static unsigned int defaultattr = 11; + ++/* ++ * Xresources preferences to load at startup ++ */ ++ResourcePref resources[] = { ++ { "font", STRING, &font }, ++ { "color0", STRING, &colorname[0] }, ++ { "color1", STRING, &colorname[1] }, ++ { "color2", STRING, &colorname[2] }, ++ { "color3", STRING, &colorname[3] }, ++ { "color4", STRING, &colorname[4] }, ++ { "color5", STRING, &colorname[5] }, ++ { "color6", STRING, &colorname[6] }, ++ { "color7", STRING, &colorname[7] }, ++ { "color8", STRING, &colorname[8] }, ++ { "color9", STRING, &colorname[9] }, ++ { "color10", STRING, &colorname[10] }, ++ { "color11", STRING, &colorname[11] }, ++ { "color12", STRING, &colorname[12] }, ++ { "color13", STRING, &colorname[13] }, ++ { "color14", STRING, &colorname[14] }, ++ { "color15", STRING, &colorname[15] }, ++ { "background", STRING, &colorname[256] }, ++ { "foreground", STRING, &colorname[257] }, ++ { "cursorColor", STRING, &colorname[258] }, ++ { "termname", STRING, &termname }, ++ { "shell", STRING, &shell }, ++ { "xfps", INTEGER, &xfps }, ++ { "actionfps", INTEGER, &actionfps }, ++ { "blinktimeout", INTEGER, &blinktimeout }, ++ { "bellvolume", INTEGER, &bellvolume }, ++ { "tabspaces", INTEGER, &tabspaces }, ++ { "borderpx", INTEGER, &borderpx }, ++ { "cwscale", FLOAT, &cwscale }, ++ { "chscale", FLOAT, &chscale }, ++}; ++ + /* + * Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set). + * Note that if you want to use ShiftMask with selmasks, set this to an other +diff --git a/x.c b/x.c +index 1f62129..8ccaf58 100644 +--- a/x.c ++++ b/x.c +@@ -14,6 +14,7 @@ + #include <X11/keysym.h> + #include <X11/Xft/Xft.h> + #include <X11/XKBlib.h> ++#include <X11/Xresource.h> + + static char *argv0; + #include "arg.h" +@@ -45,6 +46,19 @@ typedef struct { + signed char appcursor; /* application cursor */ + } Key; + ++/* Xresources preferences */ ++enum resource_type { ++ STRING = 0, ++ INTEGER = 1, ++ FLOAT = 2 ++}; ++ ++typedef struct { ++ char *name; ++ enum resource_type type; ++ void *dst; ++} ResourcePref; ++ + /* X modifiers */ + #define XK_ANY_MOD UINT_MAX + #define XK_NO_MOD 0 +@@ -813,8 +827,8 @@ xclear(int x1, int y1, int x2, int y2) + void + xhints(void) + { +- XClassHint class = {opt_name ? opt_name : termname, +- opt_class ? opt_class : termname}; ++ XClassHint class = {opt_name ? opt_name : "st", ++ opt_class ? opt_class : "St"}; + XWMHints wm = {.flags = InputHint, .input = 1}; + XSizeHints *sizeh; + +@@ -1081,6 +1095,77 @@ xicdestroy(XIC xim, XPointer client, XPointer call) + return 1; + } + ++/* ++ * Function: resource_load ++ * ----------------------- ++ * Load the value of a resource from the provided db ++ * ++ * db: XrmDatabase to load from ++ * name: name of the resource to load ++ * rtype: type for resource being loaded ++ * dst: pointer to destination for loaded value ++ * ++ * returns: 1 if no value returned or resource's type is not "String" ++ * 0 on success ++ */ ++int ++resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) ++{ ++ char **sdst = dst; ++ int *idst = dst; ++ float *fdst = dst; ++ ++ char fullname[256]; ++ char fullclass[256]; ++ char *type; ++ XrmValue ret; ++ ++ snprintf(fullname, sizeof(fullname), "%s.%s", ++ opt_name ? opt_name : "st", name); ++ snprintf(fullclass, sizeof(fullclass), "%s.%s", ++ opt_class ? opt_class : "St", name); ++ fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0'; ++ ++ XrmGetResource(db, fullname, fullclass, &type, &ret); ++ if (ret.addr == NULL || strncmp("String", type, 64)) ++ return 1; ++ ++ switch (rtype) { ++ case STRING: ++ *sdst = ret.addr; ++ break; ++ case INTEGER: ++ *idst = strtoul(ret.addr, NULL, 10); ++ break; ++ case FLOAT: ++ *fdst = strtof(ret.addr, NULL); ++ break; ++ } ++ return 0; ++} ++ ++/* ++ * Function: xresources_init ++ * ------------------------- ++ * Initializes xresources values defined in resources ++ */ ++void ++xresources_init(void) ++{ ++ char *resm; ++ XrmDatabase db; ++ ResourcePref *p; ++ ++ XrmInitialize(); ++ resm = XResourceManagerString(xw.dpy); ++ if (!resm) ++ return; ++ ++ db = XrmGetStringDatabase(resm); ++ for (p = resources; p < resources + LEN(resources); p++) ++ resource_load(db, p->name, p->type, p->dst); ++} ++ + void + xinit(int cols, int rows) + { +@@ -1092,6 +1177,7 @@ xinit(int cols, int rows) + + if (!(xw.dpy = XOpenDisplay(NULL))) + die("can't open display\n"); ++ xresources_init(); + xw.scr = XDefaultScreen(xw.dpy); + xw.vis = XDefaultVisual(xw.dpy, xw.scr); + +-- +2.25.0 +