From e674a2da7e56fe4b23fee2229d8c12379f640133 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 5 Dec 2021 19:55:22 +0500 Subject: [PATCH] Move bar code to "src/dwm/bar.h" --- Makefile | 1 + src/dwm.c | 38 ++------------------------------------ src/dwm/bar.c | 34 ++++++++++++++++++++++++++++++++++ src/dwm/bar.h | 6 ++++++ 4 files changed, 43 insertions(+), 36 deletions(-) create mode 100644 src/dwm/bar.c create mode 100644 src/dwm/bar.h diff --git a/Makefile b/Makefile index bf4842c..b235b72 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,7 @@ MODULES_SRC = \ src/xbase.c DWM_SRC = \ + src/dwm/bar.c \ src/dwm/handlers.c \ src/dwm/layouts.c \ src/dwm/xerror.c diff --git a/src/dwm.c b/src/dwm.c index 28ec40f..10dce97 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -210,13 +210,13 @@ static void updatesizehints(Client *c); static void updatetitle(Client *c); static void updatewindowtype(Client *c); static void updatewmhints(Client *c); -static bool winpolybar(Window w); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); static void wmcheckwin_create(); static void wmcheckwin_destroy(); static void zoom(const Arg *arg); +#include "dwm/bar.h" #include "dwm/handlers.h" #include "dwm/layouts.h" #include "dwm/xerror.h" @@ -334,6 +334,7 @@ static Button buttons[] = { * Private function implementations * ************************************/ +#include "dwm/bar.c" #include "dwm/handlers.c" #include "dwm/layouts.c" #include "dwm/xerror.c" @@ -2318,41 +2319,6 @@ Client *wintoclient(Window w) return NULL; } -bool winpolybar(const Window w) -{ - XClassHint ch = { NULL, NULL }; - bool result = true; - - if (XGetClassHint(xbase->x_display, w, &ch)) { - if ( - ch.res_class - && - strstr(ch.res_class, "Polybar") == NULL - && - strstr(ch.res_class, "polybar") == NULL - ) { - result = false; - } - - if ( - ch.res_name - && - strstr(ch.res_name, "Polybar") == NULL - && - strstr(ch.res_name, "polybar") == NULL - ) { - result = false; - } - } else { - result = false; - } - - if (ch.res_class) XFree(ch.res_class); - if (ch.res_name) XFree(ch.res_name); - - return result; -} - Monitor *wintomon(Window w) { { diff --git a/src/dwm/bar.c b/src/dwm/bar.c new file mode 100644 index 0000000..a67f2fb --- /dev/null +++ b/src/dwm/bar.c @@ -0,0 +1,34 @@ +bool winpolybar(const Window w) +{ + XClassHint ch = { NULL, NULL }; + bool result = true; + + if (XGetClassHint(xbase->x_display, w, &ch)) { + if ( + ch.res_class + && + strstr(ch.res_class, "Polybar") == NULL + && + strstr(ch.res_class, "polybar") == NULL + ) { + result = false; + } + + if ( + ch.res_name + && + strstr(ch.res_name, "Polybar") == NULL + && + strstr(ch.res_name, "polybar") == NULL + ) { + result = false; + } + } else { + result = false; + } + + if (ch.res_class) XFree(ch.res_class); + if (ch.res_name) XFree(ch.res_name); + + return result; +} diff --git a/src/dwm/bar.h b/src/dwm/bar.h new file mode 100644 index 0000000..6a2d875 --- /dev/null +++ b/src/dwm/bar.h @@ -0,0 +1,6 @@ +#ifndef _DWM_BAR_H +#define _DWM_BAR_H + +static bool winpolybar(Window w); + +#endif // _DWM_BAR_H