changeset 3145:ed7353359a60

Updated parsing of keys
author unexist
date Mon, 28 Nov 2011 20:22:17 +0100
parents fac1753d273c
children 1e84040729c8
files src/shared/shared.c
diffstat 1 files changed, 11 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/shared/shared.c	Wed Nov 23 18:25:09 2011 +0100
+++ b/src/shared/shared.c	Mon Nov 28 20:22:17 2011 +0100
@@ -870,7 +870,6 @@
   unsigned int *state,
   int *mouse)
 {
-  int i;
   KeySym sym = NoSymbol;
   char *tokens = NULL, *tok = NULL, *save = NULL;
 
@@ -885,31 +884,21 @@
         {
           /* Unknown keys */
           case NoSymbol:
+            if('B' == tok[0])
               {
-                char button[4] = { 0 };
+                int buttonid = 0;
 
-                /* Check if it is a mouse button */
-                for(i = 1; i <= 20; i++)
-                  {
-                    snprintf(button, sizeof(button), "B%d", i);
+                sscanf(tok, "B%d", &buttonid);
 
-                    if(0 == strcmp(tok, button))
-                      {
-                        *mouse = True;
-                        *code  = XK_Pointer_Button1 + i - 1; ///< FIXME: Implementation independent?
-                        sym    = XK_Pointer_Button1;
+                *mouse = True;
+                *code  = XK_Pointer_Button1 + buttonid; ///< FIXME: Implementation independent?
+                sym    = XK_Pointer_Button1;
+              }
+            else
+              {
+                free(tokens);
 
-                        break;
-                      }
-                  }
-
-                /* Check if a symbol was found */
-                if(NoSymbol == sym)
-                  {
-                    free(tokens);
-
-                    return sym;
-                  }
+                return sym;
               }
             break;