Introduction
Introduction Statistics Contact Development Disclaimer Help
allow neutralizing a key modifier by applying the same modifier again - svkbd -…
git clone git://git.suckless.org/svkbd
Log
Files
Refs
README
LICENSE
---
commit 42380f62ebebefc94eb986343d6d91b1b6106ed5
parent b25e55e4622d419f252570d15080cdd2628b9236
Author: Max Schillinger <[email protected]>
Date: Sun, 13 Jun 2021 22:27:57 +0200
allow neutralizing a key modifier by applying the same modifier again
svkbd allows you to create keys for symbols of the second (=shift) layer by def…
{ "|", "|", XK_backslash, 1, XK_Shift_L },
This key creates a pipe symbol by sending shift + backslash. But unfortunately,…
The appended patch fixes this by allowing to neutralize the shift by tapping th…
This way you can create a "flipped" backslash/pipe key:
{ "|", "\\", XK_backslash, 1, XK_Shift_L },
This patch works equally for AltGr symbols in a `de`-based layout. For example:
{ "~", "+", XK_plus, 1, XK_ISO_Level3_Shift },
(In the German QWERTZ layout, you enter "~" with AltGr-"+".)
Best regards,
Max
Signed-off-by: Maarten van Gompel <[email protected]>
Diffstat:
M svkbd.c | 36 ++++++++++++++++++++---------…
1 file changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/svkbd.c b/svkbd.c
@@ -198,16 +198,19 @@ buttonpress(XEvent *e)
if (!(k = findkey(ev->x, ev->y)))
return;
- if (k->modifier) {
- mod = k->modifier;
- } else {
- for (i = 0; i < LENGTH(buttonmods); i++) {
- if (ev->button == buttonmods[i].button) {
- mod = buttonmods[i].mod;
- break;
- }
+ for (i = 0; i < LENGTH(buttonmods); i++) {
+ if (ev->button == buttonmods[i].button) {
+ mod = buttonmods[i].mod;
+ break;
}
}
+
+ if (k->modifier) {
+ if (mod == k->modifier)
+ mod = 0;
+ else
+ mod = k->modifier;
+ }
press(k, mod);
}
@@ -231,7 +234,9 @@ buttonrelease(XEvent *e)
if (ev->x < 0 || ev->y < 0) {
unpress(NULL, mod);
} else if ((k = findkey(ev->x, ev->y))) {
- if (k->modifier)
+ if (k->modifier == mod)
+ unpress(k, 0);
+ else if (k->modifier)
unpress(k, k->modifier);
else
unpress(k, mod);
@@ -564,6 +569,7 @@ void
unpress(Key *k, KeySym buttonmod)
{
int i;
+ Bool neutralizebuttonmod = False;
if (k != NULL) {
switch(k->keysym) {
@@ -589,10 +595,13 @@ unpress(Key *k, KeySym buttonmod)
/* simulate the press event, as we postponed it earlier in pre…
for (i = 0; i < numkeys; i++) {
if (keys[i].pressed && IsModifierKey(keys[i].keysym)) {
- simulate_keypress(keys[i].keysym);
+ if (keys[i].keysym == buttonmod)
+ neutralizebuttonmod = True;
+ else
+ simulate_keypress(keys[i].keysym);
}
}
- if (buttonmod) {
+ if (buttonmod && !neutralizebuttonmod) {
simulate_keypress(buttonmod);
}
simulate_keypress(k->keysym);
@@ -615,14 +624,15 @@ unpress(Key *k, KeySym buttonmod)
}
}
- if (buttonmod) {
+ if (buttonmod && !neutralizebuttonmod) {
simulate_keyrelease(buttonmod);
}
if ((k == NULL) || (!IsModifierKey(k->keysym))) {
for (i = 0; i < numkeys; i++) {
if (keys[i].pressed && IsModifierKey(keys[i].keysym)) {
- simulate_keyrelease(keys[i].keysym);
+ if (!(keys[i].keysym == buttonmod && neutraliz…
+ simulate_keyrelease(keys[i].keysym);
keys[i].pressed = 0;
drawkey(&keys[i]);
}
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.