How to change default behavior of Xephyr for capturing and releasing keyboard/mouse

xephyr

When running Xephyr, its window title says "ctrl-shift grabs mouse and keyboard".

I am using ctrl-shift (left ctrl – left shift) as keyboard layout switching hotkeys and it interferes with Xephyr, when I press them, just the keyboard layout is switched, Xephyr doesn't grab mouse and keyboard.

I strongly want to avoid changing the hotkey combination for keyboard layout switching.

Is it possible to change the default hotkeys for mouse/keyboard grabbing in Xephyr?

Ideally, I would like a VirtualBox-like behavior: Xephyr window would grab mouse and keyboard when I mouse click on it and would release mouse and keyboard when I press the right ctrl. If this is is not possible, I'm open to alternative suggestions which will keep left ctrl – left shift for keyboard layout switching only.

Best Answer

It is hard wired in the code: http://cgit.freedesktop.org/xorg/xserver/tree/hw/kdrive/ephyr/hostx.c#n1002

You have to patch it:

if ((XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_L
     || XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_R)
    && (xev.xkey.state & ControlMask))

There you can use any other key code you like.

The available key codes are defined in /usr/include/X11/keysymdef.h