Blob Blame History Raw
diff -up tigervnc-1.0.90-20100420svn4030/unix/xserver/hw/vnc/Input.cc.rh611677 tigervnc-1.0.90-20100420svn4030/unix/xserver/hw/vnc/Input.cc
--- tigervnc-1.0.90-20100420svn4030/unix/xserver/hw/vnc/Input.cc.rh611677	2010-08-24 17:40:00.511860227 +0200
+++ tigervnc-1.0.90-20100420svn4030/unix/xserver/hw/vnc/Input.cc	2010-08-24 17:49:23.169007409 +0200
@@ -322,6 +322,11 @@ public:
 			return;
 		}
 
+		if (maxKeysPerMod == 0) {
+			vlog.debug("Keyboard has no modifiers");
+			return;
+		}
+
 		keycode = modmap[modIndex * maxKeysPerMod];
 		xfree(modmap);
 #else
@@ -355,6 +360,11 @@ public:
 			vlog.error("generate_modkeymap failed");
 			return;
 		}
+
+		if (maxKeysPerMod == 0) {
+			vlog.debug("Keyboard has no modifiers");
+			return;
+		}
 #else
 		maxKeysPerMod = keyc->maxKeysPerModifier;
 #endif
@@ -530,6 +540,9 @@ void InputDevice::keyEvent(rdr::U32 keys
 		return;
 	}
 
+	if (maxKeysPerMod == 0)
+		vlog.debug("Keyboard has no modifiers");
+
 	state = XkbStateFieldFromRec(&keyc->xkbInfo->state);
 #else
 	keyc = keyboardDev->key;
@@ -565,11 +578,13 @@ void InputDevice::keyEvent(rdr::U32 keys
 ModeSwitchFound:
 
 	int col = 0;
-	if ((state & (1 << ShiftMapIndex)) != 0)
-		col |= 1;
-	if (modeSwitchMapIndex != 0 &&
-	    ((state & (1 << modeSwitchMapIndex))) != 0)
-		col |= 2;
+	if (maxKeysPerMod != 0) {
+		if ((state & (1 << ShiftMapIndex)) != 0)
+			col |= 1;
+		if (modeSwitchMapIndex != 0 &&
+		    ((state & (1 << modeSwitchMapIndex))) != 0)
+			col |= 2;
+	}
 
 	int kc = KeysymToKeycode(keymap, keysym, &col);
 
@@ -581,7 +596,8 @@ ModeSwitchFound:
 	 * We never get ISO_Left_Tab here because it's already been translated
 	 * in VNCSConnectionST.
 	 */
-	if (keysym == XK_Tab && ((state & (1 << ShiftMapIndex))) != 0)
+	if (maxKeysPerMod != 0 && keysym == XK_Tab &&
+	    ((state & (1 << ShiftMapIndex))) != 0)
 		col |= 1;
 
 	if (kc == 0) {
@@ -662,18 +678,20 @@ ModeSwitchFound:
 		}
 	}
 
-	ModifierState shift(keyboardDev, ShiftMapIndex);
-	ModifierState modeSwitch(keyboardDev, modeSwitchMapIndex);
-	if (down) {
-		if (col & 1)
-			shift.press();
-		else
-			shift.release();
-		if (modeSwitchMapIndex) {
-			if (col & 2)
-				modeSwitch.press();
+	if (maxKeysPerMod != 0) {
+		ModifierState shift(keyboardDev, ShiftMapIndex);
+		ModifierState modeSwitch(keyboardDev, modeSwitchMapIndex);
+		if (down) {
+			if (col & 1)
+				shift.press();
 			else
-				modeSwitch.release();
+				shift.release();
+			if (modeSwitchMapIndex) {
+				if (col & 2)
+					modeSwitch.press();
+				else
+					modeSwitch.release();
+			}
 		}
 	}