summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-07-18 21:19:23 +0200
committerPeter Hutterer <peter.hutterer@who-t.net>2011-08-22 15:56:49 +1000
commit159b03e13760920274b573a2bccdbf6a79f059e7 (patch)
tree220ca056977c363cfe09c5190b9b59138ada18ce
parent95772598b57f6054fbf88683fa0a492c77605790 (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.c18
-rw-r--r--hw/xfree86/common/xf86Init.c19
-rw-r--r--include/globals.h2
-rw-r--r--include/xserver-properties.h3
-rw-r--r--man/Xserver.man6
-rw-r--r--os/utils.c10
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
@@ -35,6 +35,7 @@
35#include "hotplug.h" 35#include "hotplug.h"
36#include "config-backends.h" 36#include "config-backends.h"
37#include "os.h" 37#include "os.h"
38#include "globals.h"
38 39
39#define UDEV_XKB_PROP_KEY "xkb" 40#define UDEV_XKB_PROP_KEY "xkb"
40 41
@@ -65,6 +66,7 @@ device_added(struct udev_device *udev_device)
65 struct udev_list_entry *set, *entry; 66 struct udev_list_entry *set, *entry;
66 struct udev_device *parent; 67 struct udev_device *parent;
67 int rc; 68 int rc;
69 const char *dev_seat;
68 70
69 path = udev_device_get_devnode(udev_device); 71 path = udev_device_get_devnode(udev_device);
70 72
@@ -73,6 +75,16 @@ device_added(struct udev_device *udev_device)
73 if (!path || !syspath) 75 if (!path || !syspath)
74 return; 76 return;
75 77
78 dev_seat = udev_device_get_property_value(udev_device, "ID_SEAT");
79 if (!dev_seat)
80 dev_seat = "seat0";
81
82 if (SeatId && strcmp(dev_seat, SeatId))
83 return;
84
85 if (!SeatId && strcmp(dev_seat, "seat0"))
86 return;
87
76 if (!udev_device_get_property_value(udev_device, "ID_INPUT")) { 88 if (!udev_device_get_property_value(udev_device, "ID_INPUT")) {
77 LogMessageVerb(X_INFO, 10, 89 LogMessageVerb(X_INFO, 10,
78 "config/udev: ignoring device %s without " 90 "config/udev: ignoring device %s without "
@@ -284,6 +296,9 @@ config_udev_init(void)
284 udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "input", NULL); 296 udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "input", NULL);
285 udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "tty", NULL); /* For Wacom serial devices */ 297 udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "tty", NULL); /* For Wacom serial devices */
286 298
299 if (SeatId && strcmp(SeatId, "seat0"))
300 udev_monitor_filter_add_match_tag(udev_monitor, SeatId);
301
287 if (udev_monitor_enable_receiving(udev_monitor)) { 302 if (udev_monitor_enable_receiving(udev_monitor)) {
288 ErrorF("config/udev: failed to bind the udev monitor\n"); 303 ErrorF("config/udev: failed to bind the udev monitor\n");
289 return 0; 304 return 0;
@@ -296,6 +311,9 @@ config_udev_init(void)
296 udev_enumerate_add_match_subsystem(enumerate, "input"); 311 udev_enumerate_add_match_subsystem(enumerate, "input");
297 udev_enumerate_add_match_subsystem(enumerate, "tty"); 312 udev_enumerate_add_match_subsystem(enumerate, "tty");
298 313
314 if (SeatId && strcmp(SeatId, "seat0"))
315 udev_enumerate_add_match_tag(enumerate, SeatId);
316
299 udev_enumerate_scan_devices(enumerate); 317 udev_enumerate_scan_devices(enumerate);
300 devices = udev_enumerate_get_list_entry(enumerate); 318 devices = udev_enumerate_get_list_entry(enumerate);
301 udev_list_entry_foreach(device, devices) { 319 udev_list_entry_foreach(device, devices) {
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
@@ -80,6 +80,7 @@
80#include "xf86Bus.h" 80#include "xf86Bus.h"
81#include "xf86VGAarbiter.h" 81#include "xf86VGAarbiter.h"
82#include "globals.h" 82#include "globals.h"
83#include "xserver-properties.h"
83 84
84#ifdef DPMSExtension 85#ifdef DPMSExtension
85#include <X11/extensions/dpmsconst.h> 86#include <X11/extensions/dpmsconst.h>
@@ -654,6 +655,24 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
654 } 655 }
655 } 656 }
656 657
658 if (SeatId) {
659 Atom SeatAtom;
660
661 SeatAtom = MakeAtom(SEAT_ATOM_NAME, sizeof(SEAT_ATOM_NAME) - 1, TRUE);
662
663 for (i = 0; i < xf86NumScreens; i++) {
664 int ret;
665
666 ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
667 SeatAtom, XA_STRING, 8,
668 strlen(SeatId)+1, SeatId );
669 if (ret != Success) {
670 xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
671 "Failed to register seat property\n");
672 }
673 }
674 }
675
657 /* If a screen uses depth 24, show what the pixmap format is */ 676 /* If a screen uses depth 24, show what the pixmap format is */
658 for (i = 0; i < xf86NumScreens; i++) { 677 for (i = 0; i < xf86NumScreens; i++) {
659 if (xf86Screens[i]->depth == 24) { 678 if (xf86Screens[i]->depth == 24) {
diff --git a/include/globals.h b/include/globals.h
index 8b80a652b..17bca8208 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -21,7 +21,7 @@ extern _X_EXPORT int defaultColorVisualClass;
21 21
22extern _X_EXPORT int GrabInProgress; 22extern _X_EXPORT int GrabInProgress;
23extern _X_EXPORT Bool noTestExtensions; 23extern _X_EXPORT Bool noTestExtensions;
24 24extern _X_EXPORT char *SeatId;
25extern _X_EXPORT char *ConnectionInfo; 25extern _X_EXPORT char *ConnectionInfo;
26 26
27#ifdef DPMSExtension 27#ifdef DPMSExtension
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
@@ -30,6 +30,9 @@
30 * byte-ordering. */ 30 * byte-ordering. */
31#define XATOM_FLOAT "FLOAT" 31#define XATOM_FLOAT "FLOAT"
32 32
33/* STRING. Seat name of this display */
34#define SEAT_ATOM_NAME "Xorg_Seat"
35
33/* BOOL. 0 - device disabled, 1 - device enabled */ 36/* BOOL. 0 - device disabled, 1 - device enabled */
34#define XI_PROP_ENABLED "Device Enabled" 37#define XI_PROP_ENABLED "Device Enabled"
35/* BOOL. If present, device is a virtual XTEST device */ 38/* BOOL. If present, device is a virtual XTEST device */
diff --git a/man/Xserver.man b/man/Xserver.man
index f74391212..1a36b0956 100644
--- a/man/Xserver.man
+++ b/man/Xserver.man
@@ -220,6 +220,12 @@ sets screen-saver timeout time in minutes.
220.B \-su 220.B \-su
221disables save under support on all screens. 221disables save under support on all screens.
222.TP 8 222.TP 8
223.B \-seat \fIseat\fP
224seat to run on. Takes a string identifying a seat in a platform
225specific syntax. On platforms which support this feature this may be
226used to limit the server to expose only a specific subset of devices
227connected to the system.
228.TP 8
223.B \-t \fInumber\fP 229.B \-t \fInumber\fP
224sets pointer acceleration threshold in pixels (i.e. after how many pixels 230sets pointer acceleration threshold in pixels (i.e. after how many pixels
225pointer acceleration should take effect). 231pointer acceleration should take effect).
diff --git a/os/utils.c b/os/utils.c
index 36cb46f11..e8ecb7193 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -201,6 +201,8 @@ Bool PanoramiXExtensionDisabledHack = FALSE;
201 201
202int auditTrailLevel = 1; 202int auditTrailLevel = 1;
203 203
204char *SeatId = NULL;
205
204#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED) 206#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
205#define HAS_SAVED_IDS_AND_SETEUID 207#define HAS_SAVED_IDS_AND_SETEUID
206#endif 208#endif
@@ -511,6 +513,7 @@ void UseMsg(void)
511 ErrorF("-render [default|mono|gray|color] set render color alloc policy\n"); 513 ErrorF("-render [default|mono|gray|color] set render color alloc policy\n");
512 ErrorF("-retro start with classic stipple and cursor\n"); 514 ErrorF("-retro start with classic stipple and cursor\n");
513 ErrorF("-s # screen-saver timeout (minutes)\n"); 515 ErrorF("-s # screen-saver timeout (minutes)\n");
516 ErrorF("-seat string seat to run on\n");
514 ErrorF("-t # default pointer threshold (pixels/t)\n"); 517 ErrorF("-t # default pointer threshold (pixels/t)\n");
515 ErrorF("-terminate terminate at server reset\n"); 518 ErrorF("-terminate terminate at server reset\n");
516 ErrorF("-to # connection time out\n"); 519 ErrorF("-to # connection time out\n");
@@ -802,6 +805,13 @@ ProcessCommandLine(int argc, char *argv[])
802 else 805 else
803 UseMsg(); 806 UseMsg();
804 } 807 }
808 else if ( strcmp( argv[i], "-seat") == 0)
809 {
810 if(++i < argc)
811 SeatId = argv[i];
812 else
813 UseMsg();
814 }
805 else if ( strcmp( argv[i], "-t") == 0) 815 else if ( strcmp( argv[i], "-t") == 0)
806 { 816 {
807 if(++i < argc) 817 if(++i < argc)