From 96b82dc2232b71a2c7f73a00a8cc341d3a527552 Mon Sep 17 00:00:00 2001 From: speedie Date: Tue, 23 May 2023 22:31:33 +0200 Subject: [PATCH] actually changed my mind for a bit --- libs/x11/inc.c | 1 - libs/x11/inc.h | 1 - libs/x11/init.c | 9 +++++++++ libs/x11/init.h | 2 ++ libs/x11/mod.c | 17 ----------------- libs/x11/mod.h | 4 ---- spmenu.c | 13 ++++++------- 7 files changed, 17 insertions(+), 30 deletions(-) delete mode 100644 libs/x11/mod.c delete mode 100644 libs/x11/mod.h diff --git a/libs/x11/inc.c b/libs/x11/inc.c index 817422e..00fb203 100644 --- a/libs/x11/inc.c +++ b/libs/x11/inc.c @@ -7,4 +7,3 @@ #include "client.h" #include "client.c" #include "init.c" -#include "mod.c" diff --git a/libs/x11/inc.h b/libs/x11/inc.h index 95694ef..b17c739 100644 --- a/libs/x11/inc.h +++ b/libs/x11/inc.h @@ -2,7 +2,6 @@ #include "lib.h" #include "init.h" -#include "mod.h" #include "xrdb.h" #include "xim.h" #include "key.h" diff --git a/libs/x11/init.c b/libs/x11/init.c index add194e..34a44a5 100644 --- a/libs/x11/init.c +++ b/libs/x11/init.c @@ -138,3 +138,12 @@ void setupdisplay(void) { match(); drawmenu(); } + +Display * opendisplay(char *disp) { + return XOpenDisplay(disp); +} + +void set_screen(Display *disp) { + screen = DefaultScreen(disp); + root = RootWindow(disp, screen); +} diff --git a/libs/x11/init.h b/libs/x11/init.h index f67f5c3..0bd22b9 100644 --- a/libs/x11/init.h +++ b/libs/x11/init.h @@ -5,3 +5,5 @@ static Display *dpy; static Window root, parentwin, win; static void setupdisplay(void); +static void set_screen(Display *disp); +static Display * opendisplay(char *disp); diff --git a/libs/x11/mod.c b/libs/x11/mod.c deleted file mode 100644 index ffce2f0..0000000 --- a/libs/x11/mod.c +++ /dev/null @@ -1,17 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -int get_locale(char *modifier_list) { - if (XSetLocaleModifiers(modifier_list)) { - return 0; - } else { - return 1; - } -} - -int supports_locale() { - if (XSupportsLocale()) { - return 0; - } else { - return 1; - } -} diff --git a/libs/x11/mod.h b/libs/x11/mod.h deleted file mode 100644 index 312e68e..0000000 --- a/libs/x11/mod.h +++ /dev/null @@ -1,4 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -static int get_locale(char *modifier_list); -static int supports_locale(); diff --git a/spmenu.c b/spmenu.c index e1d451a..639aa7d 100644 --- a/spmenu.c +++ b/spmenu.c @@ -534,26 +534,25 @@ int main(int argc, char *argv[]) { strcpy(modetext, normtext); } - if (!setlocale(LC_CTYPE, "") || !supports_locale()) + if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fputs("warning: no locale support\n", stderr); // invalid locale, so notify the user about it - if (!get_locale("")) { + if (!XSetLocaleModifiers("")) fputs("warning: no locale modifiers support\n", stderr); - } - if (!(dpy = XOpenDisplay(NULL))) + if (!(dpy = opendisplay(NULL))) die("spmenu: cannot open display"); // failed to open display // set screen and root window - screen = DefaultScreen(dpy); - root = RootWindow(dpy, screen); + set_screen(dpy); // parent window is the root window (ie. window manager) because we're not embedding if (!embed || !(parentwin = strtol(embed, NULL, 0))) parentwin = root; - if (!XGetWindowAttributes(dpy, parentwin, &wa)) + if (!XGetWindowAttributes(dpy, parentwin, &wa)) { die("spmenu: could not get embedding window attributes: 0x%lx", parentwin); + } xinitvisual(); // init visual and create drawable after drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap); // wrapper function creating a drawable