diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-07-18 21:19:23 +0200 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-08-22 15:56:49 +1000 |
commit | 159b03e13760920274b573a2bccdbf6a79f059e7 (patch) | |
tree | 220ca056977c363cfe09c5190b9b59138ada18ce | |
parent | 95772598b57f6054fbf88683fa0a492c77605790 (diff) |
config: add udev/systemd multi-seat support
Add support for multi-seat-aware input device hotplugging. This
implements the multi-seat scheme explained here:
http://www.freedesktop.org/wiki/Software/systemd/multiseat
This introduces a new X server switch "-seat" which allows configuration
of the seat to enumerate hotplugging devices on. If specified the value
of this parameter will also be exported as root window property
Xorg_Seat.
To properly support input hotplugging devices need to be tagged in udev
according to the seat they are on. Untagged devices are assumed to be on
the default seat "seat0". If no "-seat" parameter is passed only devices
on "seat0" are used. This means that the new scheme is perfectly
compatible with existing setups which have no tagged input devices.
Note that the -seat switch takes a completely generic identifier, and
that it has no effect on non-Linux systems. In fact, on other OSes a
completely different identifier scheme for seats could be used but still
be exposed with the Xorg_Seat and -seat.
I tried to follow the coding style of the surrounding code blocks if
there was any one could follow.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | config/udev.c | 18 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Init.c | 19 | ||||
-rw-r--r-- | include/globals.h | 2 | ||||
-rw-r--r-- | include/xserver-properties.h | 3 | ||||
-rw-r--r-- | man/Xserver.man | 6 | ||||
-rw-r--r-- | os/utils.c | 10 |
6 files changed, 57 insertions, 1 deletions
diff --git a/config/udev.c b/config/udev.c index e7383dc36..fc6ee5dac 100644 --- a/config/udev.c +++ b/config/udev.c @@ -37,2 +37,3 @@ #include "os.h" +#include "globals.h" @@ -67,2 +68,3 @@ device_added(struct udev_device *udev_device) int rc; + const char *dev_seat; @@ -75,2 +77,12 @@ device_added(struct udev_device *udev_device) + dev_seat = udev_device_get_property_value(udev_device, "ID_SEAT"); + if (!dev_seat) + dev_seat = "seat0"; + + if (SeatId && strcmp(dev_seat, SeatId)) + return; + + if (!SeatId && strcmp(dev_seat, "seat0")) + return; + if (!udev_device_get_property_value(udev_device, "ID_INPUT")) { @@ -286,2 +298,5 @@ config_udev_init(void) + if (SeatId && strcmp(SeatId, "seat0")) + udev_monitor_filter_add_match_tag(udev_monitor, SeatId); + if (udev_monitor_enable_receiving(udev_monitor)) { @@ -298,2 +313,5 @@ config_udev_init(void) + if (SeatId && strcmp(SeatId, "seat0")) + udev_enumerate_add_match_tag(enumerate, SeatId); + udev_enumerate_scan_devices(enumerate); diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 5ee68cd26..89bc82a97 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -82,2 +82,3 @@ #include "globals.h" +#include "xserver-properties.h" @@ -656,2 +657,20 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) + if (SeatId) { + Atom SeatAtom; + + SeatAtom = MakeAtom(SEAT_ATOM_NAME, sizeof(SEAT_ATOM_NAME) - 1, TRUE); + + for (i = 0; i < xf86NumScreens; i++) { + int ret; + + ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex, + SeatAtom, XA_STRING, 8, + strlen(SeatId)+1, SeatId ); + if (ret != Success) { + xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING, + "Failed to register seat property\n"); + } + } + } + /* If a screen uses depth 24, show what the pixmap format is */ diff --git a/include/globals.h b/include/globals.h index 8b80a652b..17bca8208 100644 --- a/include/globals.h +++ b/include/globals.h @@ -23,3 +23,3 @@ extern _X_EXPORT int GrabInProgress; extern _X_EXPORT Bool noTestExtensions; - +extern _X_EXPORT char *SeatId; extern _X_EXPORT char *ConnectionInfo; diff --git a/include/xserver-properties.h b/include/xserver-properties.h index 2b1feabb6..bf50042d0 100644 --- a/include/xserver-properties.h +++ b/include/xserver-properties.h @@ -32,2 +32,5 @@ +/* STRING. Seat name of this display */ +#define SEAT_ATOM_NAME "Xorg_Seat" + /* BOOL. 0 - device disabled, 1 - device enabled */ diff --git a/man/Xserver.man b/man/Xserver.man index f74391212..1a36b0956 100644 --- a/man/Xserver.man +++ b/man/Xserver.man @@ -222,2 +222,8 @@ disables save under support on all screens. .TP 8 +.B \-seat \fIseat\fP +seat to run on. Takes a string identifying a seat in a platform +specific syntax. On platforms which support this feature this may be +used to limit the server to expose only a specific subset of devices +connected to the system. +.TP 8 .B \-t \fInumber\fP diff --git a/os/utils.c b/os/utils.c index 36cb46f11..e8ecb7193 100644 --- a/os/utils.c +++ b/os/utils.c @@ -203,2 +203,4 @@ int auditTrailLevel = 1; +char *SeatId = NULL; + #if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED) @@ -513,2 +515,3 @@ void UseMsg(void) ErrorF("-s # screen-saver timeout (minutes)\n"); + ErrorF("-seat string seat to run on\n"); ErrorF("-t # default pointer threshold (pixels/t)\n"); @@ -804,2 +807,9 @@ ProcessCommandLine(int argc, char *argv[]) } + else if ( strcmp( argv[i], "-seat") == 0) + { + if(++i < argc) + SeatId = argv[i]; + else + UseMsg(); + } else if ( strcmp( argv[i], "-t") == 0) |