libinput driver doesn't grab devices, keystrokes still go to the TTY
Peter Hutterer
peter.hutterer at who-t.net
Tue Jun 9 02:02:16 UTC 2020
On Mon, Jun 08, 2020 at 06:29:56PM +1000, Adam Nielsen wrote:
> Hi all,
>
> I'm trying to set up a multiseat environment, with Xorg on a new seat
> and the normal Linux console (TTY) on the default seat0.
>
> Using loginctl, I've assigned an add-in video card and keyboard to the
> Xorg seat, leaving the onboard video card and a different keyboard to
> default as seat0. It almost works except any keys I type on the Xorg
> keyboard get sent to both Xorg and the TTY, whereas they should only go
> to X.
>
> Some things I read[1] said I need this:
>
> Section "InputClass"
> Identifier "prevent input events from going to the console"
> Option "GrabDevice" "True"
> EndSection
the xf86-input-libinput driver doesn't have this option, so this snippet is
a noop.
> While a patch[2] from 2013 suggests that GrabDevice is set automatically
> for seats that are not named "seat0", so it should apply to my keyboard
> belonging to "seat-nvidia".
>
> Either way I tried putting that section into my xorg config and
> confirmed it was applied: (with and without -sharevts and -novtswitch,
> which the patch suggests is now automatic anyway)
>
> # /usr/bin/X -sharevts :0 -seat seat-nvidia -novtswitch
> ...
> (II) config/udev: Adding input device HID 04d9:1400 (/dev/input/event1)
> (**) HID 04d9:1400: Applying InputClass "libinput keyboard catchall"
> (**) HID 04d9:1400: Applying InputClass "prevent input events from going to the console"
> (II) Using input driver 'libinput' for 'HID 04d9:1400'
> (**) HID 04d9:1400: always reports core events
> (**) Option "Device" "/dev/input/event1"
> (**) Option "_source" "server/udev"
> (II) event1 - HID 04d9:1400: is tagged by udev as: Keyboard
> (II) event1 - HID 04d9:1400: device is a keyboard
> (II) event1 - HID 04d9:1400: device removed
> (**) Option "config_info" "udev:/sys/devices/pci0000:00/0000:...
> (II) XINPUT: Adding extended input device "HID 04d9:1400" (type: KEYBOARD, id 6)
> (II) event1 - HID 04d9:1400: is tagged by udev as: Keyboard
> (II) event1 - HID 04d9:1400: device is a keyboard
>
> However still I get keystrokes going to both Xorg and the TTY.
>
> I saw that I can use evtest to make sure grabbing is working, so I ran
> this via SSH:
>
> evtest --grab /dev/input/event1
>
> And sure enough that stopped my keystrokes from going to either Xorg or
> the TTY, with them only being seen by evtest.
an EVIOCGRAB does more than just cutting off the tty, it cuts off everything
including internal consumers of that (e.g. rfkill and sysrq). That breaks
things and is the reason we removed the grab-by-default from the
evdev/synaptics drivers about a decade ago and punted this responsibility to
the X server.
> So it looks like Xorg is no longer grabbing input devices properly? Is
> there anything further I can do to check this?
>
> I'm running X Server 1.20.8 and xf86-input-libinput 0.30.0 under Arch
> Linux.
Handwavy summary because I only need to look at this every 2y or so it's
always fully paged out by the time this comes up.
In the normal case, the server switches the VT and changes it to
KD_GRAPHICS, see hw/xfree86/os-support/linux/lnx_init.c
This stops the keyboard from going to the VT.
In your case where you want the TTY and an xserver on the side this won't
work. tbh I'm not sure a driver-specific option is the solution here (it may
be), probably worth spending some time investitagating what other solutions
are there. But meanwhile, the libinput driver simply doesn't have that
option so you'll have to keep using evdev+synaptics for now.
Cheers,
Peter
More information about the xorg
mailing list