From e59188201b7e6eeaba95b196a21ba2ec1a374923 Mon Sep 17 00:00:00 2001 From: uint23 Date: Wed, 16 Apr 2025 12:21:40 +0100 Subject: added mask cleaning to accept all types of inputs --- src/defs.h | 3 ++- src/sxwm.c | 21 +++++++++++++++------ src/usercfg.h | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/defs.h b/src/defs.h index a09ba13..2046bc3 100644 --- a/src/defs.h +++ b/src/defs.h @@ -31,13 +31,14 @@ typedef struct { int is_func; } Binding; -typedef struct { +typedef struct Client{ Window id; int x, y; unsigned int w, h; unsigned int bw; Bool isfocused; Bool isfloating; + struct Client *next; } Client; #endif diff --git a/src/sxwm.c b/src/sxwm.c index 491d6b7..142697f 100644 --- a/src/sxwm.c +++ b/src/sxwm.c @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -23,6 +24,7 @@ typedef void (*EventHandler)(XEvent *); +static unsigned int clean_mask(unsigned int mask); static void hdl_dummy(XEvent *xev); static void hdl_config_req(XEvent *xev); static void hdl_destroy_ntf(XEvent *xev); @@ -46,10 +48,17 @@ static Window root; static unsigned long border_foc_col; static unsigned long border_ufoc_col; - +static unsigned int scr_width; +static unsigned int scr_height; #include "usercfg.h" +static unsigned int +clean_mask(unsigned int mask) +{ + return mask & ~(LockMask | Mod2Mask | Mod3Mask); +} + static void hdl_dummy(XEvent *xev) {} @@ -86,12 +95,12 @@ hdl_keypress(XEvent *xev) XKeyEvent *ev = &xev->xkey; unsigned int modifiers; - modifiers = ev->state; keysym = XkbKeycodeToKeysym(dpy, ev->keycode, 0, 0); + modifiers = clean_mask(ev->state); int lenbindings = sizeof(binds) / sizeof(binds[0]); for (int i = 0; i < lenbindings; ++i) { - if (keysym == binds[i].keysym && modifiers == binds[i].mods) { + if (keysym == binds[i].keysym && modifiers == clean_mask(binds[i].mods)) { if (binds[i].is_func) binds[i].action.fn(); else @@ -188,8 +197,7 @@ setup(void) root = XDefaultRootWindow(dpy); other_wm(); XSelectInput(dpy, root, - SubstructureRedirectMask | KeyPressMask | KeyReleaseMask - ); + SubstructureRedirectMask | SubstructureNotifyMask | KeyPressMask); for (int i = 0; i < LASTEvent; ++i) evtable[i] = hdl_dummy; @@ -202,7 +210,8 @@ setup(void) border_foc_col = parse_col(BORDER_FOC_COL); border_ufoc_col = parse_col(BORDER_UFOC_COL); -} + scr_width = XDisplayWidth(dpy, DefaultScreen(dpy)); + scr_height = XDisplayHeight(dpy, DefaultScreen(dpy)); } static void spawn(const char **cmd) diff --git a/src/usercfg.h b/src/usercfg.h index ea39c8e..457bc17 100644 --- a/src/usercfg.h +++ b/src/usercfg.h @@ -4,7 +4,7 @@ #include #include "defs.h" -#define BORDER_WIDTH 2 +#define BORDER_WIDTH 10 #define BORDER_FOC_COL "#00FF00" #define BORDER_UFOC_COL "#FF0000" -- cgit v1.2.3