diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-10-17 22:21:02 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-10-17 22:21:02 +0200 |
commit | 2b0976e93809291eaff0725a5c0772e00a450e2b (patch) | |
tree | 463e2477aabfb4fb5b1b87223d5d52d745ea2dd6 /nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | |
parent | 05cb09a5f9edff28466c736dd4601d17068d4c12 (diff) | |
parent | ffc2c3840466ed50abc35cba40fdc697e478ebd6 (diff) | |
download | nx-libs-2b0976e93809291eaff0725a5c0772e00a450e2b.tar.gz nx-libs-2b0976e93809291eaff0725a5c0772e00a450e2b.tar.bz2 nx-libs-2b0976e93809291eaff0725a5c0772e00a450e2b.zip |
Merge branch 'uli42-pr/fix_caps_handling' into 3.6.x
Attributes GH PR #937: https://github.com/ArcticaProject/nx-libs/pull/937
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Keyboard.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 233b6df74..14d811877 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -706,12 +706,54 @@ XkbError: { XkbGetControls(nxagentDisplay, XkbAllControlsMask, xkb); } -#ifdef TEST + #ifdef TEST else { fprintf(stderr, "%s: No current keyboard.\n", __func__); } -#endif + #endif + + #ifdef TEST + if (nxagentCapsLockKeycode != 0) + { + fprintf(stderr, "%s: Modifiers for CapsLock (%d): 0x%x\n", __func__, nxagentCapsLockKeycode, xkb->map->modmap[nxagentCapsLockKeycode]); + } + if (nxagentNumLockKeycode != 0) + { + fprintf(stderr, "%s: Modifiers for NumLock (%d): 0x%x\n", __func__, nxagentNumLockKeycode, xkb->map->modmap[nxagentNumLockKeycode]); + } + #endif + + /* Users can add options to their xkb setup. E.g. setxkbmap + * -option caps:ctrl_modifier makes CapsLock behave like the + * Ctrl key. As we have special treatment for CapsLock and + * NumLock to keep them in sync with the real X server we + * check if they are assigned to another modifier. In that + * case we disable the sync treatment by setting the according + * keycode to 0. + */ + if (xkb && xkb->map && xkb->map->modmap) + { + if (nxagentCapsLockKeycode != 0 && xkb->map->modmap[nxagentCapsLockKeycode] != LockMask) + { + nxagentCapsLockKeycode = 0; + #ifdef TEST + fprintf(stderr, "%s: CapsLock key is mapped to some other modifier - disabling special treatment\n", __func__); + #endif + } + + /* I have not found an xkb option definition for remapping + * NumLock. But users can still do that manually so let's be + * safe here. + */ + if (xkb->map->modmap[nxagentNumLockKeycode] != Mod2Mask) + { + nxagentNumLockKeycode = 0; + #ifdef TEST + fprintf(stderr, "%s: Numock key is mapped to some other modifier - disabling special treatment\n", __func__); + #endif + } + } #ifdef DEBUG fprintf(stderr, "%s: Going to set rules and init device: " |