diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-02-09 03:10:22 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-02-09 03:10:22 +0900 |
| commit | 36f7b343c714566d5bf931e768f0536a12d67c2f (patch) | |
| tree | 2040321e9984b1d8191f144f6b81f05f38acb8d7 /slock/patches/slock-passthrough-20240812-809d3c0.diff | |
| parent | 365403254a39ceac9797e430d4a62ec6c7b2f99c (diff) | |
updates
Diffstat (limited to 'slock/patches/slock-passthrough-20240812-809d3c0.diff')
| -rw-r--r-- | slock/patches/slock-passthrough-20240812-809d3c0.diff | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/slock/patches/slock-passthrough-20240812-809d3c0.diff b/slock/patches/slock-passthrough-20240812-809d3c0.diff new file mode 100644 index 0000000..bc4c2bc --- /dev/null +++ b/slock/patches/slock-passthrough-20240812-809d3c0.diff @@ -0,0 +1,104 @@ +From 809d3c01cfdc8c5bf7eb37e5d3ade59b0947cab3 Mon Sep 17 00:00:00 2001 +From: catboomer <catb00mer@proton.me> +Date: Mon, 12 Aug 2024 17:55:30 -0500 +Subject: [PATCH] [PATCH] passthrough: adds table to config.h to permit certain + keys to pass through slock + +--- + config.def.h | 15 +++++++++++++++ + slock.c | 28 +++++++++++++++++++++++++++- + 2 files changed, 42 insertions(+), 1 deletion(-) + +diff --git a/config.def.h b/config.def.h +index 9855e21..5b2ff78 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -10,3 +10,18 @@ static const char *colorname[NUMCOLS] = { + + /* treat a cleared input like a wrong password (color) */ + static const int failonclear = 1; ++ ++#include <X11/XF86keysym.h> ++ ++static const Passthrough passthroughs[] = { ++ /* Modifier Key */ ++ { 0, XF86XK_AudioRaiseVolume }, ++ { 0, XF86XK_AudioLowerVolume }, ++ { 0, XF86XK_AudioMute }, ++ { 0, XF86XK_AudioPause }, ++ { 0, XF86XK_AudioStop }, ++ { 0, XF86XK_AudioNext }, ++ { 0, XF86XK_AudioPrev }, ++ { 0, XF86XK_MonBrightnessUp }, ++ { 0, XF86XK_MonBrightnessDown }, ++}; +diff --git a/slock.c b/slock.c +index 5ae738c..522a226 100644 +--- a/slock.c ++++ b/slock.c +@@ -22,6 +22,11 @@ + #include "arg.h" + #include "util.h" + ++#include <X11/XF86keysym.h> ++#define LENGTH(X) (sizeof X / sizeof X[0]) ++#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) ++ ++static unsigned int numlockmask = 0; + char *argv0; + + enum { +@@ -31,6 +36,11 @@ enum { + NUMCOLS + }; + ++typedef struct { ++ unsigned int mod; ++ KeySym keysym; ++} Passthrough; ++ + struct lock { + int screen; + Window root, win; +@@ -130,7 +140,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, + { + XRRScreenChangeNotifyEvent *rre; + char buf[32], passwd[256], *inputhash; +- int num, screen, running, failure, oldc; ++ int num, screen, running, failure, oldc, i, passing; + unsigned int len, color; + KeySym ksym; + XEvent ev; +@@ -156,6 +166,20 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, + IsPFKey(ksym) || + IsPrivateKeypadKey(ksym)) + continue; ++ ++ passing = 0; ++ for (i = 0; i < LENGTH(passthroughs); i++) { ++ if (ksym == passthroughs[i].keysym && ++ CLEANMASK(passthroughs[i].mod) == CLEANMASK(ev.xkey.state)) { ++ passing = 1; ++ XSendEvent(dpy, DefaultRootWindow(dpy), True, KeyPressMask, &ev); ++ break; ++ } ++ } ++ ++ if(passing) ++ continue; ++ + switch (ksym) { + case XK_Return: + passwd[len] = '\0'; +@@ -184,6 +208,8 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, + (len + num < sizeof(passwd))) { + memcpy(passwd + len, buf, num); + len += num; ++ } else { ++ continue; /* Don't trigger fail screen when pressing control characters */ + } + break; + } +-- +2.46.0 + |
