Tk Source Code

Artifact [4e3484a3]
Login

Artifact 4e3484a30e28de7dc322bd96de7121beb19e450f:

Attachment "patch_tkUnixKey.c" to ticket [481308ff] added by tfengler 2001-11-13 21:53:34.
--- tkUnixKey.c.orig	Tue Nov 13 15:05:22 2001
+++ tkUnixKey.c	Tue Nov 13 14:58:53 2001
@@ -182,14 +182,27 @@
      */
 
     index = 0;
+
     if (eventPtr->xkey.state & dispPtr->modeModMask) {
 	index = 2;
+    } 
+    else if (eventPtr->xkey.state & dispPtr->numlockModMask) {
+      /* The "Numlockkey" in Sun Solaris has the same effect as the "Mode"-Key
+       * but only on the keys of the numerals pad
+       * When the "Numlockkey" is pressed, first get the keysym with index=2, 
+       * then test wether it is a keysym of the numerals pad. If it is not, 
+       * go back to index=0
+       */
+      index = 2;
+      sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, index);
+      if (sym < XK_KP_Multiply || sym > XK_KP_9)
+        index=0; 
     }
     if ((eventPtr->xkey.state & ShiftMask)
 	    || ((dispPtr->lockUsage != LU_IGNORE)
 	    && (eventPtr->xkey.state & LockMask))) {
 	index += 1;
-    }
+    }    
     sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, index);
 
     /*
@@ -287,6 +300,7 @@
     dispPtr->modeModMask = 0;
     dispPtr->metaModMask = 0;
     dispPtr->altModMask = 0;
+    dispPtr->numlockModMask = 0;
     codePtr = modMapPtr->modifiermap;
     max = 8*modMapPtr->max_keypermod;
     for (i = 0; i < max; i++, codePtr++) {
@@ -303,6 +317,13 @@
 	if ((keysym == XK_Alt_L) || (keysym == XK_Alt_R)) {
 	    dispPtr->altModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
 	}
+        /* The "Numlockkey" is needed in function TkpGetKeySym to split 
+         * keys from the numerals pad from other keys while the NumLock-Key 
+         * is pressed
+         */
+	if (keysym == XK_Num_Lock) {
+	    dispPtr->numlockModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
+        }
     }
 
     /*


--- tkInt.h.orig	Tue Nov 13 15:07:13 2001
+++ tkInt.h	Tue Nov 13 15:12:49 2001
@@ -129,6 +129,9 @@
     unsigned int altModMask;	/* Has one bit set to indicate the modifier
 				 * corresponding to the "Meta" key.  If no
 				 * such modifier, then this is zero. */
+    unsigned int numlockModMask;/* Has one bit set to indicate the modifier
+				 * corresponding to the "Numlock" key.  If no
+				 * such modifier, then this is zero. */
     enum {LU_IGNORE, LU_CAPS, LU_SHIFT} lockUsage;
 				/* Indicates how to interpret lock modifier. */
     int numModKeyCodes;		/* Number of entries in modKeyCodes array