From 7fd7f72d5d91aadf2992f7dd51e8f323854fcf11 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 20 Oct 2021 17:41:28 +0200 Subject: [PATCH] xresources: Questionable solution to allowing command line arguments to take precedence over xresources --- dmenu.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/dmenu.c b/dmenu.c index facf7f6..3e3c52e 100644 --- a/dmenu.c +++ b/dmenu.c @@ -1825,6 +1825,28 @@ main(int argc, char *argv[]) int fast = 0; #endif // NON_BLOCKING_STDIN_PATCH + #if XRESOURCES_PATCH + if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) + fputs("warning: no locale support\n", stderr); + if (!(dpy = XOpenDisplay(NULL))) + die("cannot open display"); + screen = DefaultScreen(dpy); + root = RootWindow(dpy, screen); + if (!embed || !(parentwin = strtol(embed, NULL, 0))) + parentwin = root; + if (!XGetWindowAttributes(dpy, parentwin, &wa)) + die("could not get embedding window attributes: 0x%lx", + parentwin); + + #if ALPHA_PATCH + xinitvisual(); + drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap); + #else + drw = drw_create(dpy, screen, root, wa.width, wa.height); + #endif // ALPHA_PATCH + readxresources(); + #endif // XRESOURCES_PATCH + for (i = 1; i < argc; i++) /* these options take no arguments */ if (!strcmp(argv[i], "-v")) { /* prints version information */ @@ -1990,6 +2012,15 @@ main(int argc, char *argv[]) else usage(); + #if XRESOURCES_PATCH + #if PANGO_PATCH + if (!drw_font_create(drw, font)) + die("no fonts could be loaded."); + #else + if (!drw_fontset_create(drw, (const char**)fonts, LENGTH(fonts))) + die("no fonts could be loaded."); + #endif // PANGO_PATCH + #else // !XRESOURCES_PATCH if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fputs("warning: no locale support\n", stderr); if (!(dpy = XOpenDisplay(NULL))) @@ -2008,22 +2039,16 @@ main(int argc, char *argv[]) #else drw = drw_create(dpy, screen, root, wa.width, wa.height); #endif // ALPHA_PATCH - #if XRESOURCES_PATCH - readxresources(); + #if PANGO_PATCH if (!drw_font_create(drw, font)) die("no fonts could be loaded."); #else - if (!drw_fontset_create(drw, (const char**)fonts, LENGTH(fonts))) - die("no fonts could be loaded."); - #endif // PANGO_PATCH - #elif PANGO_PATCH - if (!drw_font_create(drw, font)) - die("no fonts could be loaded."); - #else if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); - #endif // XRESOURCES_PATCH | PANGO_PATCH + #endif // PANGO_PATCH + #endif // XRESOURCES_PATCH + #if PANGO_PATCH lrpad = drw->font->h; #else