Skip to content

Handle mod keys correctly #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@ tags
deb/
pkgs
debian/changelog.*
/PKGBUILD*
/gui-agent/qubes-gui
/gui-common/qubes-gui-runuser
/pkg/
*.tar.zst
/src/
/xf86-input-mfndev/compile
/xf86-input-mfndev/config.h.in
/xf86-input-mfndev/depcomp
/xf86-input-mfndev/ltmain.sh
/xf86-qubes-common/libxf86-qubes-common.so
25 changes: 16 additions & 9 deletions gui-agent/vmside.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <X11/Xutil.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/XInput2.h>
#include <X11/XKBlib.h>
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
Expand Down Expand Up @@ -1616,6 +1617,8 @@ static void handle_keypress(Ghandles * g, XID UNUSED(winid))
state.mods &= LockMask;
key.state &= LockMask;
}
bool is_press = key.type == KeyPress;
bool duplicate = false;
if (state.mods != key.state) {
XModifierKeymap *modmap;
int mod_index;
Expand All @@ -1636,7 +1639,8 @@ static void handle_keypress(Ghandles * g, XID UNUSED(winid))
// #define Mod4MapIndex 6
// #define Mod5MapIndex 7
for (mod_index = 0; mod_index < 8; mod_index++) {
if (modmap->modifiermap[mod_index*modmap->max_keypermod] == 0x00) {
uint32_t keycode = modmap->modifiermap[mod_index*modmap->max_keypermod];
if (keycode == 0x00) {
if (g->log_level > 1)
fprintf(stderr, "ignoring disabled modifier %d\n", mod_index);
// no key set for this modifier, ignore
Expand All @@ -1646,21 +1650,24 @@ static void handle_keypress(Ghandles * g, XID UNUSED(winid))
// special case for caps lock switch by press+release
if (mod_index == LockMapIndex) {
if ((state.mods & mod_mask) ^ (key.state & mod_mask)) {
feed_xdriver(g, 'K', modmap->modifiermap[mod_index*modmap->max_keypermod], 1);
feed_xdriver(g, 'K', modmap->modifiermap[mod_index*modmap->max_keypermod], 0);
feed_xdriver(g, 'K', keycode, 1);
feed_xdriver(g, 'K', keycode, 0);
}
} else {
if ((state.mods & mod_mask) && !(key.state & mod_mask))
feed_xdriver(g, 'K', modmap->modifiermap[mod_index*modmap->max_keypermod], 0);
else if (!(state.mods & mod_mask) && (key.state & mod_mask))
feed_xdriver(g, 'K', modmap->modifiermap[mod_index*modmap->max_keypermod], 1);
if ((state.mods & mod_mask) && !(key.state & mod_mask)) {
feed_xdriver(g, 'K', keycode, 0);
if (keycode == key.keycode && is_press == 0) duplicate = true;
}
else if (!(state.mods & mod_mask) && (key.state & mod_mask)) {
feed_xdriver(g, 'K', keycode, 1);
if (keycode == key.keycode && is_press == 1) duplicate = true;
}
}
}
XFreeModifiermap(modmap);
}
}

feed_xdriver(g, 'K', key.keycode, key.type == KeyPress ? 1 : 0);
if (!duplicate) feed_xdriver(g, 'K', key.keycode, is_press);
}

static void handle_button(Ghandles * g, XID winid)
Expand Down