summaryrefslogtreecommitdiff
path: root/src/sxwm.c
diff options
context:
space:
mode:
authoruint23 <[email protected]>2025-04-16 12:21:40 +0100
committeruint23 <[email protected]>2025-04-16 12:21:40 +0100
commite59188201b7e6eeaba95b196a21ba2ec1a374923 (patch)
treec19dbd73f66727d849ff5dfd5dbf9078400ee737 /src/sxwm.c
parentdc3b91874677ebb2b0f6ec517b2dce661a92f2fe (diff)
added mask cleaning to accept all types of inputs
Diffstat (limited to 'src/sxwm.c')
-rw-r--r--src/sxwm.c21
1 files changed, 15 insertions, 6 deletions
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 <err.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -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)