major.io words of wisdom from a systems engineer

Sticky shift key with synergy in Fedora 12

My synergy setup at work is relatively simple. I have a MacBook Pro running Snow Leopard that acts as a synergy server and a desktop running Fedora 12 as a synergy client. On the Mac, I use SynergyKM to manage the synergy server. The Fedora box uses my gdm strategy for starting synergy at the login screen and in GNOME.

I kept having an issue where the shift key would become stuck regardless of the settings I set for the client or server. The halfDuplexCapsLock configuration option had no effect. After installing xkeycaps, I found that both shift keys were getting stuck if I brought the mouse back and forth between Mac and Fedora twice.

I decided to run a test. I started the client with the debug argument and moved the mouse to my Fedora box. At that point, I pressed the letter ‘a’ and saw:

DEBUG1: CXWindowsKeyState.cpp,195:   032 (00000000) up
DEBUG1: CXWindowsKeyState.cpp,195:   03e (00000000) up
DEBUG1: CXWindowsKeyState.cpp,195:   026 (00000000) down
DEBUG1: CXWindowsKeyState.cpp,195:   032 (00000000) down
DEBUG1: CXWindowsKeyState.cpp,195:   03e (00000000) down
DEBUG1: CXWindowsKeyState.cpp,195:   026 (00000000) up

I brought the mouse back to the Mac and then back to Fedora. I pressed ‘a’ again and saw:

DEBUG1: CXWindowsKeyState.cpp,195:   026 (00000000) down
DEBUG1: CXWindowsKeyState.cpp,195:   026 (00000000) up
DEBUG1: CXWindowsKeyState.cpp,195:   026 (00000000) down
DEBUG1: CXWindowsKeyState.cpp,195:   026 (00000000) up

After dumping the keyboard layout with xmodmap I found the keys that corresponded with the key numbers:

  • 032 - Left shift
  • 03e - Right shift
  • 026 - a

If I tapped the left shift, I could clear the key press, but I couldn’t clear the right shift key (it was stuck down according to Fedora’s X server). When I hooked up a physical keyboard and mouse, I was able to use them normally without any keybinding problems.

The root cause: When synergy started in /etc/gdm/PreSession/Default after the gdm login, the keyboard layout wasn’t set up properly. The X server was setting up the keyboard layout later in the startup process and this confusion caused the shift keys to get stuck. Fedora 12 uses evdev to probe for keyboards during X’s startup and eventually settles on a default layout if none are explicitly defined.

The fix: I added the synergy startup to the GNOME startup items and it works flawlessly.