From 2004b0cb9781330c54504c9404dfd69f7b7d1902 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 17 Nov 2021 21:59:08 +0500 Subject: [PATCH] Move xerror functions to "src/dwm/xerror.c" --- Makefile | 3 ++- src/dwm.c | 41 ++--------------------------------------- src/dwm/xerror.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/dwm/xerror.h | 8 ++++++++ 4 files changed, 52 insertions(+), 40 deletions(-) create mode 100644 src/dwm/xerror.c create mode 100644 src/dwm/xerror.h diff --git a/Makefile b/Makefile index 012c2c7..be7fe3f 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,8 @@ DWM_SRC = \ src/dwm/handlers.c \ src/dwm/layouts.c \ src/dwm/swallow.c \ - src/dwm/systray.c + src/dwm/systray.c \ + src/dwm/xerror.c MODULES_HDR = $(MODULES_SRC:.c=.h) DWM_HDR = $(DWM_SRC:.c=.h) diff --git a/src/dwm.c b/src/dwm.c index b3bfeb8..2745a5a 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -278,15 +278,13 @@ static void view(const Arg *arg); static void viewrel(const Arg *arg); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); -static int xerror(Display *dpy, XErrorEvent *ee); -static int xerrordummy(Display *dpy, XErrorEvent *ee); -static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); #include "dwm/handlers.h" #include "dwm/layouts.h" #include "dwm/swallow.h" #include "dwm/systray.h" +#include "dwm/xerror.h" /************* * variables * @@ -342,6 +340,7 @@ static xcb_connection_t *xcon; #include "dwm/layouts.c" #include "dwm/swallow.c" #include "dwm/systray.c" +#include "dwm/xerror.c" int main(int argc, char *argv[]) @@ -2419,42 +2418,6 @@ wintomon(Window w) return selmon; } -/* There's no way to check accesses to destroyed windows, thus those cases are - * ignored (especially on UnmapNotify's). Other types of errors call Xlibs - * default error handler, which may call exit. */ -int -xerror(Display *dpy, XErrorEvent *ee) -{ - if (ee->error_code == BadWindow - || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) - || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) - || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable) - || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) - || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) - || (ee->request_code == X_GrabButton && ee->error_code == BadAccess) - || (ee->request_code == X_GrabKey && ee->error_code == BadAccess) - || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)) - return 0; - fprintf(stderr, "polytreewm: fatal error: request code=%d, error code=%d\n", - ee->request_code, ee->error_code); - return xerrorxlib(dpy, ee); /* may call exit */ -} - -int -xerrordummy(Display *dpy, XErrorEvent *ee) -{ - return 0; -} - -/* Startup Error handler to check if another window manager - * is already running. */ -int -xerrorstart(Display *dpy, XErrorEvent *ee) -{ - die("polytreewm: another window manager is already running"); - return -1; -} - void zoom(const Arg *arg) { diff --git a/src/dwm/xerror.c b/src/dwm/xerror.c new file mode 100644 index 0000000..44bed8e --- /dev/null +++ b/src/dwm/xerror.c @@ -0,0 +1,40 @@ +#ifndef _DWM_XERROR_C +#define _DWM_XERROR_C + +/* There's no way to check accesses to destroyed windows, thus those cases are + * ignored (especially on UnmapNotify's). Other types of errors call Xlibs + * default error handler, which may call exit. */ +int +xerror(Display *dpy, XErrorEvent *ee) +{ + if (ee->error_code == BadWindow + || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) + || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) + || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable) + || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) + || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) + || (ee->request_code == X_GrabButton && ee->error_code == BadAccess) + || (ee->request_code == X_GrabKey && ee->error_code == BadAccess) + || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)) + return 0; + fprintf(stderr, "polytreewm: fatal error: request code=%d, error code=%d\n", + ee->request_code, ee->error_code); + return xerrorxlib(dpy, ee); /* may call exit */ +} + +int +xerrordummy(Display *dpy, XErrorEvent *ee) +{ + return 0; +} + +/* Startup Error handler to check if another window manager + * is already running. */ +int +xerrorstart(Display *dpy, XErrorEvent *ee) +{ + die("polytreewm: another window manager is already running"); + return -1; +} + +#endif // _DWM_XERROR_C diff --git a/src/dwm/xerror.h b/src/dwm/xerror.h new file mode 100644 index 0000000..df6040c --- /dev/null +++ b/src/dwm/xerror.h @@ -0,0 +1,8 @@ +#ifndef _DWM_XERROR_H +#define _DWM_XERROR_H + +static int xerror(Display *dpy, XErrorEvent *ee); +static int xerrordummy(Display *dpy, XErrorEvent *ee); +static int xerrorstart(Display *dpy, XErrorEvent *ee); + +#endif // _DWM_XERROR_H