[X2Go-Commits] [nx-libs] 17/429: Keyboard.c: improve capslock and numlock handling

git-admin at x2go.org git-admin at x2go.org
Mon Oct 18 09:36:00 CEST 2021


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch 3.6.x
in repository nx-libs.

commit ffc2c3840466ed50abc35cba40fdc697e478ebd6
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Fri Jun 19 00:18:34 2020 +0200

    Keyboard.c: improve capslock and numlock handling
    
    Fixes ArcticaProject/nx-libs#935
---
 nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 42 +++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
index 48ab721f5..14d811877 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -713,6 +713,48 @@ XkbError:
         }
         #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: "
                         "[rules='%s',model='%s',layout='%s',variant='%s',options='%s'].\n", __func__,

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git


More information about the x2go-commits mailing list