shod

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit b4ca67d83b118432c9d217a7bd07e556bf80ae40
parent 142ca632da533954a7a06860268946bd6cbfa8c0
Author: Lucas de Sena <lucas@seninha.org>
Date:   Fri,  6 Jan 2023 10:09:40 -0300

select SubstructureRedirectMask'd events only once

With the addition of checkotherwm(), we are selecting the events
associated with the mask SubstructureRedirectMask twice: once at
checkotherwm() and another time at initroot().

At initroot(), however, we were doing more than just selecting
SubstructureRedirectMask events: we also select other events
and set the default cursor for the root window.  All in a single
XChangeWindowAttributes(3) call.

With this commit, the XChangeWindowAttributes(3) call is split into
a call to XDefineCursor(3) at initroot() to set the cursor, and a
XSelectInput(3) at checkotherwm() to select all events (including
the ones associated with SubstructureRedirectMask).

Diffstat:
Mshod.c | 16++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/shod.c b/shod.c @@ -12,6 +12,9 @@ #include "shod.h" #define WMNAME "shod" +#define ROOT_EVENTS (SubstructureRedirectMask | SubstructureNotifyMask \ + | StructureNotifyMask | ButtonPressMask \ + | PropertyChangeMask) static int (*xerrorxlib)(Display *, XErrorEvent *); volatile sig_atomic_t running = 1; @@ -191,14 +194,8 @@ initcursors(void) static void initroot(void) { - XSetWindowAttributes swa; - - /* Select SubstructureRedirect events on root window */ - swa.cursor = wm.cursors[CURSOR_NORMAL]; - swa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask - | StructureNotifyMask | ButtonPressMask - | PropertyChangeMask; - XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &swa); + /* change default cursor */ + XDefineCursor(dpy, root, wm.cursors[CURSOR_NORMAL]); /* Set focus to root window */ XSetInputFocus(dpy, root, RevertToParent, CurrentTime); @@ -281,8 +278,7 @@ static void checkotherwm(void) { xerrorxlib = XSetErrorHandler(xerrorstart); - /* this causes an error if some other window manager is running */ - XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask); + XSelectInput(dpy, root, ROOT_EVENTS); XSync(dpy, False); XSetErrorHandler(xerror); XSync(dpy, False);