diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2017-12-08 15:02:03 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2017-12-08 15:02:03 +0000 |
commit | e2e6e25be1cbd7ecc45bbd9130c4527f7715e547 (patch) | |
tree | 85e40fcfbc819cb0394346c69db478a22e9ed122 /xserver/hw/kdrive/src | |
parent | 63d0911c1d9f1be4f8755144bced468fcbc398a6 (diff) |
Update to xserver 1.19.5.
Tested by bru@, jsg@ and others
Diffstat (limited to 'xserver/hw/kdrive/src')
-rw-r--r-- | xserver/hw/kdrive/src/Makefile.am | 8 | ||||
-rw-r--r-- | xserver/hw/kdrive/src/Makefile.in | 20 | ||||
-rw-r--r-- | xserver/hw/kdrive/src/kdrive.c | 96 | ||||
-rw-r--r-- | xserver/hw/kdrive/src/kdrive.h | 6 | ||||
-rw-r--r-- | xserver/hw/kdrive/src/kinfo.c | 4 | ||||
-rw-r--r-- | xserver/hw/kdrive/src/kinput.c | 390 |
6 files changed, 362 insertions, 162 deletions
diff --git a/xserver/hw/kdrive/src/Makefile.am b/xserver/hw/kdrive/src/Makefile.am index d69f0dd99..b7f94b058 100644 --- a/xserver/hw/kdrive/src/Makefile.am +++ b/xserver/hw/kdrive/src/Makefile.am @@ -23,3 +23,11 @@ libkdrive_la_SOURCES = \ kshadow.c \ $(KDRIVE_XV_SOURCES) \ $(top_srcdir)/mi/miinitext.c + +if CONFIG_UDEV +libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +else +if CONFIG_HAL +libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +endif +endif diff --git a/xserver/hw/kdrive/src/Makefile.in b/xserver/hw/kdrive/src/Makefile.in index 60d446ef0..d679b82a8 100644 --- a/xserver/hw/kdrive/src/Makefile.in +++ b/xserver/hw/kdrive/src/Makefile.in @@ -55,9 +55,10 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -72,7 +73,9 @@ CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) -libkdrive_la_LIBADD = +@CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@libkdrive_la_DEPENDENCIES = $(top_builddir)/config/libconfig.la +@CONFIG_UDEV_TRUE@libkdrive_la_DEPENDENCIES = \ +@CONFIG_UDEV_TRUE@ $(top_builddir)/config/libconfig.la am__libkdrive_la_SOURCES_DIST = fourcc.h kcmap.c kdrive.c kdrive.h \ kinfo.c kinput.c kmode.c kshadow.c kxv.c kxv.h \ $(top_srcdir)/mi/miinitext.c @@ -303,6 +306,9 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PROJECTROOT = @PROJECTROOT@ +PTHREAD_CC = @PTHREAD_CC@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_LIBS = @PTHREAD_LIBS@ PYTHON3 = @PYTHON3@ RANLIB = @RANLIB@ RAWCPP = @RAWCPP@ @@ -333,7 +339,10 @@ UDEV_LIBS = @UDEV_LIBS@ UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ VERSION = @VERSION@ +WAYLAND_PROTOCOLS_DATADIR = @WAYLAND_PROTOCOLS_DATADIR@ WAYLAND_SCANNER = @WAYLAND_SCANNER@ +WINDOWSDRI_CFLAGS = @WINDOWSDRI_CFLAGS@ +WINDOWSDRI_LIBS = @WINDOWSDRI_LIBS@ WINDOWSWM_CFLAGS = @WINDOWSWM_CFLAGS@ WINDOWSWM_LIBS = @WINDOWSWM_LIBS@ WINDRES = @WINDRES@ @@ -428,6 +437,7 @@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ +ax_pthread_config = @ax_pthread_config@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -497,6 +507,8 @@ libkdrive_la_SOURCES = \ $(KDRIVE_XV_SOURCES) \ $(top_srcdir)/mi/miinitext.c +@CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la +@CONFIG_UDEV_TRUE@libkdrive_la_LIBADD = $(top_builddir)/config/libconfig.la all: all-am .SUFFIXES: diff --git a/xserver/hw/kdrive/src/kdrive.c b/xserver/hw/kdrive/src/kdrive.c index 582ff66d2..f02d8262b 100644 --- a/xserver/hw/kdrive/src/kdrive.c +++ b/xserver/hw/kdrive/src/kdrive.c @@ -43,7 +43,13 @@ #include <execinfo.h> #endif -#include <signal.h> +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +#include <hotplug.h> +#endif + +/* This stub can be safely removed once we can + * split input and GPU parts in hotplug.h et al. */ +#include <systemd-logind.h> typedef struct _kdDepths { CARD8 depth; @@ -81,6 +87,11 @@ char *kdSwitchCmd; DDXPointRec kdOrigin; Bool kdHasPointer = FALSE; Bool kdHasKbd = FALSE; +const char *kdGlobalXkbRules = NULL; +const char *kdGlobalXkbModel = NULL; +const char *kdGlobalXkbLayout = NULL; +const char *kdGlobalXkbVariant = NULL; +const char *kdGlobalXkbOptions = NULL; static Bool kdCaughtSignal = FALSE; @@ -447,6 +458,11 @@ KdUseMsg(void) ("-mouse driver [,n,,options] Specify the pointer driver and its options (n is the number of buttons)\n"); ErrorF ("-keybd driver [,,options] Specify the keyboard driver and its options\n"); + ErrorF("-xkb-rules Set default XkbRules value (can be overriden by -keybd options)\n"); + ErrorF("-xkb-model Set default XkbModel value (can be overriden by -keybd options)\n"); + ErrorF("-xkb-layout Set default XkbLayout value (can be overriden by -keybd options)\n"); + ErrorF("-xkb-variant Set default XkbVariant value (can be overriden by -keybd options)\n"); + ErrorF("-xkb-options Set default XkbOptions value (can be overriden by -keybd options)\n"); ErrorF("-zaphod Disable cursor screen switching\n"); ErrorF("-2button Emulate 3 button mouse\n"); ErrorF("-3button Disable 3 button mouse emulation\n"); @@ -555,6 +571,46 @@ KdProcessArgument(int argc, char **argv, int i) sscanf(argv[i], "vt%2d", &kdVirtualTerminal) == 1) { return 1; } + if (!strcmp(argv[i], "-xkb-rules")) { + if (i + 1 >= argc) { + UseMsg(); + FatalError("Missing argument for option -xkb-rules.\n"); + } + kdGlobalXkbRules = argv[i + 1]; + return 2; + } + if (!strcmp(argv[i], "-xkb-model")) { + if (i + 1 >= argc) { + UseMsg(); + FatalError("Missing argument for option -xkb-model.\n"); + } + kdGlobalXkbModel = argv[i + 1]; + return 2; + } + if (!strcmp(argv[i], "-xkb-layout")) { + if (i + 1 >= argc) { + UseMsg(); + FatalError("Missing argument for option -xkb-layout.\n"); + } + kdGlobalXkbLayout = argv[i + 1]; + return 2; + } + if (!strcmp(argv[i], "-xkb-variant")) { + if (i + 1 >= argc) { + UseMsg(); + FatalError("Missing argument for option -xkb-variant.\n"); + } + kdGlobalXkbVariant = argv[i + 1]; + return 2; + } + if (!strcmp(argv[i], "-xkb-options")) { + if (i + 1 >= argc) { + UseMsg(); + FatalError("Missing argument for option -xkb-options.\n"); + } + kdGlobalXkbOptions = argv[i + 1]; + return 2; + } if (!strcmp(argv[i], "-mouse") || !strcmp(argv[i], "-pointer")) { if (i + 1 >= argc) UseMsg(); @@ -1125,6 +1181,11 @@ KdInitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) KdAddScreen(pScreenInfo, screen, argc, argv); OsRegisterSigWrapper(KdSignalWrapper); + +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) + if (SeatId) /* Enable input hot-plugging */ + config_pre_init(); +#endif } void @@ -1143,3 +1204,36 @@ DPMSSupported(void) { return FALSE; } + +/* These stubs can be safely removed once we can + * split input and GPU parts in hotplug.h et al. */ +#ifdef CONFIG_UDEV_KMS +void +NewGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} + +void +DeleteGPUDeviceRequest(struct OdevAttributes *attribs) +{ +} +#endif + +struct xf86_platform_device * +xf86_find_platform_device_by_devnum(int major, int minor) +{ + return NULL; +} + +#ifdef SYSTEMD_LOGIND +void +systemd_logind_vtenter(void) +{ +} + +void +systemd_logind_release_fd(int major, int minor, int fd) +{ + close(fd); +} +#endif diff --git a/xserver/hw/kdrive/src/kdrive.h b/xserver/hw/kdrive/src/kdrive.h index e1d2b5927..3c7f2cdf2 100644 --- a/xserver/hw/kdrive/src/kdrive.h +++ b/xserver/hw/kdrive/src/kdrive.h @@ -527,12 +527,10 @@ void KdScreenToPointerCoords(int *x, int *y); void - -KdBlockHandler(ScreenPtr pScreen, void *timeout, void *readmask); +KdBlockHandler(ScreenPtr pScreen, void *timeout); void - -KdWakeupHandler(ScreenPtr pScreen, unsigned long result, void *readmask); +KdWakeupHandler(ScreenPtr pScreen, int result); void KdDisableInput(void); diff --git a/xserver/hw/kdrive/src/kinfo.c b/xserver/hw/kdrive/src/kinfo.c index 01ae1e491..f91d57504 100644 --- a/xserver/hw/kdrive/src/kinfo.c +++ b/xserver/hw/kdrive/src/kinfo.c @@ -134,6 +134,7 @@ KdFreePointer(KdPointerInfo * pi) free(pi->name); free(pi->path); input_option_free_list(&pi->options); + pi->next = NULL; free(pi); } @@ -145,6 +146,9 @@ KdFreeKeyboard(KdKeyboardInfo * ki) free(ki->xkbRules); free(ki->xkbModel); free(ki->xkbLayout); + free(ki->xkbVariant); + free(ki->xkbOptions); + input_option_free_list(&ki->options); ki->next = NULL; free(ki); } diff --git a/xserver/hw/kdrive/src/kinput.c b/xserver/hw/kdrive/src/kinput.c index d5741f100..8b08747a6 100644 --- a/xserver/hw/kdrive/src/kinput.c +++ b/xserver/hw/kdrive/src/kinput.c @@ -32,9 +32,8 @@ #if HAVE_X11_XF86KEYSYM_H #include <X11/XF86keysym.h> #endif -#include <signal.h> #include <stdio.h> -#ifdef sun +#ifdef __sun #include <sys/file.h> /* needed for FNONBLOCK & FASYNC */ #endif @@ -51,6 +50,15 @@ #include "inpututils.h" #include "optionstr.h" +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) +#include <hotplug.h> +#endif + +#ifdef KDRIVE_EVDEV +#define DEV_INPUT_EVENT_PREFIX "/dev/input/event" +#define DEV_INPUT_EVENT_PREFIX_LEN (sizeof(DEV_INPUT_EVENT_PREFIX) - 1) +#endif + #define AtomFromName(x) MakeAtom(x, strlen(x), 1) struct KdConfigDevice { @@ -93,37 +101,11 @@ static int kdNumInputFds; extern Bool kdRawPointerCoordinates; -static void -KdSigio(int sig) -{ - int i; - - for (i = 0; i < kdNumInputFds; i++) - (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure); -} - -#ifdef DEBUG_SIGIO - -void -KdAssertSigioBlocked(char *where) -{ - sigset_t set, old; - - sigemptyset(&set); - sigprocmask(SIG_BLOCK, &set, &old); - if (!sigismember(&old, SIGIO)) { - ErrorF("SIGIO not blocked at %s\n", where); - KdBacktrace(0); - } -} - -#else - -#define KdAssertSigioBlocked(s) - -#endif - -static int kdnFds; +extern const char *kdGlobalXkbRules; +extern const char *kdGlobalXkbModel; +extern const char *kdGlobalXkbLayout; +extern const char *kdGlobalXkbVariant; +extern const char *kdGlobalXkbOptions; #ifdef FNONBLOCK #define NOBLOCK FNONBLOCK @@ -153,43 +135,28 @@ KdNonBlockFd(int fd) } static void -KdAddFd(int fd) +KdNotifyFd(int fd, int ready, void *data) { - struct sigaction act; - sigset_t set; + int i = (int) (intptr_t) data; + (*kdInputFds[i].read)(fd, kdInputFds[i].closure); +} - kdnFds++; - fcntl(fd, F_SETOWN, getpid()); +static void +KdAddFd(int fd, int i) +{ KdNonBlockFd(fd); - AddEnabledDevice(fd); - memset(&act, '\0', sizeof act); - act.sa_handler = KdSigio; - sigemptyset(&act.sa_mask); - sigaddset(&act.sa_mask, SIGIO); - sigaddset(&act.sa_mask, SIGALRM); - sigaddset(&act.sa_mask, SIGVTALRM); - sigaction(SIGIO, &act, 0); - sigemptyset(&set); - sigprocmask(SIG_SETMASK, &set, 0); + InputThreadRegisterDev(fd, KdNotifyFd, (void *) (intptr_t) i); } static void KdRemoveFd(int fd) { - struct sigaction act; int flags; - kdnFds--; - RemoveEnabledDevice(fd); + InputThreadUnregisterDev(fd); flags = fcntl(fd, F_GETFL); flags &= ~(FASYNC | NOBLOCK); fcntl(fd, F_SETFL, flags); - if (kdnFds == 0) { - memset(&act, '\0', sizeof act); - act.sa_handler = SIG_IGN; - sigemptyset(&act.sa_mask); - sigaction(SIGIO, &act, 0); - } } Bool @@ -202,9 +169,9 @@ KdRegisterFd(int fd, void (*read) (int fd, void *closure), void *closure) kdInputFds[kdNumInputFds].enable = 0; kdInputFds[kdNumInputFds].disable = 0; kdInputFds[kdNumInputFds].closure = closure; - kdNumInputFds++; if (kdInputEnabled) - KdAddFd(fd); + KdAddFd(fd, kdNumInputFds); + kdNumInputFds++; return TRUE; } @@ -241,7 +208,7 @@ KdDisableInput(void) KdPointerInfo *pi; int found = 0, i = 0; - OsBlockSIGIO(); + input_lock(); for (ki = kdKeyboards; ki; ki = ki->next) { if (ki->driver && ki->driver->Disable) @@ -324,7 +291,7 @@ KdEnableInput(void) NoticeEventTime (&ev, pi->dixdev); } - OsReleaseSIGIO(); + input_unlock(); } static KdKeyboardDriver * @@ -391,7 +358,8 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff) #endif if (!pi->driver) { if (!pi->driverPrivate) { - ErrorF("no driver specified for %s\n", pi->name); + ErrorF("no driver specified for pointer device \"%s\" (%s)\n", + pi->name ? pi->name : "(unnamed)", pi->path); return BadImplementation; } @@ -711,7 +679,8 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) #endif if (!ki->driver) { if (!ki->driverPrivate) { - ErrorF("no driver specified!\n"); + ErrorF("no driver specified for keyboard device \"%s\" (%s)\n", + ki->name ? ki->name : "(unnamed)", ki->path); return BadImplementation; } @@ -731,10 +700,6 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) return BadImplementation; } - if ((*ki->driver->Init) (ki) != Success) { - return !Success; - } - memset(&rmlvo, 0, sizeof(rmlvo)); rmlvo.rules = ki->xkbRules; rmlvo.model = ki->xkbModel; @@ -747,6 +712,10 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff) return BadImplementation; } + if ((*ki->driver->Init) (ki) != Success) { + return !Success; + } + xiclass = AtomFromName(XI_KEYBOARD); AssignTypeAndName(pDevice, xiclass, ki->name ? ki->name : "Generic KDrive Keyboard"); @@ -885,11 +854,13 @@ KdNewKeyboard(void) ki->bellDuration = 200; ki->next = NULL; ki->options = NULL; - ki->xkbRules = strdup(XKB_DFLT_RULES); - ki->xkbModel = strdup(XKB_DFLT_MODEL); - ki->xkbLayout = strdup(XKB_DFLT_LAYOUT); - ki->xkbVariant = strdup(XKB_DFLT_VARIANT); - ki->xkbOptions = strdup(XKB_DFLT_OPTIONS); + ki->name = strdup("Generic Keyboard"); + ki->path = NULL; + ki->xkbRules = strdup(kdGlobalXkbRules ? kdGlobalXkbRules : XKB_DFLT_RULES); + ki->xkbModel = strdup(kdGlobalXkbModel ? kdGlobalXkbModel : XKB_DFLT_MODEL); + ki->xkbLayout = strdup(kdGlobalXkbLayout ? kdGlobalXkbLayout : XKB_DFLT_LAYOUT); + ki->xkbVariant = strdup(kdGlobalXkbVariant ? kdGlobalXkbVariant :XKB_DFLT_VARIANT); + ki->xkbOptions = strdup(kdGlobalXkbOptions ? kdGlobalXkbOptions : XKB_DFLT_OPTIONS); return ki; } @@ -1068,22 +1039,68 @@ KdParseKbdOptions(KdKeyboardInfo * ki) const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); - if (strcasecmp(key, "XkbRules") == 0) + if ( +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) + strcasecmp(key, "xkb_rules") == 0 || +#endif + strcasecmp(key, "XkbRules") == 0) ki->xkbRules = strdup(value); - else if (strcasecmp(key, "XkbModel") == 0) + else if ( +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) + strcasecmp(key, "xkb_model") == 0 || +#endif + strcasecmp(key, "XkbModel") == 0) ki->xkbModel = strdup(value); - else if (strcasecmp(key, "XkbLayout") == 0) + else if ( +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) + strcasecmp(key, "xkb_layout") == 0 || +#endif + strcasecmp(key, "XkbLayout") == 0) ki->xkbLayout = strdup(value); - else if (strcasecmp(key, "XkbVariant") == 0) + else if ( +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) + strcasecmp(key, "xkb_variant") == 0 || +#endif + strcasecmp(key, "XkbVariant") == 0) ki->xkbVariant = strdup(value); - else if (strcasecmp(key, "XkbOptions") == 0) + else if ( +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) + strcasecmp(key, "xkb_options") == 0 || +#endif + strcasecmp(key, "XkbOptions") == 0) ki->xkbOptions = strdup(value); - else if (!strcasecmp(key, "device")) + else if (!strcasecmp(key, "device")) { + if (ki->path != NULL) + free(ki->path); ki->path = strdup(value); + } +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) + else if (!strcasecmp(key, "path")) { + if (ki->path != NULL) + free(ki->path); + ki->path = strdup(value); + } + else if (!strcasecmp(key, "name")) { + free(ki->name); + ki->name = strdup(value); + } +#endif + else if (!strcasecmp(key, "driver")) + ki->driver = KdFindKeyboardDriver(value); else ErrorF("Kbd option key (%s) of value (%s) not assigned!\n", key, value); } + +#ifdef KDRIVE_EVDEV + if (!ki->driver && ki->path != NULL && + strncasecmp(ki->path, + DEV_INPUT_EVENT_PREFIX, + DEV_INPUT_EVENT_PREFIX_LEN) == 0) { + ki->driver = KdFindKeyboardDriver("evdev"); + ki->options = input_option_new(ki->options, "driver", "evdev"); + } +#endif } KdKeyboardInfo * @@ -1160,22 +1177,48 @@ KdParsePointerOptions(KdPointerInfo * pi) const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); - if (!strcmp(key, "emulatemiddle")) + if (!strcasecmp(key, "emulatemiddle")) pi->emulateMiddleButton = TRUE; - else if (!strcmp(key, "noemulatemiddle")) + else if (!strcasecmp(key, "noemulatemiddle")) pi->emulateMiddleButton = FALSE; - else if (!strcmp(key, "transformcoord")) + else if (!strcasecmp(key, "transformcoord")) pi->transformCoordinates = TRUE; - else if (!strcmp(key, "rawcoord")) + else if (!strcasecmp(key, "rawcoord")) pi->transformCoordinates = FALSE; - else if (!strcasecmp(key, "device")) + else if (!strcasecmp(key, "device")) { + if (pi->path != NULL) + free(pi->path); pi->path = strdup(value); + } +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) + else if (!strcasecmp(key, "path")) { + if (pi->path != NULL) + free(pi->path); + pi->path = strdup(value); + } + else if (!strcasecmp(key, "name")) { + free(pi->name); + pi->name = strdup(value); + } +#endif else if (!strcasecmp(key, "protocol")) pi->protocol = strdup(value); + else if (!strcasecmp(key, "driver")) + pi->driver = KdFindPointerDriver(value); else ErrorF("Pointer option key (%s) of value (%s) not assigned!\n", key, value); } + +#ifdef KDRIVE_EVDEV + if (!pi->driver && pi->path != NULL && + strncasecmp(pi->path, + DEV_INPUT_EVENT_PREFIX, + DEV_INPUT_EVENT_PREFIX_LEN) == 0) { + pi->driver = KdFindPointerDriver("evdev"); + pi->options = input_option_new(pi->options, "driver", "evdev"); + } +#endif } KdPointerInfo * @@ -1262,6 +1305,9 @@ KdInitInput(void) KdKeyboardInfo *ki; struct KdConfigDevice *dev; + if (kdConfigPointers || kdConfigKeyboards) + InputThreadPreInit(); + kdInputEnabled = TRUE; for (dev = kdConfigPointers; dev; dev = dev->next) { @@ -1280,11 +1326,21 @@ KdInitInput(void) } mieqInit(); + +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) + if (SeatId) /* Enable input hot-plugging */ + config_init(); +#endif } void KdCloseInput(void) { +#if defined(CONFIG_UDEV) || defined(CONFIG_HAL) + if (SeatId) /* Input hot-plugging is enabled */ + config_fini(); +#endif + mieqFini(); } @@ -1740,7 +1796,7 @@ KdReleaseAllKeys(void) int key; KdKeyboardInfo *ki; - OsBlockSIGIO(); + input_lock(); for (ki = kdKeyboards; ki; ki = ki->next) { for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode; key++) { @@ -1751,7 +1807,7 @@ KdReleaseAllKeys(void) } } - OsReleaseSIGIO(); + input_unlock(); #endif } @@ -1905,7 +1961,7 @@ _KdEnqueuePointerEvent(KdPointerInfo * pi, int type, int x, int y, int z, } void -KdBlockHandler(ScreenPtr pScreen, void *timeo, void *readmask) +KdBlockHandler(ScreenPtr pScreen, void *timeo) { KdPointerInfo *pi; int myTimeout = 0; @@ -1931,28 +1987,17 @@ KdBlockHandler(ScreenPtr pScreen, void *timeo, void *readmask) } void -KdWakeupHandler(ScreenPtr pScreen, unsigned long lresult, void *readmask) +KdWakeupHandler(ScreenPtr pScreen, int result) { - int result = (int) lresult; - fd_set *pReadmask = (fd_set *) readmask; - int i; KdPointerInfo *pi; - if (kdInputEnabled && result > 0) { - for (i = 0; i < kdNumInputFds; i++) - if (FD_ISSET(kdInputFds[i].fd, pReadmask)) { - OsBlockSIGIO(); - (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure); - OsReleaseSIGIO(); - } - } for (pi = kdPointers; pi; pi = pi->next) { if (pi->timeoutPending) { if ((long) (GetTimeInMillis() - pi->emulationTimeout) >= 0) { pi->timeoutPending = FALSE; - OsBlockSIGIO(); + input_lock(); KdReceiveTimeout(pi); - OsReleaseSIGIO(); + input_unlock(); } } } @@ -2049,10 +2094,10 @@ int KdCurScreen; /* current event screen */ static void KdWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) { - OsBlockSIGIO(); + input_lock(); KdCurScreen = pScreen->myNum; miPointerWarpCursor(pDev, pScreen, x, y); - OsReleaseSIGIO(); + input_unlock(); } miPointerScreenFuncRec kdPointerScreenFuncs = { @@ -2112,24 +2157,29 @@ int NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, DeviceIntPtr *pdev) { - InputOption *option = NULL; + InputOption *option = NULL, *optionsdup = NULL; KdPointerInfo *pi = NULL; KdKeyboardInfo *ki = NULL; nt_list_for_each_entry(option, options, list.next) { const char *key = input_option_get_key(option); const char *value = input_option_get_value(option); + optionsdup = input_option_new(optionsdup, key, value); if (strcmp(key, "type") == 0) { if (strcmp(value, "pointer") == 0) { pi = KdNewPointer(); - if (!pi) + if (!pi) { + input_option_free_list(&optionsdup); return BadAlloc; + } } else if (strcmp(value, "keyboard") == 0) { ki = KdNewKeyboard(); - if (!ki) + if (!ki) { + input_option_free_list(&optionsdup); return BadAlloc; + } } else { ErrorF("unrecognised device type!\n"); @@ -2139,81 +2189,110 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, #ifdef CONFIG_HAL else if (strcmp(key, "_source") == 0 && strcmp(value, "server/hal") == 0) { - ErrorF("Ignoring device from HAL.\n"); - return BadValue; + if (SeatId) { + /* Input hot-plugging is enabled */ + if (attrs->flags & ATTR_POINTER) { + pi = KdNewPointer(); + if (!pi) { + input_option_free_list(&optionsdup); + return BadAlloc; + } + } + else if (attrs->flags & ATTR_KEYBOARD) { + ki = KdNewKeyboard(); + if (!ki) { + input_option_free_list(&optionsdup); + return BadAlloc; + } + } + } + else { + ErrorF("Ignoring device from HAL.\n"); + input_option_free_list(&optionsdup); + return BadValue; + } } #endif #ifdef CONFIG_UDEV else if (strcmp(key, "_source") == 0 && strcmp(value, "server/udev") == 0) { - ErrorF("Ignoring device from udev.\n"); - return BadValue; - } -#endif - } - - if (!ki && !pi) { - ErrorF("unrecognised device identifier!\n"); - return BadValue; - } - - /* FIXME: change this code below to use KdParseKbdOptions and - * KdParsePointerOptions */ - nt_list_for_each_entry(option, options, list.next) { - const char *key = input_option_get_key(option); - const char *value = input_option_get_value(option); - - if (strcmp(key, "device") == 0) { - if (pi && value) - pi->path = strdup(value); - else if (ki && value) - ki->path = strdup(value); - } - else if (strcmp(key, "driver") == 0) { - if (pi) { - pi->driver = KdFindPointerDriver(value); - if (!pi->driver) { - ErrorF("couldn't find driver!\n"); - KdFreePointer(pi); - return BadValue; + if (SeatId) { + /* Input hot-plugging is enabled */ + if (attrs->flags & ATTR_POINTER) { + pi = KdNewPointer(); + if (!pi) { + input_option_free_list(&optionsdup); + return BadAlloc; + } } - pi->options = options; - } - else if (ki) { - ki->driver = KdFindKeyboardDriver(value); - if (!ki->driver) { - ErrorF("couldn't find driver!\n"); - KdFreeKeyboard(ki); - return BadValue; + else if (attrs->flags & ATTR_KEYBOARD) { + ki = KdNewKeyboard(); + if (!ki) { + input_option_free_list(&optionsdup); + return BadAlloc; + } } - ki->options = options; + } + else { + ErrorF("Ignoring device from udev.\n"); + input_option_free_list(&optionsdup); + return BadValue; } } +#endif } if (pi) { + pi->options = optionsdup; + KdParsePointerOptions(pi); + + if (!pi->driver) { + ErrorF("couldn't find driver for pointer device \"%s\" (%s)\n", + pi->name ? pi->name : "(unnamed)", pi->path); + KdFreePointer(pi); + return BadValue; + } + if (KdAddPointer(pi) != Success || ActivateDevice(pi->dixdev, TRUE) != Success || EnableDevice(pi->dixdev, TRUE) != TRUE) { - ErrorF("couldn't add or enable pointer\n"); + ErrorF("couldn't add or enable pointer \"%s\" (%s)\n", + pi->name ? pi->name : "(unnamed)", pi->path); + KdFreePointer(pi); return BadImplementation; } + + *pdev = pi->dixdev; } else if (ki) { + ki->options = optionsdup; + KdParseKbdOptions(ki); + + if (!ki->driver) { + ErrorF("couldn't find driver for keyboard device \"%s\" (%s)\n", + ki->name ? ki->name : "(unnamed)", ki->path); + KdFreeKeyboard(ki); + return BadValue; + } + if (KdAddKeyboard(ki) != Success || ActivateDevice(ki->dixdev, TRUE) != Success || EnableDevice(ki->dixdev, TRUE) != TRUE) { - ErrorF("couldn't add or enable keyboard\n"); + ErrorF("couldn't add or enable keyboard \"%s\" (%s)\n", + ki->name ? ki->name : "(unnamed)", ki->path); + KdFreeKeyboard(ki); return BadImplementation; } - } - if (pi) { - *pdev = pi->dixdev; - } - else if (ki) { *pdev = ki->dixdev; } + else { + ErrorF("unrecognised device identifier: %s\n", + input_option_get_value(input_option_find(optionsdup, + "device"))); + input_option_free_list(&optionsdup); + return BadValue; + } return Success; } @@ -2223,3 +2302,8 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev) { RemoveDevice(pDev, TRUE); } + +void +RemoveInputDeviceTraces(const char *config_info) +{ +} |