[X2Go-Commits] [nx-libs] 18/51: Keyboard.c: refactor keycode conversion

git-admin at x2go.org git-admin at x2go.org
Fri Feb 8 05:40:05 CET 2019


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

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

commit 269a352ff493f2f41e81afa5485dec39d2d5dbf4
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Sat Jul 22 18:56:13 2017 +0200

    Keyboard.c: refactor keycode conversion
    
    we'll need the remote xkb in KeyboardProc in future so let's move it up.
---
 nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 94 ++++++++++++++++-----------
 1 file changed, 56 insertions(+), 38 deletions(-)

diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
index 0b4e269..3410e09 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -81,7 +81,7 @@ is" without express or implied warranty.
 static int nxagentXkbGetNames(char **rules, char **model, char **layout,
                                   char **variant, char **options);
 
-static void nxagentKeycodeConversionSetup(void);
+static void nxagentKeycodeConversionSetup(char *rules, char *model);
 
 void nxagentWriteKeyboardFile(unsigned int ruleslen, char *rules, char *model, char *layout, char *variant, char *options);
 
@@ -818,9 +818,38 @@ XkbError:
         fprintf(stderr, "nxagentKeyboardProc: Init XKB extension.\n");
         #endif
 
-        xkb = XkbGetKeyboard(nxagentDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd);
+        {
+          char *drules = NULL;
+          char *dmodel = NULL;
+          char *dlayout = NULL;
+          char *dvariant = NULL;
+          char *doptions = NULL;
+
+          unsigned int drulesLen = nxagentXkbGetNames(&drules, &dmodel, &dlayout,
+                                                      &dvariant, &doptions);
+
+          #ifdef DEBUG
+          if (drulesLen && drules && dmodel)
+          {
+            fprintf(stderr, "%s: Remote: [rules='%s',model='%s',layout='%s',variant='%s',options='%s'].\n",
+                    __func__, drules, dmodel, dlayout, dvariant, doptions);
+          }
+          else
+          {
+            fprintf(stderr, "%s: Failed to retrieve remote rules.\n", __func__);
+          }
+          #endif
 
-        nxagentKeycodeConversionSetup();
+          nxagentWriteKeyboardFile(drulesLen, drules, dmodel, dlayout, dvariant, doptions);
+          nxagentKeycodeConversionSetup(drules, dmodel);
+
+          if (drules)
+          {
+            XFree(drules);
+          }
+        }
+
+        xkb = XkbGetKeyboard(nxagentDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd);
 
         if (xkb && xkb->geom)
         {
@@ -1609,15 +1638,8 @@ void nxagentWriteKeyboardFile(unsigned int ruleslen, char *rules, char *model, c
   }
 }
 
-void nxagentKeycodeConversionSetup(void)
+void nxagentKeycodeConversionSetup(char * rules, char * model)
 {
-  char *drules = NULL;
-  char *dmodel = NULL;
-  char *dlayout = NULL;
-  char *dvariant = NULL;
-  char *doptions = NULL;
-  unsigned int drulesLen;
-
   if (nxagentOption(KeycodeConversion) == KeycodeConversionOff)
   {
     fprintf(stderr, "Info: Keycode conversion is off\n");
@@ -1631,28 +1653,9 @@ void nxagentKeycodeConversionSetup(void)
     return;
   }
 
-  nxagentKeycodeConversion = False;
-
-  drulesLen = nxagentXkbGetNames(&drules, &dmodel, &dlayout,
-                                     &dvariant, &doptions);
-
-  #ifdef DEBUG
-  if (drulesLen != 0 && drules && dmodel)
-  {
-    fprintf(stderr, "%s: Remote: [rules='%s',model='%s',layout='%s',variant='%s',options='%s'].\n",
-            __func__, drules, dmodel, dlayout, dvariant, doptions);
-  }
-  else
-  {
-    fprintf(stderr, "%s: Failed to retrieve remote rules.\n", __func__);
-  }
-  #endif
-
-  nxagentWriteKeyboardFile(drulesLen, drules, dmodel, dlayout, dvariant, doptions);
-
-  if (drules && dmodel &&
-      (strcmp(drules, "evdev") == 0 ||
-       strcmp(dmodel, "evdev") == 0))
+  if (rules && model &&
+      (strcmp(rules, "evdev") == 0 ||
+       strcmp(model, "evdev") == 0))
   {
     #ifdef DEBUG
     fprintf(stderr, "%s: Activating KeyCode conversion.\n", __func__);
@@ -1663,12 +1666,13 @@ void nxagentKeycodeConversionSetup(void)
   }
   else
   {
+    #ifdef DEBUG
+    fprintf(stderr, "%s: Deactivating KeyCode conversion.\n", __func__);
+    #endif
+
     fprintf(stderr, "Info: Keycode conversion auto-determined as off\n");
-  }
 
-  if (drules)
-  {
-    XFree(drules);
+    nxagentKeycodeConversion = False;
   }
 }
 
@@ -1683,7 +1687,21 @@ void nxagentResetKeycodeConversion(void)
 
   if (result != 0)
   {
-    nxagentKeycodeConversionSetup();
+    char *drules = NULL;
+    char *dmodel = NULL;
+    char *dlayout = NULL;
+    char *dvariant = NULL;
+    char *doptions = NULL;
+    unsigned int drulesLen;
+
+    drulesLen = nxagentXkbGetNames(&drules, &dmodel, &dlayout,
+                                   &dvariant, &doptions);
+
+    if (drulesLen && drules && dmodel)
+      nxagentKeycodeConversionSetup(drules, dmodel);
+
+    if (drules)
+      XFree(drules);
   }
   else
   {

--
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