diff --git a/xorg-server-xf4vnc-bug605015-fix-keyboard-handling-xinput.diff b/xorg-server-xf4vnc-bug605015-fix-keyboard-handling-xinput.diff new file mode 100644 index 0000000..fa45b33 --- /dev/null +++ b/xorg-server-xf4vnc-bug605015-fix-keyboard-handling-xinput.diff @@ -0,0 +1,117 @@ +This patch fixes keyboard handling for XInput enabled servers. W/o this patch +the wrong keyboard was used for adding new KeyCodes. + +This should basically already enable the use of other keyboards, if the remote +keyboard stays at US. + +mhopf - 21/04/2011 + +Index: xorg-server-1.9.3/hw/vnc/kbdptr.c +=================================================================== +--- xorg-server-1.9.3.orig/hw/vnc/kbdptr.c ++++ xorg-server-1.9.3/hw/vnc/kbdptr.c +@@ -46,19 +46,17 @@ + #endif + + #define KEY_IS_PRESSED(keycode) \ +- (kbdDevice->key->down[(keycode) >> 3] & (1 << ((keycode) & 7))) ++ (inputInfo.keyboard->key->down[(keycode) >> 3] & (1 << ((keycode) & 7))) + + static void vncXConvertCase(KeySym sym, KeySym *lower, KeySym *upper); + +-static DeviceIntPtr ptrDevice = NULL, kbdDevice = NULL; ++static DeviceIntPtr ptrDevice = NULL; + + + void + vncSetKeyboardDevice(DeviceIntPtr kbd) + { +- if (kbdDevice && kbd) +- return; /* set once */ +- kbdDevice = kbd; ++ // obsoleted by inputInfo + } + + +@@ -145,10 +143,7 @@ KbdAddEvent(Bool down, KeySym keySym, rf + Bool shiftMustBeReleased = FALSE; + Bool shiftMustBePressed = FALSE; + +- if (!kbdDevice) +- return; +- +- keySyms = XkbGetCoreMap(kbdDevice); ++ keySyms = XkbGetCoreMap(inputInfo.keyboard); + + #ifdef CORBA + if (cl) { +@@ -259,40 +254,40 @@ KbdAddEvent(Bool down, KeySym keySym, rf + shiftMustBePressed = TRUE; + } + +- XkbApplyMappingChange(kbdDevice, keySyms, keyCode, 1, NULL, serverClient); ++ XkbApplyMappingChange(inputInfo.keyboard, keySyms, keyCode, 1, NULL, serverClient); + + ErrorF("KbdAddEvent: unknown KeySym 0x%x - allocating KeyCode %d\n", + (int)keySym, keyCode); + } + +- xkb = &kbdDevice->key->xkbInfo->state; ++ xkb = &inputInfo.keyboard->key->xkbInfo->state; + if (down) { + if (shiftMustBePressed && !(XkbStateFieldFromRec(xkb) & ShiftMask)) { + fakeShiftPress = TRUE; +- EnqueueKey(kbdDevice, KeyPress, SHIFT_L_KEY_CODE); ++ EnqueueKey(inputInfo.keyboard, KeyPress, SHIFT_L_KEY_CODE); + } + if (shiftMustBeReleased && (XkbStateFieldFromRec(xkb) & ShiftMask)) { + if (KEY_IS_PRESSED(SHIFT_L_KEY_CODE)) { + fakeShiftLRelease = TRUE; +- EnqueueKey(kbdDevice, KeyRelease, SHIFT_L_KEY_CODE); ++ EnqueueKey(inputInfo.keyboard, KeyRelease, SHIFT_L_KEY_CODE); + } + if (KEY_IS_PRESSED(SHIFT_R_KEY_CODE)) { + fakeShiftRRelease = TRUE; +- EnqueueKey(kbdDevice, KeyRelease, SHIFT_R_KEY_CODE); ++ EnqueueKey(inputInfo.keyboard, KeyRelease, SHIFT_R_KEY_CODE); + } + } + } + +- EnqueueKey(kbdDevice, type, keyCode); ++ EnqueueKey(inputInfo.keyboard, type, keyCode); + + if (fakeShiftPress) { +- EnqueueKey(kbdDevice, KeyRelease, SHIFT_L_KEY_CODE); ++ EnqueueKey(inputInfo.keyboard, KeyRelease, SHIFT_L_KEY_CODE); + } + if (fakeShiftLRelease) { +- EnqueueKey(kbdDevice, KeyPress, SHIFT_L_KEY_CODE); ++ EnqueueKey(inputInfo.keyboard, KeyPress, SHIFT_L_KEY_CODE); + } + if (fakeShiftRRelease) { +- EnqueueKey(kbdDevice, KeyPress, SHIFT_R_KEY_CODE); ++ EnqueueKey(inputInfo.keyboard, KeyPress, SHIFT_R_KEY_CODE); + } + } + +@@ -343,15 +338,15 @@ KbdReleaseAllKeys(void) + { + int i, j; + +- if (!kbdDevice) ++ if (!inputInfo.keyboard) + return; + + for (i = 0; i < DOWN_LENGTH; i++) { +- if (kbdDevice->key->down[i] != 0) { ++ if (inputInfo.keyboard->key->down[i] != 0) { + for (j = 0; j < 8; j++) { +- if (kbdDevice->key->down[i] & (1 << j)) { ++ if (inputInfo.keyboard->key->down[i] & (1 << j)) { + int detail = (i << 3) | j; +- EnqueueKey(kbdDevice, KeyRelease, detail); ++ EnqueueKey(inputInfo.keyboard, KeyRelease, detail); + } + } + } diff --git a/xorg-server-xf4vnc-bug605015-fix-keycode-lookup-and-isolevel3shift.diff b/xorg-server-xf4vnc-bug605015-fix-keycode-lookup-and-isolevel3shift.diff new file mode 100644 index 0000000..48b6419 --- /dev/null +++ b/xorg-server-xf4vnc-bug605015-fix-keycode-lookup-and-isolevel3shift.diff @@ -0,0 +1,131 @@ +This patch fixes keycode lookup (not using any static keyboard layout any more) +and ISO-Level3-Shift handling (enabling the use of keyboard layouts that use +AltGr for reaching certain characters). + +Note that the implementation is still imperfect. Keyboard layouts that use a +different key than AltGr for ISO-Level3-Shift will show some weird behavior. +Mode_Switch is also not supported, so keyboard switching via Mode_Switch might +not work as intended either. Suggesting the use of input methods in these cases +(they will hopefully work). + +mhopf - 21/04/2011 + +Index: xorg-server-1.9.3/hw/vnc/kbdptr.c +=================================================================== +--- xorg-server-1.9.3.orig/hw/vnc/kbdptr.c ++++ xorg-server-1.9.3/hw/vnc/kbdptr.c +@@ -142,6 +142,10 @@ KbdAddEvent(Bool down, KeySym keySym, rf + Bool fakeShiftRRelease = FALSE; + Bool shiftMustBeReleased = FALSE; + Bool shiftMustBePressed = FALSE; ++ Bool fakeLevel3Press = FALSE; ++ Bool fakeLevel3Release = FALSE; ++ Bool level3MustBeReleased = FALSE; ++ Bool level3MustBePressed = FALSE; + + keySyms = XkbGetCoreMap(inputInfo.keyboard); + +@@ -161,6 +165,12 @@ KbdAddEvent(Bool down, KeySym keySym, rf + * + * Alan. + */ ++ /* Never use predefined keys. ++ * This is inherently incapable of dealing with changing ++ * keyboard layouts. Not being able to work with non-local xmodmaps ++ * is a nuisance at worst, and probably even preferred. ++ * 2011-04-15 mhopf@suse.de */ ++#if 0 + #if !XFREE86VNC + /* First check if it's one of our predefined keys. If so then we can make + some attempt at allowing an xmodmap inside a VNC desktop behave +@@ -187,6 +197,7 @@ KbdAddEvent(Bool down, KeySym keySym, rf + } + } + #endif ++#endif + + if (!keyCode) { + +@@ -201,18 +212,27 @@ KbdAddEvent(Bool down, KeySym keySym, rf + + for (i = 0; i < NO_OF_KEYS * keySyms->mapWidth; i++) { + if (keySym == keySyms->map[i]) { ++ int j, numSyms = 0; + keyCode = MIN_KEY_CODE + i / keySyms->mapWidth; + +- if (keySyms->map[(i / keySyms->mapWidth) +- * keySyms->mapWidth + 1] != NoSymbol) { +- ++ for (j = 0; j < keySyms->mapWidth; j++) ++ if (keySyms->map[(i / keySyms->mapWidth) ++ * keySyms->mapWidth + j] != NoSymbol) ++ numSyms++; ++ if (numSyms > 1) { + /* this keycode has more than one symbol associated with +- it, so shift state is important */ ++ it, so shift/Level3_shift state is important */ + +- if ((i % keySyms->mapWidth) == 0) ++ if (((i % keySyms->mapWidth) & 1) == 0) + shiftMustBeReleased = TRUE; + else + shiftMustBePressed = TRUE; ++ /* Does NOT consider Mode_shift (entries 2-3) */ ++ if (((i % keySyms->mapWidth) & 4) == 0) ++ level3MustBeReleased = TRUE; ++ else { ++ level3MustBePressed = TRUE; ++ } + } + break; + } +@@ -252,6 +272,7 @@ KbdAddEvent(Bool down, KeySym keySym, rf + shiftMustBeReleased = TRUE; + else + shiftMustBePressed = TRUE; ++ level3MustBeReleased = TRUE; + } + + XkbApplyMappingChange(inputInfo.keyboard, keySyms, keyCode, 1, NULL, serverClient); +@@ -262,6 +283,16 @@ KbdAddEvent(Bool down, KeySym keySym, rf + + xkb = &inputInfo.keyboard->key->xkbInfo->state; + if (down) { ++ // TODO: would require to check which keycodes are actually ++ // bound to ISO_Level3_Shift and/or Shift_L ++ if (level3MustBePressed && !KEY_IS_PRESSED(ISO_LEVEL3_KEY_CODE)) { ++ fakeLevel3Press = TRUE; ++ EnqueueKey(inputInfo.keyboard, KeyPress, ISO_LEVEL3_KEY_CODE); ++ } ++ if (level3MustBeReleased && KEY_IS_PRESSED(ISO_LEVEL3_KEY_CODE)) { ++ fakeLevel3Release = TRUE; ++ EnqueueKey(inputInfo.keyboard, KeyRelease, ISO_LEVEL3_KEY_CODE); ++ } + if (shiftMustBePressed && !(XkbStateFieldFromRec(xkb) & ShiftMask)) { + fakeShiftPress = TRUE; + EnqueueKey(inputInfo.keyboard, KeyPress, SHIFT_L_KEY_CODE); +@@ -289,6 +320,12 @@ KbdAddEvent(Bool down, KeySym keySym, rf + if (fakeShiftRRelease) { + EnqueueKey(inputInfo.keyboard, KeyPress, SHIFT_R_KEY_CODE); + } ++ if (fakeLevel3Press) { ++ EnqueueKey(inputInfo.keyboard, KeyRelease, ISO_LEVEL3_KEY_CODE); ++ } ++ if (fakeLevel3Release) { ++ EnqueueKey(inputInfo.keyboard, KeyPress, ISO_LEVEL3_KEY_CODE); ++ } + } + + +Index: xorg-server-1.9.3/hw/vnc/keyboard.h +=================================================================== +--- xorg-server-1.9.3.orig/hw/vnc/keyboard.h ++++ xorg-server-1.9.3/hw/vnc/keyboard.h +@@ -32,6 +32,7 @@ + #define META_R_KEY_CODE (MIN_KEY_CODE + 108) + #define ALT_L_KEY_CODE (MIN_KEY_CODE + 56) + #define ALT_R_KEY_CODE (MIN_KEY_CODE + 105) ++#define ISO_LEVEL3_KEY_CODE ALT_R_KEY_CODE + + static KeySym map[MAX_KEY_CODE * GLYPHS_PER_KEY] = { + /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, diff --git a/xorg-server-xf4vnc-bug605015-vnc-umlauts.diff b/xorg-server-xf4vnc-bug605015-vnc-umlauts.diff deleted file mode 100644 index 1a7aca8..0000000 --- a/xorg-server-xf4vnc-bug605015-vnc-umlauts.diff +++ /dev/null @@ -1,25 +0,0 @@ -Index: xorg-server-1.6.5/hw/vnc/kbdptr.c -=================================================================== ---- xorg-server-1.6.5.orig/hw/vnc/kbdptr.c -+++ xorg-server-1.6.5/hw/vnc/kbdptr.c -@@ -166,7 +166,9 @@ KbdAddEvent(Bool down, KeySym keySym, rf - if (!kbdDevice) - return; - -- keySyms = &kbdDevice->key->curKeySyms; -+ /* Use virtual core keyboard for keysyms - see discussion on -+ * https://defect.opensolaris.org/bz/show_bug.cgi?id=8687 */ -+ keySyms = &inputInfo.keyboard->key->curKeySyms; - - #ifdef CORBA - if (cl) { -@@ -277,7 +279,8 @@ KbdAddEvent(Bool down, KeySym keySym, rf - shiftMustBePressed = TRUE; - } - -- SendMappingNotify(kbdDevice, MappingKeyboard, keyCode, 1, serverClient); -+ /* Use virtual core keyboard for keysyms */ -+ SendMappingNotify(inputInfo.keyboard, MappingKeyboard, keyCode, 1, serverClient); - - ErrorF("KbdAddEvent: unknown KeySym 0x%x - allocating KeyCode %d\n", - (int)keySym, keyCode); diff --git a/xorg-x11-server.changes b/xorg-x11-server.changes index 85b39b9..a5f0fc3 100644 --- a/xorg-x11-server.changes +++ b/xorg-x11-server.changes @@ -1,3 +1,17 @@ +------------------------------------------------------------------- +Thu Apr 21 14:16:01 UTC 2011 - mhopf@novell.com + +- bnc #605015 + - Enable use of all keyboard layouts, independent of remotely set layout + - Remove obsolete xorg-server-xf4vnc-bug605015-vnc-umlauts.diff + - xorg-server-xf4vnc-bug605015-fix-keyboard-handling-xinput.diff + This should basically already enable the use of other keyboards, if the + remote keyboard stays at US. + - xorg-server-xf4vnc-bug605015-fix-keycode-lookup-and-isolevel3shift.diff + This patch fixes keycode lookup (not using any static keyboard layout any + more) and ISO-Level3-Shift handling (enabling the use of keyboard layouts + that use AltGr for reaching certain characters). + ------------------------------------------------------------------- Tue Apr 12 09:21:29 UTC 2011 - sndirsch@novell.com diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index feecc0c..0356038 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -79,7 +79,8 @@ Patch47: xorg-server-xf4vnc-clientTimeout.diff Patch48: xorg-server-xf4vnc-fix.diff Patch49: xorg-server-xf4vnc-fixes_1_8.diff Patch50: xorg-server-xf4vnc-fixes_1_9.diff -Patch51: xorg-server-xf4vnc-bug605015-vnc-umlauts.diff +Patch51: xorg-server-xf4vnc-bug605015-fix-keyboard-handling-xinput.diff +Patch52: xorg-server-xf4vnc-bug605015-fix-keycode-lookup-and-isolevel3shift.diff %endif Patch45: bug-197858_dpms.diff Patch67: xorg-docs.diff @@ -209,7 +210,8 @@ An X Window System server for Virtual Network Computing (VNC). %patch48 -p1 %patch49 -p0 %patch50 -p1 -#%patch51 -p1 +%patch51 -p1 +%patch52 -p1 chmod 755 hw/vnc/symlink-vnc.sh %endif %patch45 -p0