aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2020-09-29 15:20:46 +0200
committerOmar Polo <op@omarpolo.com>2020-09-29 15:27:21 +0200
commitfe0dcf4e2d945f528e2af9cbfc9d8eadb3b571bd (patch)
tree2774053bdffb66656fde872e77db19d57ff6b944
parente573cb09321087dc40dc088a53a9e079a31ecfe5 (diff)
downloadstar-platinum-fe0dcf4e2d945f528e2af9cbfc9d8eadb3b571bd.tar.gz
star-platinum-fe0dcf4e2d945f528e2af9cbfc9d8eadb3b571bd.tar.bz2
add an error handler
the default error handler violates the pledge "stdio" by trying to read (and possibly also write after) some files. Also, I don't like my program to be randomly killed if I try to get class hints on a window that doesn't have any.
-rw-r--r--star-platinum.c9
-rw-r--r--star-platinum.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/star-platinum.c b/star-platinum.c
index 9db19aa..4deaff2 100644
--- a/star-platinum.c
+++ b/star-platinum.c
@@ -161,6 +161,8 @@ main(int argc, char **argv)
return 1;
}
+ XSetErrorHandler(&error_handler);
+
root = DefaultRootWindow(d);
/* grab all the keys */
@@ -195,6 +197,13 @@ main(int argc, char **argv)
/* xlib */
+int
+error_handler(Display *d, XErrorEvent *e)
+{
+ fprintf(stderr, "Xlib error %d\n", e->type);
+ return 1;
+}
+
/* TODO: it should grab ALL POSSIBLE COMBINATIONS of `ignored_modifiers`! */
void
grabkey(struct key k)
diff --git a/star-platinum.h b/star-platinum.h
index 445302b..7949d62 100644
--- a/star-platinum.h
+++ b/star-platinum.h
@@ -83,6 +83,7 @@ void process_event(struct group*, XKeyEvent*);
int group_match(struct group*, Window);
/* xlib-related */
+int error_handler(Display*, XErrorEvent*);
void grabkey(struct key);
KeySym keycode_to_keysym(unsigned int);
Window focused_window();