summaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authoruint23 <[email protected]>2025-04-14 22:18:55 +0100
committeruint23 <[email protected]>2025-04-14 22:18:55 +0100
commit7883981fe9976b3933959c04fa8cc62158c70855 (patch)
tree0dbec9721c71c3f1e638a0bffc40cd18622077a1 /src/utils.c
parent54c9dd27d5674990ddc8d444f14336d549d52725 (diff)
inital window manager setup. check for other window managers too
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
new file mode 100644
index 0000000..c99e74c
--- /dev/null
+++ b/src/utils.c
@@ -0,0 +1,31 @@
+#include <err.h>
+#include <X11/Xlib.h>
+#include "util.h"
+
+void
+otherwm(void)
+{
+ XSetErrorHandler(otherwmerr);
+ XChangeWindowAttributes(dpy, root, CWEventMask,
+ &(XSetWindowAttributes){.event_mask = SubstructureRedirectMask});
+ XSync(dpy, False);
+ XSetErrorHandler(xerr);
+ XSync(dpy, False);
+}
+
+int
+otherwmerr(Display *dpy, XErrorEvent *ee)
+{
+ errx(0, "sxwm: another window manager is already running, please close it");
+ return 0;
+ if (dpy && ee) return 0;
+}
+
+int
+xerr(Display *dpy, XErrorEvent *ee)
+{
+ fprintf(stderr, "sxwm: fatal error\nrequest code:%d\nerror code:%d",
+ ee->request_code, ee->error_code);
+ return 0;
+ if (dpy && ee) return 0;
+}