aboutsummaryrefslogtreecommitdiff
path: root/xorg-server
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server')
-rw-r--r--xorg-server/Xi/stubs.c3
-rw-r--r--xorg-server/config/Makefile.am20
-rw-r--r--xorg-server/config/config-backends.h21
-rw-r--r--xorg-server/config/config.c77
-rw-r--r--xorg-server/config/dbus-api40
-rw-r--r--xorg-server/config/dbus.c2
-rw-r--r--xorg-server/config/hal.c88
-rw-r--r--xorg-server/config/udev.c260
-rw-r--r--xorg-server/configure.ac31
-rw-r--r--xorg-server/cpprules.in3
-rw-r--r--xorg-server/dix/devices.c6
-rw-r--r--xorg-server/dix/ptrveloc.c2372
-rw-r--r--xorg-server/doc/c-extensions61
-rw-r--r--xorg-server/exa/exa.c6
-rw-r--r--xorg-server/exa/exa_accel.c35
-rw-r--r--xorg-server/exa/exa_migration_classic.c3
-rw-r--r--xorg-server/exa/exa_migration_mixed.c58
-rw-r--r--xorg-server/exa/exa_mixed.c18
-rw-r--r--xorg-server/exa/exa_priv.h15
-rw-r--r--xorg-server/exa/exa_unaccel.c347
-rw-r--r--xorg-server/hw/dmx/dmxinput.c3
-rw-r--r--xorg-server/hw/kdrive/Xkdrive.man57
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.c6
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.h407
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdriext.c21
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrglxext.c28
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostproxy.c94
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostproxy.h51
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c6
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrproxyext.c119
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrproxyext.h34
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrvideo.c19
-rw-r--r--xorg-server/hw/kdrive/fake/fake.c5
-rw-r--r--xorg-server/hw/kdrive/fake/fake.h1
-rw-r--r--xorg-server/hw/kdrive/fbdev/Xfbdev.man28
-rw-r--r--xorg-server/hw/kdrive/fbdev/fbdev.h7
-rw-r--r--xorg-server/hw/kdrive/linux/bus.c3
-rw-r--r--xorg-server/hw/kdrive/linux/keyboard.c14
-rw-r--r--xorg-server/hw/kdrive/linux/tslib.c14
-rw-r--r--xorg-server/hw/kdrive/src/kinfo.c36
-rw-r--r--xorg-server/hw/kdrive/src/kinput.c85
-rw-r--r--xorg-server/hw/kdrive/src/kxv.c303
-rw-r--r--xorg-server/hw/xfree86/common/xf86AutoConfig.c3
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c211
-rw-r--r--xorg-server/hw/xfree86/common/xf86Globals.c3
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c15
-rw-r--r--xorg-server/hw/xfree86/common/xf86Module.h2
-rw-r--r--xorg-server/hw/xfree86/common/xf86Option.c25
-rw-r--r--xorg-server/hw/xfree86/common/xf86Priv.h1
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.c119
-rw-r--r--xorg-server/hw/xfree86/doc/README.modes474
-rw-r--r--xorg-server/hw/xfree86/doc/man/Xorg.man.pre57
-rw-r--r--xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre239
-rw-r--r--xorg-server/hw/xfree86/exa/examodule.c37
-rw-r--r--xorg-server/hw/xfree86/parser/Configint.h2
-rw-r--r--xorg-server/hw/xfree86/parser/Input.c7
-rw-r--r--xorg-server/hw/xfree86/parser/InputClass.c232
-rw-r--r--xorg-server/hw/xfree86/parser/Layout.c96
-rw-r--r--xorg-server/hw/xfree86/parser/Makefile.am1
-rw-r--r--xorg-server/hw/xfree86/parser/configProcs.h4
-rw-r--r--xorg-server/hw/xfree86/parser/read.c8
-rw-r--r--xorg-server/hw/xfree86/parser/scan.c356
-rw-r--r--xorg-server/hw/xfree86/parser/write.c2
-rw-r--r--xorg-server/hw/xfree86/parser/xf86Parser.h47
-rw-r--r--xorg-server/hw/xfree86/parser/xf86tokens.h13
-rw-r--r--xorg-server/hw/xquartz/GL/glcontextmodes.c550
-rw-r--r--xorg-server/hw/xquartz/GL/glcontextmodes.h54
-rw-r--r--xorg-server/hw/xquartz/darwinXinput.c3
-rw-r--r--xorg-server/hw/xwin/InitOutput.c3
-rw-r--r--xorg-server/hw/xwin/winconfig.c2072
-rw-r--r--xorg-server/hw/xwin/winconfig.h1
-rw-r--r--xorg-server/hw/xwin/winprocarg.c18
-rw-r--r--xorg-server/hw/xwin/xlaunch/config.h7
-rw-r--r--xorg-server/hw/xwin/xlaunch/main.cc84
-rw-r--r--xorg-server/include/dix-config.h.in6
-rw-r--r--xorg-server/include/input.h16
-rw-r--r--xorg-server/include/ptrveloc.h3
-rw-r--r--xorg-server/include/xorg-config.h.in3
-rw-r--r--xorg-server/test/xi2/protocol-eventconvert.c5
79 files changed, 6245 insertions, 3341 deletions
diff --git a/xorg-server/Xi/stubs.c b/xorg-server/Xi/stubs.c
index 400e937d1..04ba9769e 100644
--- a/xorg-server/Xi/stubs.c
+++ b/xorg-server/Xi/stubs.c
@@ -227,7 +227,8 @@ ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
*
*/
int
-NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
+NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
+ DeviceIntPtr *pdev)
{
return BadValue;
}
diff --git a/xorg-server/config/Makefile.am b/xorg-server/config/Makefile.am
index 7fa2df877..27f251b3a 100644
--- a/xorg-server/config/Makefile.am
+++ b/xorg-server/config/Makefile.am
@@ -1,12 +1,20 @@
-AM_CFLAGS = @DIX_CFLAGS@
+AM_CFLAGS = $(DIX_CFLAGS)
noinst_LTLIBRARIES = libconfig.la
libconfig_la_SOURCES = config.c config-backends.h
+if CONFIG_UDEV
+
+AM_CFLAGS += $(UDEV_CFLAGS)
+libconfig_la_SOURCES += udev.c
+libconfig_la_LIBADD = $(UDEV_LIBS)
+
+else
+
if CONFIG_NEED_DBUS
-AM_CFLAGS += @DBUS_CFLAGS@
+AM_CFLAGS += $(DBUS_CFLAGS)
libconfig_la_SOURCES += dbus-core.c
-endif
+libconfig_la_LIBADD = $(DBUS_LIBS)
if CONFIG_DBUS_API
dbusconfigdir = $(sysconfdir)/dbus-1/system.d
@@ -16,7 +24,13 @@ libconfig_la_SOURCES += dbus.c
endif
if CONFIG_HAL
+AM_CFLAGS += $(HAL_CFLAGS)
libconfig_la_SOURCES += hal.c
+libconfig_la_LIBADD += $(HAL_LIBS)
endif
+endif # CONFIG_NEED_DBUS
+
+endif # !CONFIG_UDEV
+
EXTRA_DIST = xorg-server.conf x11-input.fdi
diff --git a/xorg-server/config/config-backends.h b/xorg-server/config/config-backends.h
index 907e86b9c..0a2a22af0 100644
--- a/xorg-server/config/config-backends.h
+++ b/xorg-server/config/config-backends.h
@@ -26,8 +26,18 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
+#include "input.h"
-#ifdef CONFIG_NEED_DBUS
+void remove_devices(const char *backend, const char *config_info);
+BOOL device_is_duplicate(const char *config_info);
+void add_option(InputOption **options, const char *key, const char *value);
+
+#ifdef CONFIG_UDEV
+int config_udev_init(void);
+void config_udev_fini(void);
+#else
+
+# ifdef CONFIG_NEED_DBUS
#include <dbus/dbus.h>
typedef void (*config_dbus_core_connect_hook)(DBusConnection *connection,
@@ -46,14 +56,15 @@ int config_dbus_core_init(void);
void config_dbus_core_fini(void);
int config_dbus_core_add_hook(struct config_dbus_core_hook *hook);
void config_dbus_core_remove_hook(struct config_dbus_core_hook *hook);
-#endif
+# endif
-#ifdef CONFIG_DBUS_API
+# ifdef CONFIG_DBUS_API
int config_dbus_init(void);
void config_dbus_fini(void);
-#endif
+# endif
-#ifdef CONFIG_HAL
+# ifdef CONFIG_HAL
int config_hal_init(void);
void config_hal_fini(void);
+# endif
#endif
diff --git a/xorg-server/config/config.c b/xorg-server/config/config.c
index b01329339..7bf5e4179 100644
--- a/xorg-server/config/config.c
+++ b/xorg-server/config/config.c
@@ -28,13 +28,17 @@
#endif
#include "os.h"
+#include "inputstr.h"
#include "hotplug.h"
#include "config-backends.h"
void
config_init(void)
{
-#if defined(CONFIG_DBUS_API) || defined(CONFIG_HAL)
+#ifdef CONFIG_UDEV
+ if (!config_udev_init())
+ ErrorF("[config] failed to initialise udev\n");
+#elif defined(CONFIG_NEED_DBUS)
if (config_dbus_core_init()) {
# ifdef CONFIG_DBUS_API
if (!config_dbus_init())
@@ -54,7 +58,9 @@ config_init(void)
void
config_fini(void)
{
-#if defined(CONFIG_DBUS_API) || defined(CONFIG_HAL)
+#if defined(CONFIG_UDEV)
+ config_udev_fini();
+#elif defined(CONFIG_NEED_DBUS)
# ifdef CONFIG_HAL
config_hal_fini();
# endif
@@ -64,3 +70,70 @@ config_fini(void)
config_dbus_core_fini();
#endif
}
+
+static void
+remove_device(const char *backend, DeviceIntPtr dev)
+{
+ /* this only gets called for devices that have already been added */
+ LogMessage(X_INFO, "config/%s: removing device %s\n", backend, dev->name);
+
+ /* Call PIE here so we don't try to dereference a device that's
+ * already been removed. */
+ OsBlockSignals();
+ ProcessInputEvents();
+ DeleteInputDeviceRequest(dev);
+ OsReleaseSignals();
+}
+
+void
+remove_devices(const char *backend, const char *config_info)
+{
+ DeviceIntPtr dev, next;
+
+ for (dev = inputInfo.devices; dev; dev = next) {
+ next = dev->next;
+ if (dev->config_info && strcmp(dev->config_info, config_info) == 0)
+ remove_device(backend, dev);
+ }
+ for (dev = inputInfo.off_devices; dev; dev = next) {
+ next = dev->next;
+ if (dev->config_info && strcmp(dev->config_info, config_info) == 0)
+ remove_device(backend, dev);
+ }
+}
+
+BOOL
+device_is_duplicate(const char *config_info)
+{
+ DeviceIntPtr dev;
+
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (dev->config_info && (strcmp(dev->config_info, config_info) == 0))
+ return TRUE;
+ }
+
+ for (dev = inputInfo.off_devices; dev; dev = dev->next)
+ {
+ if (dev->config_info && (strcmp(dev->config_info, config_info) == 0))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void
+add_option(InputOption **options, const char *key, const char *value)
+{
+ if (!value || *value == '\0')
+ return;
+
+ for (; *options; options = &(*options)->next)
+ ;
+ *options = xcalloc(sizeof(**options), 1);
+ if (!*options) /* Yeesh. */
+ return;
+ (*options)->key = xstrdup(key);
+ (*options)->value = xstrdup(value);
+ (*options)->next = NULL;
+}
diff --git a/xorg-server/config/dbus-api b/xorg-server/config/dbus-api
new file mode 100644
index 000000000..018e98657
--- /dev/null
+++ b/xorg-server/config/dbus-api
@@ -0,0 +1,40 @@
+D-BUS Configuration API v2
+----------------------------
+
+The X server will register the bus name org.x.config.displayN, and the
+object /org/x/config/N, where N is the display number.
+
+Currently only hotplugging of input devices is supported.
+
+org.x.config.input:
+ org.x.config.input.version:
+ Returns one unsigned int32, which is the API version.
+
+ org.x.config.input.add:
+ Takes an argument of key/value option pairs in arrays, e.g.:
+ [ss][ss][ss][ss]
+ is the signature for four options. These options will be passed
+ to the input driver as with any others.
+ Option names beginning with _ are not allowed; they are reserved
+ for internal use.
+
+ Returns a number of signed int32s. Positive integers are the
+ device IDs of new devices; negative numbers are X error codes,
+ as defined in X.h. BadMatch will be returned if the options
+ given do not match any device. BadValue is returned for a malformed
+ message. (Example: 8 is new device ID 8; -8 is BadMatch.)
+
+ Notably, BadAlloc is never returned: the server internally signals
+ to D-BUS that the attempt failed for lack of memory.
+
+ org.x.config.input.remove:
+ Takes one uint32 argument, which is the device ID to remove, i.e.:
+ u
+ is the signature.
+
+ Returns one signed int32 which represents an X status as defined in
+ X.h. See org.x.config.input.add. Error codes are negative numbers.
+
+ org.x.config.input.listDevices:
+ Lists the currently active devices. No argument.
+ Return value is sequence of [<id> <name>] [<id> <name>] ..., i.e. [us].
diff --git a/xorg-server/config/dbus.c b/xorg-server/config/dbus.c
index 37462ace0..86d9d287f 100644
--- a/xorg-server/config/dbus.c
+++ b/xorg-server/config/dbus.c
@@ -147,7 +147,7 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
dbus_message_iter_next(&iter);
}
- ret = NewInputDeviceRequest(options, &dev);
+ ret = NewInputDeviceRequest(options, NULL, &dev);
if (ret != Success) {
DebugF("[config/dbus] NewInputDeviceRequest failed\n");
goto unwind;
diff --git a/xorg-server/config/hal.c b/xorg-server/config/hal.c
index 28f55a02f..1b01eccaa 100644
--- a/xorg-server/config/hal.c
+++ b/xorg-server/config/hal.c
@@ -58,25 +58,9 @@ struct xkb_options {
char* options;
};
-
-static void
-remove_device(DeviceIntPtr dev)
-{
- /* this only gets called for devices that have already been added */
- LogMessage(X_INFO, "config/hal: removing device %s\n", dev->name);
-
- /* Call PIE here so we don't try to dereference a device that's
- * already been removed. */
- OsBlockSignals();
- ProcessInputEvents();
- DeleteInputDeviceRequest(dev);
- OsReleaseSignals();
-}
-
static void
device_removed(LibHalContext *ctx, const char *udi)
{
- DeviceIntPtr dev, next;
char *value;
value = xalloc(strlen(udi) + 5); /* "hal:" + NULL */
@@ -84,36 +68,11 @@ device_removed(LibHalContext *ctx, const char *udi)
return;
sprintf(value, "hal:%s", udi);
- for (dev = inputInfo.devices; dev; dev = next) {
- next = dev->next;
- if (dev->config_info && strcmp(dev->config_info, value) == 0)
- remove_device(dev);
- }
- for (dev = inputInfo.off_devices; dev; dev = next) {
- next = dev->next;
- if (dev->config_info && strcmp(dev->config_info, value) == 0)
- remove_device(dev);
- }
+ remove_devices("hal", value);
xfree(value);
}
-static void
-add_option(InputOption **options, const char *key, const char *value)
-{
- if (!value || *value == '\0')
- return;
-
- for (; *options; options = &(*options)->next)
- ;
- *options = xcalloc(sizeof(**options), 1);
- if (!*options) /* Yeesh. */
- return;
- (*options)->key = xstrdup(key);
- (*options)->value = xstrdup(value);
- (*options)->next = NULL;
-}
-
static char *
get_prop_string(LibHalContext *hal_ctx, const char *udi, const char *name)
{
@@ -166,31 +125,12 @@ get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop)
return ret;
}
-static BOOL
-device_is_duplicate(char *config_info)
-{
- DeviceIntPtr dev;
-
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (dev->config_info && (strcmp(dev->config_info, config_info) == 0))
- return TRUE;
- }
-
- for (dev = inputInfo.off_devices; dev; dev = dev->next)
- {
- if (dev->config_info && (strcmp(dev->config_info, config_info) == 0))
- return TRUE;
- }
-
- return FALSE;
-}
-
static void
device_added(LibHalContext *hal_ctx, const char *udi)
{
char *path = NULL, *driver = NULL, *name = NULL, *config_info = NULL;
InputOption *options = NULL, *tmpo = NULL;
+ InputAttributes attrs = {0};
DeviceIntPtr dev = NULL;
DBusError error;
struct xkb_options xkb_opts = {0};
@@ -215,10 +155,28 @@ device_added(LibHalContext *hal_ctx, const char *udi)
LogMessage(X_WARNING,"config/hal: no driver or path specified for %s\n", udi);
goto unwind;
}
+ attrs.device = xstrdup(path);
name = get_prop_string(hal_ctx, udi, "info.product");
if (!name)
name = xstrdup("(unnamed)");
+ else
+ attrs.product = xstrdup(name);
+
+ attrs.vendor = get_prop_string(hal_ctx, udi, "info.vendor");
+
+ if (libhal_device_query_capability(hal_ctx, udi, "input.keys", NULL))
+ attrs.flags |= ATTR_KEYBOARD;
+ if (libhal_device_query_capability(hal_ctx, udi, "input.mouse", NULL))
+ attrs.flags |= ATTR_POINTER;
+ if (libhal_device_query_capability(hal_ctx, udi, "input.joystick", NULL))
+ attrs.flags |= ATTR_JOYSTICK;
+ if (libhal_device_query_capability(hal_ctx, udi, "input.tablet", NULL))
+ attrs.flags |= ATTR_TABLET;
+ if (libhal_device_query_capability(hal_ctx, udi, "input.touchpad", NULL))
+ attrs.flags |= ATTR_TOUCHPAD;
+ if (libhal_device_query_capability(hal_ctx, udi, "input.touchscreen", NULL))
+ attrs.flags |= ATTR_TOUCHSCREEN;
options = xcalloc(sizeof(*options), 1);
if (!options){
@@ -400,7 +358,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
/* this isn't an error, but how else do you output something that the user can see? */
LogMessage(X_INFO, "config/hal: Adding input device %s\n", name);
- if ((rc = NewInputDeviceRequest(options, &dev)) != Success) {
+ if ((rc = NewInputDeviceRequest(options, &attrs, &dev)) != Success) {
LogMessage(X_ERROR, "config/hal: NewInputDeviceRequest failed (%d)\n", rc);
dev = NULL;
goto unwind;
@@ -430,6 +388,10 @@ unwind:
xfree(tmpo);
}
+ xfree(attrs.product);
+ xfree(attrs.vendor);
+ xfree(attrs.device);
+
if (xkb_opts.layout)
xfree(xkb_opts.layout);
if (xkb_opts.rules)
diff --git a/xorg-server/config/udev.c b/xorg-server/config/udev.c
new file mode 100644
index 000000000..3ef0d7fb3
--- /dev/null
+++ b/xorg-server/config/udev.c
@@ -0,0 +1,260 @@
+/*
+ * Copyright © 2009 Julien Cristau
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Julien Cristau <jcristau@debian.org>
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <libudev.h>
+
+#include "input.h"
+#include "inputstr.h"
+#include "hotplug.h"
+#include "config-backends.h"
+#include "os.h"
+
+#define UDEV_XKB_PROP_KEY "xkb"
+
+static struct udev_monitor *udev_monitor;
+
+static void
+device_added(struct udev_device *udev_device)
+{
+ const char *path, *name = NULL;
+ char *config_info = NULL;
+ const char *syspath;
+ const char *key, *value, *tmp;
+ InputOption *options = NULL, *tmpo;
+ InputAttributes attrs = {};
+ DeviceIntPtr dev = NULL;
+ struct udev_list_entry *set, *entry;
+ struct udev_device *parent;
+ int rc;
+
+ path = udev_device_get_devnode(udev_device);
+
+ syspath = udev_device_get_syspath(udev_device);
+
+ if (!path || !syspath)
+ return;
+
+ if (!udev_device_get_property_value(udev_device, "ID_INPUT"))
+ return;
+
+ options = xcalloc(sizeof(*options), 1);
+ if (!options)
+ return;
+
+ options->key = xstrdup("_source");
+ options->value = xstrdup("server/udev");
+ if (!options->key || !options->value)
+ goto unwind;
+
+ parent = udev_device_get_parent(udev_device);
+ if (parent)
+ name = udev_device_get_property_value(parent, "NAME");
+ if (!name)
+ name = "(unnamed)";
+ else
+ attrs.product = name;
+ add_option(&options, "name", name);
+
+ add_option(&options, "path", path);
+ add_option(&options, "device", path);
+ attrs.device = path;
+
+ config_info = Xprintf("udev:%s", syspath);
+ if (!config_info)
+ goto unwind;
+
+ if (device_is_duplicate(config_info)) {
+ LogMessage(X_WARNING, "config/udev: device %s already added. "
+ "Ignoring.\n", name);
+ goto unwind;
+ }
+
+ set = udev_device_get_properties_list_entry(udev_device);
+ udev_list_entry_foreach(entry, set) {
+ key = udev_list_entry_get_name(entry);
+ if (!key)
+ continue;
+ value = udev_list_entry_get_value(entry);
+ if (!strncasecmp(key, UDEV_XKB_PROP_KEY,
+ sizeof(UDEV_XKB_PROP_KEY) - 1)) {
+ tmp = key + sizeof(UDEV_XKB_PROP_KEY) - 1;
+ if (!strcasecmp(tmp, "rules"))
+ add_option(&options, "xkb_rules", value);
+ else if (!strcasecmp(tmp, "layout"))
+ add_option(&options, "xkb_layout", value);
+ else if (!strcasecmp(tmp, "variant"))
+ add_option(&options, "xkb_variant", value);
+ else if (!strcasecmp(tmp, "model"))
+ add_option(&options, "xkb_model", value);
+ else if (!strcasecmp(tmp, "options"))
+ add_option(&options, "xkb_options", value);
+ } else if (!strcmp(key, "ID_VENDOR")) {
+ attrs.vendor = value;
+ } else if (!strcmp(key, "ID_INPUT_KEY")) {
+ attrs.flags |= ATTR_KEYBOARD;
+ } else if (!strcmp(key, "ID_INPUT_MOUSE")) {
+ attrs.flags |= ATTR_POINTER;
+ } else if (!strcmp(key, "ID_INPUT_JOYSTICK")) {
+ attrs.flags |= ATTR_JOYSTICK;
+ } else if (!strcmp(key, "ID_INPUT_TABLET")) {
+ attrs.flags |= ATTR_TABLET;
+ } else if (!strcmp(key, "ID_INPUT_TOUCHPAD")) {
+ attrs.flags |= ATTR_TOUCHPAD;
+ } else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) {
+ attrs.flags |= ATTR_TOUCHSCREEN;
+ }
+ }
+ LogMessage(X_INFO, "config/udev: Adding input device %s (%s)\n",
+ name, path);
+ rc = NewInputDeviceRequest(options, &attrs, &dev);
+ if (rc != Success)
+ goto unwind;
+
+ for (; dev; dev = dev->next) {
+ xfree(dev->config_info);
+ dev->config_info = xstrdup(config_info);
+ }
+
+ unwind:
+ xfree(config_info);
+ while (!dev && (tmpo = options)) {
+ options = tmpo->next;
+ xfree(tmpo->key);
+ xfree(tmpo->value);
+ xfree(tmpo);
+ }
+
+ return;
+}
+
+static void
+device_removed(struct udev_device *device)
+{
+ char *value;
+ const char *syspath = udev_device_get_syspath(device);
+
+ value = Xprintf("udev:%s", syspath);
+ if (!value)
+ return;
+
+ remove_devices("udev", value);
+
+ xfree(value);
+}
+
+static void
+wakeup_handler(pointer data, int err, pointer read_mask)
+{
+ int udev_fd = udev_monitor_get_fd(udev_monitor);
+ struct udev_device *udev_device;
+ const char *action;
+
+ if (err < 0)
+ return;
+
+ if (FD_ISSET(udev_fd, (fd_set *)read_mask)) {
+ udev_device = udev_monitor_receive_device(udev_monitor);
+ if (!udev_device)
+ return;
+ action = udev_device_get_action(udev_device);
+ if (action) {
+ if (!strcmp(action, "add"))
+ device_added(udev_device);
+ else if (!strcmp(action, "remove"))
+ device_removed(udev_device);
+ }
+ udev_device_unref(udev_device);
+ }
+}
+
+static void
+block_handler(pointer data, struct timeval **tv, pointer read_mask)
+{
+}
+
+int
+config_udev_init(void)
+{
+ struct udev *udev;
+ struct udev_enumerate *enumerate;
+ struct udev_list_entry *devices, *device;
+ int rc;
+
+ udev = udev_new();
+ if (!udev)
+ return 0;
+ udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
+ if (!udev_monitor)
+ return 0;
+ rc = udev_monitor_filter_add_match_subsystem_devtype(udev_monitor,
+ "input", NULL);
+ if (rc < 0)
+ return 0;
+
+ if (udev_monitor_enable_receiving(udev_monitor)) {
+ ErrorF("config/udev: failed to bind the udev monitor\n");
+ return 0;
+ }
+
+ enumerate = udev_enumerate_new(udev);
+ if (!enumerate)
+ return 0;
+ udev_enumerate_add_match_subsystem(enumerate, "input");
+ udev_enumerate_scan_devices(enumerate);
+ devices = udev_enumerate_get_list_entry(enumerate);
+ udev_list_entry_foreach(device, devices) {
+ const char *syspath = udev_list_entry_get_name(device);
+ struct udev_device *udev_device = udev_device_new_from_syspath(udev, syspath);
+ device_added(udev_device);
+ udev_device_unref(udev_device);
+ }
+ udev_enumerate_unref(enumerate);
+
+ RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
+ AddGeneralSocket(udev_monitor_get_fd(udev_monitor));
+
+ return 1;
+}
+
+void
+config_udev_fini(void)
+{
+ struct udev *udev;
+
+ if (!udev_monitor)
+ return;
+
+ udev = udev_monitor_get_udev(udev_monitor);
+
+ RemoveGeneralSocket(udev_monitor_get_fd(udev_monitor));
+ RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, udev_monitor);
+ udev_monitor_unref(udev_monitor);
+ udev_monitor = NULL;
+ udev_unref(udev);
+}
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac
index fe28a07cc..7e2c6a51e 100644
--- a/xorg-server/configure.ac
+++ b/xorg-server/configure.ac
@@ -26,8 +26,8 @@ dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.7.99.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2009-12-18"
+AC_INIT([xorg-server], 1.7.99.3, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="(unreleased)"
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
@@ -122,7 +122,7 @@ AM_CONDITIONAL(SPECIAL_DTRACE_OBJECTS, [test "x$SPECIAL_DTRACE_OBJECTS" = "xyes"
AC_HEADER_DIRENT
AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h dlfcn.h stropts.h])
+AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h dlfcn.h stropts.h fnmatch.h])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@@ -618,6 +618,7 @@ AC_ARG_ENABLE(multibuffer, AS_HELP_STRING([--enable-multibuffer], [Build Mult
AC_ARG_ENABLE(dbe, AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
AC_ARG_ENABLE(xf86bigfont, AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: disabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=no])
AC_ARG_ENABLE(dpms, AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
+AC_ARG_ENABLE(config-udev, AS_HELP_STRING([--enable-config-udev], [Build udev support (default: no)]), [CONFIG_UDEV=$enableval], [CONFIG_UDEV=no])
AC_ARG_ENABLE(config-dbus, AS_HELP_STRING([--enable-config-dbus], [Build D-BUS API support (default: no)]), [CONFIG_DBUS_API=$enableval], [CONFIG_DBUS_API=no])
AC_ARG_ENABLE(config-hal, AS_HELP_STRING([--disable-config-hal], [Build HAL support (default: auto)]), [CONFIG_HAL=$enableval], [CONFIG_HAL=auto])
AC_ARG_ENABLE(xfree86-utils, AS_HELP_STRING([--enable-xfree86-utils], [Build xfree86 DDX utilities (default: enabled)]), [XF86UTILS=$enableval], [XF86UTILS=yes])
@@ -775,6 +776,26 @@ LIBXI="xi >= 1.2.99.1"
LIBXTST="xtst >= 1.0.99.2"
LIBPCIACCESS="pciaccess >= 0.8.0"
LIBGLIB="glib-2.0 >= 2.16"
+LIBUDEV="libudev >= 143"
+
+if test "x$CONFIG_UDEV" = xyes &&
+ { test "x$CONFIG_DBUS_API" = xyes || test "x$CONFIG_HAL" = xyes; }; then
+ AC_MSG_ERROR([Hotplugging through both libudev and dbus/hal not allowed])
+fi
+
+PKG_CHECK_MODULES(UDEV, $LIBUDEV, [HAVE_LIBUDEV=yes], [HAVE_LIBUDEV=no])
+if test "x$CONFIG_UDEV" = xauto; then
+ CONFIG_UDEV="$HAVE_LIBUDEV"
+fi
+AM_CONDITIONAL(CONFIG_UDEV, [test "x$CONFIG_UDEV" = xyes])
+if test "x$CONFIG_UDEV" = xyes; then
+ CONFIG_DBUS_API=no
+ CONFIG_HAL=no
+ if ! test "x$HAVE_LIBUDEV" = xyes; then
+ AC_MSG_ERROR([udev configuration API requested, but libudev is not installed])
+ fi
+ AC_DEFINE(CONFIG_UDEV, 1, [Use libudev for input hotplug])
+fi
dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas
dnl CONFIG_DBUS_API is true if we want to enable the D-Bus config
@@ -808,13 +829,11 @@ if test "x$CONFIG_HAL" = xyes; then
fi
AC_DEFINE(CONFIG_HAL, 1, [Use the HAL hotplug API])
- REQUIRED_LIBS="$REQUIRED_LIBS hal"
CONFIG_NEED_DBUS="yes"
fi
AM_CONDITIONAL(CONFIG_HAL, [test "x$CONFIG_HAL" = xyes])
if test "x$CONFIG_NEED_DBUS" = xyes; then
- REQUIRED_LIBS="$REQUIRED_LIBS dbus-1"
AC_DEFINE(CONFIG_NEED_DBUS, 1, [Use D-Bus for input hotplug])
fi
AM_CONDITIONAL(CONFIG_NEED_DBUS, [test "x$CONFIG_NEED_DBUS" = xyes])
@@ -1737,6 +1756,7 @@ if test "x$XORG" = xyes; then
dnl these only go in xorg-config.h
XF86CONFIGFILE="xorg.conf"
+ XF86CONFIGDIR="xorg.conf.d"
CONFIGFILE="$sysconfdir/$XF86CONFIGFILE"
LOGPREFIX="$logdir/Xorg."
AC_DEFINE(XORG_SERVER, 1, [Building Xorg server])
@@ -1749,6 +1769,7 @@ if test "x$XORG" = xyes; then
AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server])
AC_DEFINE_DIR(__XCONFIGFILE__, XF86CONFIGFILE, [Name of configuration file])
AC_DEFINE_DIR(XF86CONFIGFILE, XF86CONFIGFILE, [Name of configuration file])
+ AC_DEFINE_DIR(__XCONFIGDIR__, XF86CONFIGDIR, [Name of configuration directory])
AC_DEFINE_DIR(DEFAULT_MODULE_PATH, moduledir, [Default module search path])
AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path])
AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location])
diff --git a/xorg-server/cpprules.in b/xorg-server/cpprules.in
index 7fcb9bd6f..7219e361f 100644
--- a/xorg-server/cpprules.in
+++ b/xorg-server/cpprules.in
@@ -36,7 +36,8 @@ MANDEFS = \
-D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) \
-D__mandir__=$(mandir) \
-D__projectroot__=$(prefix) \
- -D__xconfigfile__=$(__XCONFIGFILE__) -D__xconfigdir__=$(XCONFIGDIR) \
+ -D__xconfigfile__=$(__XCONFIGFILE__) \
+ -D__xconfigdir__=$(__XCONFIGDIR__) \
-D__xkbdir__=$(XKB_BASE_DIRECTORY) \
-D__modulepath__="$(DEFAULT_MODULE_PATH)" \
-D__xlogfile__=$(XLOGFILE) -D__xservername__=$(XSERVERNAME)
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index 6329d2810..92b95ed69 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -842,6 +842,9 @@ CloseDevice(DeviceIntPtr dev)
if(dev->valuator && dev->valuator->accelScheme.AccelCleanupProc)
dev->valuator->accelScheme.AccelCleanupProc(dev);
+ while (dev->xkb_interest)
+ XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
+
xfree(dev->name);
classes = (ClassesPtr)&dev->key;
@@ -853,9 +856,6 @@ CloseDevice(DeviceIntPtr dev)
FreeAllDeviceClasses(classes);
}
- while (dev->xkb_interest)
- XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
-
if (DevHasCursor(dev) && dev->spriteInfo->sprite) {
xfree(dev->spriteInfo->sprite->spriteTrace);
xfree(dev->spriteInfo->sprite);
diff --git a/xorg-server/dix/ptrveloc.c b/xorg-server/dix/ptrveloc.c
index 1aa0849aa..b9ece2159 100644
--- a/xorg-server/dix/ptrveloc.c
+++ b/xorg-server/dix/ptrveloc.c
@@ -1,1173 +1,1199 @@
-/*
- *
- * Copyright © 2006-2009 Simon Thum simon dot thum at gmx dot de
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifdef _MSC_VER
-#define _USE_MATH_DEFINES
-#endif
-
-#include <math.h>
-#include <ptrveloc.h>
-#include <exevents.h>
-#include <X11/Xatom.h>
-
-#include <xserver-properties.h>
-
-/*****************************************************************************
- * Predictable pointer acceleration
- *
- * 2006-2009 by Simon Thum (simon [dot] thum [at] gmx de)
- *
- * Serves 3 complementary functions:
- * 1) provide a sophisticated ballistic velocity estimate to improve
- * the relation between velocity (of the device) and acceleration
- * 2) make arbitrary acceleration profiles possible
- * 3) decelerate by two means (constant and adaptive) if enabled
- *
- * Important concepts are the
- *
- * - Scheme
- * which selects the basic algorithm
- * (see devices.c/InitPointerAccelerationScheme)
- * - Profile
- * which returns an acceleration
- * for a given velocity
- *
- * The profile can be selected by the user at runtime.
- * The classic profile is intended to cleanly perform old-style
- * function selection (threshold =/!= 0)
- *
- ****************************************************************************/
-
-#ifdef _MSC_VER
-#define inline __inline
-#define lrintf(val) ((int)val)
-#endif
-
-/* fwds */
-int
-SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
-static float
-SimpleSmoothProfile(DeviceIntPtr dev, DeviceVelocityPtr vel, float velocity,
- float threshold, float acc);
-static PointerAccelerationProfileFunc
-GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
-
-/*#define PTRACCEL_DEBUGGING*/
-
-#ifdef PTRACCEL_DEBUGGING
-#define DebugAccelF ErrorF
-#else
-#define DebugAccelF(...) /* */
-#endif
-
-/********************************
- * Init/Uninit
- *******************************/
-
-/* some int which is not a profile number */
-#define PROFILE_UNINITIALIZE (-100)
-
-/* number of properties for predictable acceleration */
-#define NPROPS_PREDICTABLE_ACCEL 4
-
-/**
- * Init struct so it should match the average case
- */
-void
-InitVelocityData(DeviceVelocityPtr vel)
-{
- memset(vel, 0, sizeof(DeviceVelocityRec));
-
- vel->corr_mul = 10.0; /* dots per 10 milisecond should be usable */
- vel->const_acceleration = 1.0; /* no acceleration/deceleration */
- vel->reset_time = 300;
- vel->use_softening = 1;
- vel->min_acceleration = 1.0; /* don't decelerate */
- vel->max_rel_diff = 0.2;
- vel->max_diff = 1.0;
- vel->initial_range = 2;
- vel->average_accel = TRUE;
- SetAccelerationProfile(vel, AccelProfileClassic);
- InitTrackers(vel, 16);
-}
-
-
-/**
- * Clean up
- */
-void
-FreeVelocityData(DeviceVelocityPtr vel){
- xfree(vel->tracker);
- SetAccelerationProfile(vel, PROFILE_UNINITIALIZE);
-}
-
-
-/*
- * dix uninit helper, called through scheme
- */
-void
-AccelerationDefaultCleanup(DeviceIntPtr dev)
-{
- /*sanity check*/
- if( dev->valuator->accelScheme.AccelSchemeProc == acceleratePointerPredictable
- && dev->valuator->accelScheme.accelData != NULL){
- dev->valuator->accelScheme.AccelSchemeProc = NULL;
- FreeVelocityData(dev->valuator->accelScheme.accelData);
- xfree(dev->valuator->accelScheme.accelData);
- dev->valuator->accelScheme.accelData = NULL;
- DeletePredictableAccelerationProperties(dev);
- }
-}
-
-
-/*************************
- * Input property support
- ************************/
-
-/**
- * choose profile
- */
-static int
-AccelSetProfileProperty(DeviceIntPtr dev, Atom atom,
- XIPropertyValuePtr val, BOOL checkOnly)
-{
- DeviceVelocityPtr vel;
- int profile, *ptr = &profile;
- int rc;
- int nelem = 1;
-
- if (atom != XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER))
- return Success;
-
- vel = GetDevicePredictableAccelData(dev);
- if (!vel)
- return BadValue;
- rc = XIPropToInt(val, &nelem, &ptr);
-
- if(checkOnly)
- {
- if (rc)
- return rc;
-
- if (GetAccelerationProfile(vel, profile) == NULL)
- return BadValue;
- } else
- SetAccelerationProfile(vel, profile);
-
- return Success;
-}
-
-static long
-AccelInitProfileProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
-{
- int profile = vel->statistics.profile_number;
- Atom prop_profile_number = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
-
- XIChangeDeviceProperty(dev, prop_profile_number, XA_INTEGER, 32,
- PropModeReplace, 1, &profile, FALSE);
- XISetDevicePropertyDeletable(dev, prop_profile_number, FALSE);
- return XIRegisterPropertyHandler(dev, AccelSetProfileProperty, NULL, NULL);
-}
-
-/**
- * constant deceleration
- */
-static int
-AccelSetDecelProperty(DeviceIntPtr dev, Atom atom,
- XIPropertyValuePtr val, BOOL checkOnly)
-{
- DeviceVelocityPtr vel;
- float v, *ptr = &v;
- int rc;
- int nelem = 1;
-
- if (atom != XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION))
- return Success;
-
- vel = GetDevicePredictableAccelData(dev);
- if (!vel)
- return BadValue;
- rc = XIPropToFloat(val, &nelem, &ptr);
-
- if(checkOnly)
- {
- if (rc)
- return rc;
- return (v >= 1.0f) ? Success : BadValue;
- }
-
- if(v >= 1.0f)
- vel->const_acceleration = 1/v;
-
- return Success;
-}
-
-static long
-AccelInitDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
-{
- float fval = 1.0/vel->const_acceleration;
- Atom prop_const_decel = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
- XIChangeDeviceProperty(dev, prop_const_decel,
- XIGetKnownProperty(XATOM_FLOAT), 32,
- PropModeReplace, 1, &fval, FALSE);
- XISetDevicePropertyDeletable(dev, prop_const_decel, FALSE);
- return XIRegisterPropertyHandler(dev, AccelSetDecelProperty, NULL, NULL);
-}
-
-
-/**
- * adaptive deceleration
- */
-static int
-AccelSetAdaptDecelProperty(DeviceIntPtr dev, Atom atom,
- XIPropertyValuePtr val, BOOL checkOnly)
-{
- DeviceVelocityPtr veloc;
- float v, *ptr = &v;
- int rc;
- int nelem = 1;
-
- if (atom != XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION))
- return Success;
-
- veloc = GetDevicePredictableAccelData(dev);
- if (!veloc)
- return BadValue;
- rc = XIPropToFloat(val, &nelem, &ptr);
-
- if(checkOnly)
- {
- if (rc)
- return rc;
- return (v >= 1.0f) ? Success : BadValue;
- }
-
- if(v >= 1.0f)
- veloc->min_acceleration = 1/v;
-
- return Success;
-}
-
-static long
-AccelInitAdaptDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
-{
- float fval = 1.0/vel->min_acceleration;
- Atom prop_adapt_decel = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
-
- XIChangeDeviceProperty(dev, prop_adapt_decel, XIGetKnownProperty(XATOM_FLOAT), 32,
- PropModeReplace, 1, &fval, FALSE);
- XISetDevicePropertyDeletable(dev, prop_adapt_decel, FALSE);
- return XIRegisterPropertyHandler(dev, AccelSetAdaptDecelProperty, NULL, NULL);
-}
-
-
-/**
- * velocity scaling
- */
-static int
-AccelSetScaleProperty(DeviceIntPtr dev, Atom atom,
- XIPropertyValuePtr val, BOOL checkOnly)
-{
- DeviceVelocityPtr vel;
- float v, *ptr = &v;
- int rc;
- int nelem = 1;
-
- if (atom != XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING))
- return Success;
-
- vel = GetDevicePredictableAccelData(dev);
- if (!vel)
- return BadValue;
- rc = XIPropToFloat(val, &nelem, &ptr);
-
- if (checkOnly)
- {
- if (rc)
- return rc;
-
- return (v > 0) ? Success : BadValue;
- }
-
- if(v > 0)
- vel->corr_mul = v;
-
- return Success;
-}
-
-static long
-AccelInitScaleProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
-{
- float fval = vel->corr_mul;
- Atom prop_velo_scale = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
-
- XIChangeDeviceProperty(dev, prop_velo_scale, XIGetKnownProperty(XATOM_FLOAT), 32,
- PropModeReplace, 1, &fval, FALSE);
- XISetDevicePropertyDeletable(dev, prop_velo_scale, FALSE);
- return XIRegisterPropertyHandler(dev, AccelSetScaleProperty, NULL, NULL);
-}
-
-static int AccelPropHandlerPrivateKeyIndex;
-DevPrivateKey AccelPropHandlerPrivateKey = &AccelPropHandlerPrivateKeyIndex;
-
-BOOL
-InitializePredictableAccelerationProperties(DeviceIntPtr dev)
-{
- DeviceVelocityPtr vel = GetDevicePredictableAccelData(dev);
- long *prop_handlers;
-
- if(!vel)
- return FALSE;
- prop_handlers = xalloc(NPROPS_PREDICTABLE_ACCEL * sizeof(long));
-
- prop_handlers[0] = AccelInitProfileProperty(dev, vel);
- prop_handlers[1] = AccelInitDecelProperty(dev, vel);
- prop_handlers[2] = AccelInitAdaptDecelProperty(dev, vel);
- prop_handlers[3] = AccelInitScaleProperty(dev, vel);
-
- dixSetPrivate(&dev->devPrivates, AccelPropHandlerPrivateKey,
- prop_handlers);
-
- return TRUE;
-}
-
-BOOL
-DeletePredictableAccelerationProperties(DeviceIntPtr dev)
-{
- Atom prop;
- long *prop_handlers;
- int i;
-
- prop = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
- XIDeleteDeviceProperty(dev, prop, FALSE);
- prop = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
- XIDeleteDeviceProperty(dev, prop, FALSE);
- prop = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
- XIDeleteDeviceProperty(dev, prop, FALSE);
- prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
- XIDeleteDeviceProperty(dev, prop, FALSE);
-
- prop_handlers = dixLookupPrivate(&dev->devPrivates,
- AccelPropHandlerPrivateKey);
- dixSetPrivate(&dev->devPrivates, AccelPropHandlerPrivateKey, NULL);
-
- for (i = 0; prop_handlers && i < NPROPS_PREDICTABLE_ACCEL; i++)
- XIUnregisterPropertyHandler(dev, prop_handlers[i]);
- xfree(prop_handlers);
-
- return TRUE;
-}
-
-/*********************
- * Tracking logic
- ********************/
-
-void
-InitTrackers(DeviceVelocityPtr vel, int ntracker)
-{
- if(ntracker < 1){
- ErrorF("(dix ptracc) invalid number of trackers\n");
- return;
- }
- xfree(vel->tracker);
- vel->tracker = (MotionTrackerPtr)xalloc(ntracker * sizeof(MotionTracker));
- memset(vel->tracker, 0, ntracker * sizeof(MotionTracker));
- vel->num_tracker = ntracker;
-}
-
-/**
- * return a bit field of possible directions.
- * 0 = N, 2 = E, 4 = S, 6 = W, in-between is as you guess.
- * There's no reason against widening to more precise directions (<45 degrees),
- * should it not perform well. All this is needed for is sort out non-linear
- * motion, so precision isn't paramount. However, one should not flag direction
- * too narrow, since it would then cut the linear segment to zero size way too
- * often.
- */
-static int
-DoGetDirection(int dx, int dy){
- float r;
- int i1, i2;
- /* on insignificant mickeys, flag 135 degrees */
- if(abs(dx) < 2 && abs(dy < 2)){
- /* first check diagonal cases */
- if(dx > 0 && dy > 0)
- return 4+8+16;
- if(dx > 0 && dy < 0)
- return 1+2+4;
- if(dx < 0 && dy < 0)
- return 1+128+64;
- if(dx < 0 && dy > 0)
- return 16+32+64;
- /* check axis-aligned directions */
- if(dx > 0)
- return 2+4+8; /*E*/
- if(dx < 0)
- return 128+64+32; /*W*/
- if(dy > 0)
- return 32+16+8; /*S*/
- if(dy < 0)
- return 128+1+2; /*N*/
- return 255; /* shouldn't happen */
- }
- /* else, compute angle and set appropriate flags */
-#ifdef _ISOC99_SOURCE
- r = atan2f(dy, dx);
-#else
- r = atan2(dy, dx);
-#endif
- /* find direction. We avoid r to become negative,
- * since C has no well-defined modulo for such cases. */
- r = (r+(M_PI*2.5))/(M_PI/4);
- /* this intends to flag 2 directions (90 degrees),
- * except on very well-aligned mickeys. */
- i1 = (int)(r+0.1) % 8;
- i2 = (int)(r+0.9) % 8;
- if(i1 < 0 || i1 > 7 || i2 < 0 || i2 > 7)
- return 255; /* shouldn't happen */
- return 1 << i1 | 1 << i2;
-}
-
-#define DIRECTION_CACHE_RANGE 5
-#define DIRECTION_CACHE_SIZE (DIRECTION_CACHE_RANGE*2+1)
-
-/* cache DoGetDirection(). */
-static int
-GetDirection(int dx, int dy){
- static int cache[DIRECTION_CACHE_SIZE][DIRECTION_CACHE_SIZE];
- int i;
- if (abs(dx) <= DIRECTION_CACHE_RANGE &&
- abs(dy) <= DIRECTION_CACHE_RANGE) {
- /* cacheable */
- i = cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy];
- if(i != 0){
- return i;
- }else{
- i = DoGetDirection(dx, dy);
- cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy] = i;
- return i;
- }
- }else{
- /* non-cacheable */
- return DoGetDirection(dx, dy);
- }
-}
-
-#undef DIRECTION_CACHE_RANGE
-#undef DIRECTION_CACHE_SIZE
-
-
-/* convert offset (age) to array index */
-#define TRACKER_INDEX(s, d) (((s)->num_tracker + (s)->cur_tracker - (d)) % (s)->num_tracker)
-
-static inline void
-FeedTrackers(DeviceVelocityPtr vel, int dx, int dy, int cur_t)
-{
- int n;
- for(n = 0; n < vel->num_tracker; n++){
- vel->tracker[n].dx += dx;
- vel->tracker[n].dy += dy;
- }
- n = (vel->cur_tracker + 1) % vel->num_tracker;
- vel->tracker[n].dx = 0;
- vel->tracker[n].dy = 0;
- vel->tracker[n].time = cur_t;
- vel->tracker[n].dir = GetDirection(dx, dy);
- DebugAccelF("(dix prtacc) motion [dx: %i dy: %i dir:%i diff: %i]\n",
- dx, dy, vel->tracker[n].dir,
- cur_t - vel->tracker[vel->cur_tracker].time);
- vel->cur_tracker = n;
-}
-
-/**
- * calc velocity for given tracker, with
- * velocity scaling.
- * This assumes linear motion.
- */
-static float
-CalcTracker(DeviceVelocityPtr vel, int offset, int cur_t){
- int index = TRACKER_INDEX(vel, offset);
- float dist = sqrt( vel->tracker[index].dx * vel->tracker[index].dx
- + vel->tracker[index].dy * vel->tracker[index].dy);
- int dtime = cur_t - vel->tracker[index].time;
- if(dtime > 0)
- return (dist / dtime);
- else
- return 0;/* synonymous for NaN, since we're not C99 */
-}
-
-/* find the most plausible velocity. That is, the most distant
- * (in time) tracker which isn't too old, beyond a linear partition,
- * or simply too much off initial velocity.
- *
- * May return 0.
- */
-static float
-QueryTrackers(DeviceVelocityPtr vel, int cur_t){
- int n, offset, dir = 255, i = -1, age_ms;
- /* initial velocity: a low-offset, valid velocity */
- float iveloc = 0, res = 0, tmp, vdiff;
- float vfac = vel->corr_mul * vel->const_acceleration; /* premultiply */
- /* loop from current to older data */
- for(offset = 1; offset < vel->num_tracker; offset++){
- n = TRACKER_INDEX(vel, offset);
-
- age_ms = cur_t - vel->tracker[n].time;
-
- /* bail out if data is too old and protect from overrun */
- if (age_ms >= vel->reset_time || age_ms < 0) {
- DebugAccelF("(dix prtacc) query: tracker too old\n");
- break;
- }
-
- /*
- * this heuristic avoids using the linear-motion velocity formula
- * in CalcTracker() on motion that isn't exactly linear. So to get
- * even more precision we could subdivide as a final step, so possible
- * non-linearities are accounted for.
- */
- dir &= vel->tracker[n].dir;
- if(dir == 0){
- DebugAccelF("(dix prtacc) query: no longer linear\n");
- /* instead of breaking it we might also inspect the partition after,
- * but actual improvement with this is probably rare. */
- break;
- }
-
- tmp = CalcTracker(vel, offset, cur_t) * vfac;
-
- if ((iveloc == 0 || offset <= vel->initial_range) && tmp != 0) {
- /* set initial velocity and result */
- res = iveloc = tmp;
- i = offset;
- } else if (iveloc != 0 && tmp != 0) {
- vdiff = fabs(iveloc - tmp);
- if (vdiff <= vel->max_diff ||
- vdiff/(iveloc + tmp) < vel->max_rel_diff) {
- /* we're in range with the initial velocity,
- * so this result is likely better
- * (it contains more information). */
- res = tmp;
- i = offset;
- }else{
- /* we're not in range, quit - it won't get better. */
- DebugAccelF("(dix prtacc) query: tracker too different:"
- " old %2.2f initial %2.2f diff: %2.2f\n",
- tmp, iveloc, vdiff);
- break;
- }
- }
- }
- if(offset == vel->num_tracker){
- DebugAccelF("(dix prtacc) query: last tracker in effect\n");
- i = vel->num_tracker-1;
- }
- if(i>=0){
- n = TRACKER_INDEX(vel, i);
- DebugAccelF("(dix prtacc) result: offset %i [dx: %i dy: %i diff: %i]\n",
- i,
- vel->tracker[n].dx,
- vel->tracker[n].dy,
- cur_t - vel->tracker[n].time);
- }
- return res;
-}
-
-#undef TRACKER_INDEX
-
-/**
- * Perform velocity approximation based on 2D 'mickeys' (mouse motion delta).
- * return true if non-visible state reset is suggested
- */
-short
-ProcessVelocityData2D(
- DeviceVelocityPtr vel,
- int dx,
- int dy,
- int time)
-{
- float velocity;
-
- vel->last_velocity = vel->velocity;
-
- FeedTrackers(vel, dx, dy, time);
-
- velocity = QueryTrackers(vel, time);
-
- vel->velocity = velocity;
- return velocity == 0;
-}
-
-/**
- * this flattens significant ( > 1) mickeys a little bit for more steady
- * constant-velocity response
- */
-static inline float
-ApplySimpleSoftening(int od, int d)
-{
- float res = d;
- if (d <= 1 && d >= -1)
- return res;
- if (d > od)
- res -= 0.5;
- else if (d < od)
- res += 0.5;
- return res;
-}
-
-
-static void
-ApplySofteningAndConstantDeceleration(
- DeviceVelocityPtr vel,
- int dx,
- int dy,
- float* fdx,
- float* fdy,
- short do_soften)
-{
- if (do_soften && vel->use_softening) {
- *fdx = ApplySimpleSoftening(vel->last_dx, dx);
- *fdy = ApplySimpleSoftening(vel->last_dy, dy);
- } else {
- *fdx = dx;
- *fdy = dy;
- }
-
- *fdx *= vel->const_acceleration;
- *fdy *= vel->const_acceleration;
-}
-
-/*
- * compute the acceleration for given velocity and enforce min_acceleartion
- */
-float
-BasicComputeAcceleration(
- DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- float velocity,
- float threshold,
- float acc){
-
- float result;
- result = vel->Profile(dev, vel, velocity, threshold, acc);
-
- /* enforce min_acceleration */
- if (result < vel->min_acceleration)
- result = vel->min_acceleration;
- return result;
-}
-
-/**
- * Compute acceleration. Takes into account averaging, nv-reset, etc.
- */
-static float
-ComputeAcceleration(
- DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- float threshold,
- float acc){
- float res;
-
- if(vel->velocity <= 0){
- DebugAccelF("(dix ptracc) profile skipped\n");
- /*
- * If we have no idea about device velocity, don't pretend it.
- */
- return 1;
- }
-
- if(vel->average_accel && vel->velocity != vel->last_velocity){
- /* use simpson's rule to average acceleration between
- * current and previous velocity.
- * Though being the more natural choice, it causes a minor delay
- * in comparison, so it can be disabled. */
- res = BasicComputeAcceleration(
- dev, vel, vel->velocity, threshold, acc);
- res += BasicComputeAcceleration(
- dev, vel, vel->last_velocity, threshold, acc);
- res += 4.0f * BasicComputeAcceleration(dev, vel,
- (vel->last_velocity + vel->velocity) / 2,
- threshold, acc);
- res /= 6.0f;
- DebugAccelF("(dix ptracc) profile average [%.2f ... %.2f] is %.3f\n",
- vel->velocity, vel->last_velocity, res);
- return res;
- }else{
- res = BasicComputeAcceleration(dev, vel,
- vel->velocity, threshold, acc);
- DebugAccelF("(dix ptracc) profile sample [%.2f] is %.3f\n",
- vel->velocity, res);
- return res;
- }
-}
-
-
-/*****************************************
- * Acceleration functions and profiles
- ****************************************/
-
-/**
- * Polynomial function similar previous one, but with f(1) = 1
- */
-static float
-PolynomialAccelerationProfile(
- DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- float velocity,
- float ignored,
- float acc)
-{
- return pow(velocity, (acc - 1.0) * 0.5);
-}
-
-
-/**
- * returns acceleration for velocity.
- * This profile selects the two functions like the old scheme did
- */
-static float
-ClassicProfile(
- DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- float velocity,
- float threshold,
- float acc)
-{
- if (threshold > 0) {
- return SimpleSmoothProfile (dev,
- vel,
- velocity,
- threshold,
- acc);
- } else {
- return PolynomialAccelerationProfile (dev,
- vel,
- velocity,
- 0,
- acc);
- }
-}
-
-
-/**
- * Power profile
- * This has a completely smooth transition curve, i.e. no jumps in the
- * derivatives.
- *
- * This has the expense of overall response dependency on min-acceleration.
- * In effect, min_acceleration mimics const_acceleration in this profile.
- */
-static float
-PowerProfile(
- DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- float velocity,
- float threshold,
- float acc)
-{
- float vel_dist;
-
- acc = (acc-1.0) * 0.1f + 1.0; /* without this, acc of 2 is unuseable */
-
- if (velocity <= threshold)
- return vel->min_acceleration;
- vel_dist = velocity - threshold;
- return (pow(acc, vel_dist)) * vel->min_acceleration;
-}
-
-
-/**
- * just a smooth function in [0..1] -> [0..1]
- * - point symmetry at 0.5
- * - f'(0) = f'(1) = 0
- * - starts faster than a sinoid
- * - smoothness C1 (Cinf if you dare to ignore endpoints)
- */
-static inline float
-CalcPenumbralGradient(float x){
- x *= 2.0f;
- x -= 1.0f;
- return 0.5f + (x * sqrt(1.0f - x*x) + asin(x))/M_PI;
-}
-
-
-/**
- * acceleration function similar to classic accelerated/unaccelerated,
- * but with smooth transition in between (and towards zero for adaptive dec.).
- */
-static float
-SimpleSmoothProfile(
- DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- float velocity,
- float threshold,
- float acc)
-{
- if(velocity < 1.0f)
- return CalcPenumbralGradient(0.5 + velocity*0.5) * 2.0f - 1.0f;
- if(threshold < 1.0f)
- threshold = 1.0f;
- if (velocity <= threshold)
- return 1;
- velocity /= threshold;
- if (velocity >= acc)
- return acc;
- else
- return 1.0f + (CalcPenumbralGradient(velocity/acc) * (acc - 1.0f));
-}
-
-
-/**
- * This profile uses the first half of the penumbral gradient as a start
- * and then scales linearly.
- */
-static float
-SmoothLinearProfile(
- DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- float velocity,
- float threshold,
- float acc)
-{
- float res, nv;
-
- if(acc > 1.0f)
- acc -= 1.0f; /*this is so acc = 1 is no acceleration */
- else
- return 1.0f;
-
- nv = (velocity - threshold) * acc * 0.5f;
-
- if(nv < 0){
- res = 0;
- }else if(nv < 2){
- res = CalcPenumbralGradient(nv*0.25f)*2.0f;
- }else{
- nv -= 2.0f;
- res = nv * 2.0f / M_PI /* steepness of gradient at 0.5 */
- + 1.0f; /* gradient crosses 2|1 */
- }
- res += vel->min_acceleration;
- return res;
-}
-
-
-static float
-LinearProfile(
- DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- float velocity,
- float threshold,
- float acc)
-{
- return acc * velocity;
-}
-
-
-static float
-NoProfile(
- DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- float velocity,
- float threshold,
- float acc)
-{
- return 1.0f;
-}
-
-static PointerAccelerationProfileFunc
-GetAccelerationProfile(
- DeviceVelocityPtr vel,
- int profile_num)
-{
- switch(profile_num){
- case AccelProfileClassic:
- return ClassicProfile;
- case AccelProfileDeviceSpecific:
- return vel->deviceSpecificProfile;
- case AccelProfilePolynomial:
- return PolynomialAccelerationProfile;
- case AccelProfileSmoothLinear:
- return SmoothLinearProfile;
- case AccelProfileSimple:
- return SimpleSmoothProfile;
- case AccelProfilePower:
- return PowerProfile;
- case AccelProfileLinear:
- return LinearProfile;
- case AccelProfileNone:
- return NoProfile;
- default:
- return NULL;
- }
-}
-
-/**
- * Set the profile by number.
- * Intended to make profiles exchangeable at runtime.
- * If you created a profile, give it a number here and in the header to
- * make it selectable. In case some profile-specific init is needed, here
- * would be a good place, since FreeVelocityData() also calls this with
- * PROFILE_UNINITIALIZE.
- *
- * returns FALSE if profile number is unavailable, TRUE otherwise.
- */
-int
-SetAccelerationProfile(
- DeviceVelocityPtr vel,
- int profile_num)
-{
- PointerAccelerationProfileFunc profile;
- profile = GetAccelerationProfile(vel, profile_num);
-
- if(profile == NULL && profile_num != PROFILE_UNINITIALIZE)
- return FALSE;
-
- if(vel->profile_private != NULL){
- /* Here one could free old profile-private data */
- xfree(vel->profile_private);
- vel->profile_private = NULL;
- }
- /* Here one could init profile-private data */
- vel->Profile = profile;
- vel->statistics.profile_number = profile_num;
- return TRUE;
-}
-
-/**********************************************
- * driver interaction
- **********************************************/
-
-
-/**
- * device-specific profile
- *
- * The device-specific profile is intended as a hook for a driver
- * which may want to provide an own acceleration profile.
- * It should not rely on profile-private data, instead
- * it should do init/uninit in the driver (ie. with DEVICE_INIT and friends).
- * Users may override or choose it.
- */
-void
-SetDeviceSpecificAccelerationProfile(
- DeviceVelocityPtr vel,
- PointerAccelerationProfileFunc profile)
-{
- if(vel)
- vel->deviceSpecificProfile = profile;
-}
-
-/**
- * Use this function to obtain a DeviceVelocityPtr for a device. Will return NULL if
- * the predictable acceleration scheme is not in effect.
- */
-DeviceVelocityPtr
-GetDevicePredictableAccelData(
- DeviceIntPtr dev)
-{
- /*sanity check*/
- if(!dev){
- ErrorF("[dix] accel: DeviceIntPtr was NULL");
- return NULL;
- }
- if( dev->valuator &&
- dev->valuator->accelScheme.AccelSchemeProc ==
- acceleratePointerPredictable &&
- dev->valuator->accelScheme.accelData != NULL){
-
- return (DeviceVelocityPtr)dev->valuator->accelScheme.accelData;
- }
- return NULL;
-}
-
-/********************************
- * acceleration schemes
- *******************************/
-
-/**
- * Modifies valuators in-place.
- * This version employs a velocity approximation algorithm to
- * enable fine-grained predictable acceleration profiles.
- */
-void
-acceleratePointerPredictable(
- DeviceIntPtr dev,
- int first_valuator,
- int num_valuators,
- int *valuators,
- int evtime)
-{
- float mult = 0.0;
- int dx = 0, dy = 0;
- int *px = NULL, *py = NULL;
- DeviceVelocityPtr velocitydata =
- (DeviceVelocityPtr) dev->valuator->accelScheme.accelData;
- float fdx, fdy, tmp; /* no need to init */
- Bool soften = TRUE;
-
- if (!num_valuators || !valuators || !velocitydata)
- return;
-
- if (velocitydata->statistics.profile_number == AccelProfileNone &&
- velocitydata->const_acceleration == 1.0f) {
- return; /*we're inactive anyway, so skip the whole thing.*/
- }
-
- if (first_valuator == 0) {
- dx = valuators[0];
- px = &valuators[0];
- }
- if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
- dy = valuators[1 - first_valuator];
- py = &valuators[1 - first_valuator];
- }
-
- if (dx || dy){
- /* reset non-visible state? */
- if (ProcessVelocityData2D(velocitydata, dx , dy, evtime)) {
- soften = FALSE;
- }
-
- if (dev->ptrfeed && dev->ptrfeed->ctrl.num) {
- /* invoke acceleration profile to determine acceleration */
- mult = ComputeAcceleration (dev, velocitydata,
- dev->ptrfeed->ctrl.threshold,
- (float)dev->ptrfeed->ctrl.num /
- (float)dev->ptrfeed->ctrl.den);
-
- if(mult != 1.0 || velocitydata->const_acceleration != 1.0) {
- ApplySofteningAndConstantDeceleration( velocitydata,
- dx, dy,
- &fdx, &fdy,
- (mult > 1.0) && soften);
-
- if (dx) {
- tmp = mult * fdx + dev->last.remainder[0];
- /* Since it may not be apparent: lrintf() does not offer
- * strong statements about rounding; however because we
- * process each axis conditionally, there's no danger
- * of a toggling remainder. Its lack of guarantees likely
- * makes it faster on the average target. */
- *px = lrintf(tmp);
- dev->last.remainder[0] = tmp - (float)*px;
- }
- if (dy) {
- tmp = mult * fdy + dev->last.remainder[1];
- *py = lrintf(tmp);
- dev->last.remainder[1] = tmp - (float)*py;
- }
- DebugAccelF("pos (%i | %i) remainders x: %.3f y: %.3f delta x:%.3f y:%.3f\n",
- *px, *py, dev->last.remainder[0], dev->last.remainder[1], fdx, fdy);
- }
- }
- }
- /* remember last motion delta (for softening/slow movement treatment) */
- velocitydata->last_dx = dx;
- velocitydata->last_dy = dy;
-}
-
-
-
-/**
- * Originally a part of xf86PostMotionEvent; modifies valuators
- * in-place. Retained mostly for embedded scenarios.
- */
-void
-acceleratePointerLightweight(
- DeviceIntPtr dev,
- int first_valuator,
- int num_valuators,
- int *valuators,
- int ignored)
-{
- float mult = 0.0;
- int dx = 0, dy = 0;
- int *px = NULL, *py = NULL;
-
- if (!num_valuators || !valuators)
- return;
-
- if (first_valuator == 0) {
- dx = valuators[0];
- px = &valuators[0];
- }
- if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
- dy = valuators[1 - first_valuator];
- py = &valuators[1 - first_valuator];
- }
-
- if (!dx && !dy)
- return;
-
- if (dev->ptrfeed && dev->ptrfeed->ctrl.num) {
- /* modeled from xf86Events.c */
- if (dev->ptrfeed->ctrl.threshold) {
- if ((abs(dx) + abs(dy)) >= dev->ptrfeed->ctrl.threshold) {
- dev->last.remainder[0] = ((float)dx *
- (float)(dev->ptrfeed->ctrl.num)) /
- (float)(dev->ptrfeed->ctrl.den) +
- dev->last.remainder[0];
- if (px) {
- *px = (int)dev->last.remainder[0];
- dev->last.remainder[0] = dev->last.remainder[0] -
- (float)(*px);
- }
-
- dev->last.remainder[1] = ((float)dy *
- (float)(dev->ptrfeed->ctrl.num)) /
- (float)(dev->ptrfeed->ctrl.den) +
- dev->last.remainder[1];
- if (py) {
- *py = (int)dev->last.remainder[1];
- dev->last.remainder[1] = dev->last.remainder[1] -
- (float)(*py);
- }
- }
- }
- else {
- mult = pow((float)dx * (float)dx + (float)dy * (float)dy,
- ((float)(dev->ptrfeed->ctrl.num) /
- (float)(dev->ptrfeed->ctrl.den) - 1.0) /
- 2.0) / 2.0;
- if (dx) {
- dev->last.remainder[0] = mult * (float)dx +
- dev->last.remainder[0];
- *px = (int)dev->last.remainder[0];
- dev->last.remainder[0] = dev->last.remainder[0] -
- (float)(*px);
- }
- if (dy) {
- dev->last.remainder[1] = mult * (float)dy +
- dev->last.remainder[1];
- *py = (int)dev->last.remainder[1];
- dev->last.remainder[1] = dev->last.remainder[1] -
- (float)(*py);
- }
- }
- }
-}
+/*
+ *
+ * Copyright © 2006-2009 Simon Thum simon dot thum at gmx dot de
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef _MSC_VER
+#define _USE_MATH_DEFINES
+#endif
+
+#include <math.h>
+#include <ptrveloc.h>
+#include <exevents.h>
+#include <X11/Xatom.h>
+
+#include <xserver-properties.h>
+
+/*****************************************************************************
+ * Predictable pointer acceleration
+ *
+ * 2006-2009 by Simon Thum (simon [dot] thum [at] gmx de)
+ *
+ * Serves 3 complementary functions:
+ * 1) provide a sophisticated ballistic velocity estimate to improve
+ * the relation between velocity (of the device) and acceleration
+ * 2) make arbitrary acceleration profiles possible
+ * 3) decelerate by two means (constant and adaptive) if enabled
+ *
+ * Important concepts are the
+ *
+ * - Scheme
+ * which selects the basic algorithm
+ * (see devices.c/InitPointerAccelerationScheme)
+ * - Profile
+ * which returns an acceleration
+ * for a given velocity
+ *
+ * The profile can be selected by the user at runtime.
+ * The classic profile is intended to cleanly perform old-style
+ * function selection (threshold =/!= 0)
+ *
+ ****************************************************************************/
+
+#ifdef _MSC_VER
+#define inline __inline
+#define lrintf(val) ((int)val)
+#endif
+
+/* fwds */
+int
+SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
+static float
+SimpleSmoothProfile(DeviceIntPtr dev, DeviceVelocityPtr vel, float velocity,
+ float threshold, float acc);
+static PointerAccelerationProfileFunc
+GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
+
+/*#define PTRACCEL_DEBUGGING*/
+
+#ifdef PTRACCEL_DEBUGGING
+#define DebugAccelF ErrorF
+#else
+#define DebugAccelF(...) /* */
+#endif
+
+/********************************
+ * Init/Uninit
+ *******************************/
+
+/* some int which is not a profile number */
+#define PROFILE_UNINITIALIZE (-100)
+
+/* number of properties for predictable acceleration */
+#define NPROPS_PREDICTABLE_ACCEL 4
+
+/**
+ * Init struct so it should match the average case
+ */
+void
+InitVelocityData(DeviceVelocityPtr vel)
+{
+ memset(vel, 0, sizeof(DeviceVelocityRec));
+
+ vel->corr_mul = 10.0; /* dots per 10 milisecond should be usable */
+ vel->const_acceleration = 1.0; /* no acceleration/deceleration */
+ vel->reset_time = 300;
+ vel->use_softening = 1;
+ vel->min_acceleration = 1.0; /* don't decelerate */
+ vel->max_rel_diff = 0.2;
+ vel->max_diff = 1.0;
+ vel->initial_range = 2;
+ vel->average_accel = TRUE;
+ SetAccelerationProfile(vel, AccelProfileClassic);
+ InitTrackers(vel, 16);
+}
+
+
+/**
+ * Clean up
+ */
+void
+FreeVelocityData(DeviceVelocityPtr vel){
+ xfree(vel->tracker);
+ SetAccelerationProfile(vel, PROFILE_UNINITIALIZE);
+}
+
+
+/*
+ * dix uninit helper, called through scheme
+ */
+void
+AccelerationDefaultCleanup(DeviceIntPtr dev)
+{
+ /*sanity check*/
+ if( dev->valuator->accelScheme.AccelSchemeProc == acceleratePointerPredictable
+ && dev->valuator->accelScheme.accelData != NULL){
+ dev->valuator->accelScheme.AccelSchemeProc = NULL;
+ FreeVelocityData(dev->valuator->accelScheme.accelData);
+ xfree(dev->valuator->accelScheme.accelData);
+ dev->valuator->accelScheme.accelData = NULL;
+ DeletePredictableAccelerationProperties(dev);
+ }
+}
+
+
+/*************************
+ * Input property support
+ ************************/
+
+/**
+ * choose profile
+ */
+static int
+AccelSetProfileProperty(DeviceIntPtr dev, Atom atom,
+ XIPropertyValuePtr val, BOOL checkOnly)
+{
+ DeviceVelocityPtr vel;
+ int profile, *ptr = &profile;
+ int rc;
+ int nelem = 1;
+
+ if (atom != XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER))
+ return Success;
+
+ vel = GetDevicePredictableAccelData(dev);
+ if (!vel)
+ return BadValue;
+ rc = XIPropToInt(val, &nelem, &ptr);
+
+ if(checkOnly)
+ {
+ if (rc)
+ return rc;
+
+ if (GetAccelerationProfile(vel, profile) == NULL)
+ return BadValue;
+ } else
+ SetAccelerationProfile(vel, profile);
+
+ return Success;
+}
+
+static long
+AccelInitProfileProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
+{
+ int profile = vel->statistics.profile_number;
+ Atom prop_profile_number = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
+
+ XIChangeDeviceProperty(dev, prop_profile_number, XA_INTEGER, 32,
+ PropModeReplace, 1, &profile, FALSE);
+ XISetDevicePropertyDeletable(dev, prop_profile_number, FALSE);
+ return XIRegisterPropertyHandler(dev, AccelSetProfileProperty, NULL, NULL);
+}
+
+/**
+ * constant deceleration
+ */
+static int
+AccelSetDecelProperty(DeviceIntPtr dev, Atom atom,
+ XIPropertyValuePtr val, BOOL checkOnly)
+{
+ DeviceVelocityPtr vel;
+ float v, *ptr = &v;
+ int rc;
+ int nelem = 1;
+
+ if (atom != XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION))
+ return Success;
+
+ vel = GetDevicePredictableAccelData(dev);
+ if (!vel)
+ return BadValue;
+ rc = XIPropToFloat(val, &nelem, &ptr);
+
+ if(checkOnly)
+ {
+ if (rc)
+ return rc;
+ return (v >= 1.0f) ? Success : BadValue;
+ }
+
+ if(v >= 1.0f)
+ vel->const_acceleration = 1/v;
+
+ return Success;
+}
+
+static long
+AccelInitDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
+{
+ float fval = 1.0/vel->const_acceleration;
+ Atom prop_const_decel = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
+ XIChangeDeviceProperty(dev, prop_const_decel,
+ XIGetKnownProperty(XATOM_FLOAT), 32,
+ PropModeReplace, 1, &fval, FALSE);
+ XISetDevicePropertyDeletable(dev, prop_const_decel, FALSE);
+ return XIRegisterPropertyHandler(dev, AccelSetDecelProperty, NULL, NULL);
+}
+
+
+/**
+ * adaptive deceleration
+ */
+static int
+AccelSetAdaptDecelProperty(DeviceIntPtr dev, Atom atom,
+ XIPropertyValuePtr val, BOOL checkOnly)
+{
+ DeviceVelocityPtr veloc;
+ float v, *ptr = &v;
+ int rc;
+ int nelem = 1;
+
+ if (atom != XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION))
+ return Success;
+
+ veloc = GetDevicePredictableAccelData(dev);
+ if (!veloc)
+ return BadValue;
+ rc = XIPropToFloat(val, &nelem, &ptr);
+
+ if(checkOnly)
+ {
+ if (rc)
+ return rc;
+ return (v >= 1.0f) ? Success : BadValue;
+ }
+
+ if(v >= 1.0f)
+ veloc->min_acceleration = 1/v;
+
+ return Success;
+}
+
+static long
+AccelInitAdaptDecelProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
+{
+ float fval = 1.0/vel->min_acceleration;
+ Atom prop_adapt_decel = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
+
+ XIChangeDeviceProperty(dev, prop_adapt_decel, XIGetKnownProperty(XATOM_FLOAT), 32,
+ PropModeReplace, 1, &fval, FALSE);
+ XISetDevicePropertyDeletable(dev, prop_adapt_decel, FALSE);
+ return XIRegisterPropertyHandler(dev, AccelSetAdaptDecelProperty, NULL, NULL);
+}
+
+
+/**
+ * velocity scaling
+ */
+static int
+AccelSetScaleProperty(DeviceIntPtr dev, Atom atom,
+ XIPropertyValuePtr val, BOOL checkOnly)
+{
+ DeviceVelocityPtr vel;
+ float v, *ptr = &v;
+ int rc;
+ int nelem = 1;
+
+ if (atom != XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING))
+ return Success;
+
+ vel = GetDevicePredictableAccelData(dev);
+ if (!vel)
+ return BadValue;
+ rc = XIPropToFloat(val, &nelem, &ptr);
+
+ if (checkOnly)
+ {
+ if (rc)
+ return rc;
+
+ return (v > 0) ? Success : BadValue;
+ }
+
+ if(v > 0)
+ vel->corr_mul = v;
+
+ return Success;
+}
+
+static long
+AccelInitScaleProperty(DeviceIntPtr dev, DeviceVelocityPtr vel)
+{
+ float fval = vel->corr_mul;
+ Atom prop_velo_scale = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
+
+ XIChangeDeviceProperty(dev, prop_velo_scale, XIGetKnownProperty(XATOM_FLOAT), 32,
+ PropModeReplace, 1, &fval, FALSE);
+ XISetDevicePropertyDeletable(dev, prop_velo_scale, FALSE);
+ return XIRegisterPropertyHandler(dev, AccelSetScaleProperty, NULL, NULL);
+}
+
+static int AccelPropHandlerPrivateKeyIndex;
+DevPrivateKey AccelPropHandlerPrivateKey = &AccelPropHandlerPrivateKeyIndex;
+
+BOOL
+InitializePredictableAccelerationProperties(DeviceIntPtr dev)
+{
+ DeviceVelocityPtr vel = GetDevicePredictableAccelData(dev);
+ long *prop_handlers;
+
+ if(!vel)
+ return FALSE;
+ prop_handlers = xalloc(NPROPS_PREDICTABLE_ACCEL * sizeof(long));
+
+ prop_handlers[0] = AccelInitProfileProperty(dev, vel);
+ prop_handlers[1] = AccelInitDecelProperty(dev, vel);
+ prop_handlers[2] = AccelInitAdaptDecelProperty(dev, vel);
+ prop_handlers[3] = AccelInitScaleProperty(dev, vel);
+
+ dixSetPrivate(&dev->devPrivates, AccelPropHandlerPrivateKey,
+ prop_handlers);
+
+ return TRUE;
+}
+
+BOOL
+DeletePredictableAccelerationProperties(DeviceIntPtr dev)
+{
+ Atom prop;
+ long *prop_handlers;
+ int i;
+
+ prop = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
+ XIDeleteDeviceProperty(dev, prop, FALSE);
+ prop = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
+ XIDeleteDeviceProperty(dev, prop, FALSE);
+ prop = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
+ XIDeleteDeviceProperty(dev, prop, FALSE);
+ prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
+ XIDeleteDeviceProperty(dev, prop, FALSE);
+
+ prop_handlers = dixLookupPrivate(&dev->devPrivates,
+ AccelPropHandlerPrivateKey);
+ dixSetPrivate(&dev->devPrivates, AccelPropHandlerPrivateKey, NULL);
+
+ for (i = 0; prop_handlers && i < NPROPS_PREDICTABLE_ACCEL; i++)
+ XIUnregisterPropertyHandler(dev, prop_handlers[i]);
+ xfree(prop_handlers);
+
+ return TRUE;
+}
+
+/*********************
+ * Tracking logic
+ ********************/
+
+void
+InitTrackers(DeviceVelocityPtr vel, int ntracker)
+{
+ if(ntracker < 1){
+ ErrorF("(dix ptracc) invalid number of trackers\n");
+ return;
+ }
+ xfree(vel->tracker);
+ vel->tracker = (MotionTrackerPtr)xalloc(ntracker * sizeof(MotionTracker));
+ memset(vel->tracker, 0, ntracker * sizeof(MotionTracker));
+ vel->num_tracker = ntracker;
+}
+
+/**
+ * return a bit field of possible directions.
+ * 0 = N, 2 = E, 4 = S, 6 = W, in-between is as you guess.
+ * There's no reason against widening to more precise directions (<45 degrees),
+ * should it not perform well. All this is needed for is sort out non-linear
+ * motion, so precision isn't paramount. However, one should not flag direction
+ * too narrow, since it would then cut the linear segment to zero size way too
+ * often.
+ */
+static int
+DoGetDirection(int dx, int dy){
+ float r;
+ int i1, i2;
+ /* on insignificant mickeys, flag 135 degrees */
+ if(abs(dx) < 2 && abs(dy < 2)){
+ /* first check diagonal cases */
+ if(dx > 0 && dy > 0)
+ return 4+8+16;
+ if(dx > 0 && dy < 0)
+ return 1+2+4;
+ if(dx < 0 && dy < 0)
+ return 1+128+64;
+ if(dx < 0 && dy > 0)
+ return 16+32+64;
+ /* check axis-aligned directions */
+ if(dx > 0)
+ return 2+4+8; /*E*/
+ if(dx < 0)
+ return 128+64+32; /*W*/
+ if(dy > 0)
+ return 32+16+8; /*S*/
+ if(dy < 0)
+ return 128+1+2; /*N*/
+ return 255; /* shouldn't happen */
+ }
+ /* else, compute angle and set appropriate flags */
+#ifdef _ISOC99_SOURCE
+ r = atan2f(dy, dx);
+#else
+ r = atan2(dy, dx);
+#endif
+ /* find direction. We avoid r to become negative,
+ * since C has no well-defined modulo for such cases. */
+ r = (r+(M_PI*2.5))/(M_PI/4);
+ /* this intends to flag 2 directions (90 degrees),
+ * except on very well-aligned mickeys. */
+ i1 = (int)(r+0.1) % 8;
+ i2 = (int)(r+0.9) % 8;
+ if(i1 < 0 || i1 > 7 || i2 < 0 || i2 > 7)
+ return 255; /* shouldn't happen */
+ return 1 << i1 | 1 << i2;
+}
+
+#define DIRECTION_CACHE_RANGE 5
+#define DIRECTION_CACHE_SIZE (DIRECTION_CACHE_RANGE*2+1)
+
+/* cache DoGetDirection(). */
+static int
+GetDirection(int dx, int dy){
+ static int cache[DIRECTION_CACHE_SIZE][DIRECTION_CACHE_SIZE];
+ int i;
+ if (abs(dx) <= DIRECTION_CACHE_RANGE &&
+ abs(dy) <= DIRECTION_CACHE_RANGE) {
+ /* cacheable */
+ i = cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy];
+ if(i != 0){
+ return i;
+ }else{
+ i = DoGetDirection(dx, dy);
+ cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy] = i;
+ return i;
+ }
+ }else{
+ /* non-cacheable */
+ return DoGetDirection(dx, dy);
+ }
+}
+
+#undef DIRECTION_CACHE_RANGE
+#undef DIRECTION_CACHE_SIZE
+
+
+/* convert offset (age) to array index */
+#define TRACKER_INDEX(s, d) (((s)->num_tracker + (s)->cur_tracker - (d)) % (s)->num_tracker)
+
+static inline void
+FeedTrackers(DeviceVelocityPtr vel, int dx, int dy, int cur_t)
+{
+ int n;
+ for(n = 0; n < vel->num_tracker; n++){
+ vel->tracker[n].dx += dx;
+ vel->tracker[n].dy += dy;
+ }
+ n = (vel->cur_tracker + 1) % vel->num_tracker;
+ vel->tracker[n].dx = 0;
+ vel->tracker[n].dy = 0;
+ vel->tracker[n].time = cur_t;
+ vel->tracker[n].dir = GetDirection(dx, dy);
+ DebugAccelF("(dix prtacc) motion [dx: %i dy: %i dir:%i diff: %i]\n",
+ dx, dy, vel->tracker[n].dir,
+ cur_t - vel->tracker[vel->cur_tracker].time);
+ vel->cur_tracker = n;
+}
+
+/**
+ * calc velocity for given tracker, with
+ * velocity scaling.
+ * This assumes linear motion.
+ */
+static float
+CalcTracker(DeviceVelocityPtr vel, int offset, int cur_t){
+ int index = TRACKER_INDEX(vel, offset);
+ float dist = sqrt( vel->tracker[index].dx * vel->tracker[index].dx
+ + vel->tracker[index].dy * vel->tracker[index].dy);
+ int dtime = cur_t - vel->tracker[index].time;
+ if(dtime > 0)
+ return (dist / dtime);
+ else
+ return 0;/* synonymous for NaN, since we're not C99 */
+}
+
+/* find the most plausible velocity. That is, the most distant
+ * (in time) tracker which isn't too old, beyond a linear partition,
+ * or simply too much off initial velocity.
+ *
+ * May return 0.
+ */
+static float
+QueryTrackers(DeviceVelocityPtr vel, int cur_t){
+ int n, offset, dir = 255, i = -1, age_ms;
+ /* initial velocity: a low-offset, valid velocity */
+ float iveloc = 0, res = 0, tmp, vdiff;
+ float vfac = vel->corr_mul * vel->const_acceleration; /* premultiply */
+ /* loop from current to older data */
+ for(offset = 1; offset < vel->num_tracker; offset++){
+ n = TRACKER_INDEX(vel, offset);
+
+ age_ms = cur_t - vel->tracker[n].time;
+
+ /* bail out if data is too old and protect from overrun */
+ if (age_ms >= vel->reset_time || age_ms < 0) {
+ DebugAccelF("(dix prtacc) query: tracker too old\n");
+ break;
+ }
+
+ /*
+ * this heuristic avoids using the linear-motion velocity formula
+ * in CalcTracker() on motion that isn't exactly linear. So to get
+ * even more precision we could subdivide as a final step, so possible
+ * non-linearities are accounted for.
+ */
+ dir &= vel->tracker[n].dir;
+ if(dir == 0){
+ DebugAccelF("(dix prtacc) query: no longer linear\n");
+ /* instead of breaking it we might also inspect the partition after,
+ * but actual improvement with this is probably rare. */
+ break;
+ }
+
+ tmp = CalcTracker(vel, offset, cur_t) * vfac;
+
+ if ((iveloc == 0 || offset <= vel->initial_range) && tmp != 0) {
+ /* set initial velocity and result */
+ res = iveloc = tmp;
+ i = offset;
+ } else if (iveloc != 0 && tmp != 0) {
+ vdiff = fabs(iveloc - tmp);
+ if (vdiff <= vel->max_diff ||
+ vdiff/(iveloc + tmp) < vel->max_rel_diff) {
+ /* we're in range with the initial velocity,
+ * so this result is likely better
+ * (it contains more information). */
+ res = tmp;
+ i = offset;
+ }else{
+ /* we're not in range, quit - it won't get better. */
+ DebugAccelF("(dix prtacc) query: tracker too different:"
+ " old %2.2f initial %2.2f diff: %2.2f\n",
+ tmp, iveloc, vdiff);
+ break;
+ }
+ }
+ }
+ if(offset == vel->num_tracker){
+ DebugAccelF("(dix prtacc) query: last tracker in effect\n");
+ i = vel->num_tracker-1;
+ }
+ if(i>=0){
+ n = TRACKER_INDEX(vel, i);
+ DebugAccelF("(dix prtacc) result: offset %i [dx: %i dy: %i diff: %i]\n",
+ i,
+ vel->tracker[n].dx,
+ vel->tracker[n].dy,
+ cur_t - vel->tracker[n].time);
+ }
+ return res;
+}
+
+#undef TRACKER_INDEX
+
+/**
+ * Perform velocity approximation based on 2D 'mickeys' (mouse motion delta).
+ * return true if non-visible state reset is suggested
+ */
+short
+ProcessVelocityData2D(
+ DeviceVelocityPtr vel,
+ int dx,
+ int dy,
+ int time)
+{
+ float velocity;
+
+ vel->last_velocity = vel->velocity;
+
+ FeedTrackers(vel, dx, dy, time);
+
+ velocity = QueryTrackers(vel, time);
+
+ vel->velocity = velocity;
+ return velocity == 0;
+}
+
+/**
+ * this flattens significant ( > 1) mickeys a little bit for more steady
+ * constant-velocity response
+ */
+static inline float
+ApplySimpleSoftening(int od, int d)
+{
+ float res = d;
+ if (d <= 1 && d >= -1)
+ return res;
+ if (d > od)
+ res -= 0.5;
+ else if (d < od)
+ res += 0.5;
+ return res;
+}
+
+
+static void
+ApplySofteningAndConstantDeceleration(
+ DeviceVelocityPtr vel,
+ int dx,
+ int dy,
+ float* fdx,
+ float* fdy,
+ short do_soften)
+{
+ if (do_soften && vel->use_softening) {
+ *fdx = ApplySimpleSoftening(vel->last_dx, dx);
+ *fdy = ApplySimpleSoftening(vel->last_dy, dy);
+ } else {
+ *fdx = dx;
+ *fdy = dy;
+ }
+
+ *fdx *= vel->const_acceleration;
+ *fdy *= vel->const_acceleration;
+}
+
+/*
+ * compute the acceleration for given velocity and enforce min_acceleartion
+ */
+float
+BasicComputeAcceleration(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float velocity,
+ float threshold,
+ float acc){
+
+ float result;
+ result = vel->Profile(dev, vel, velocity, threshold, acc);
+
+ /* enforce min_acceleration */
+ if (result < vel->min_acceleration)
+ result = vel->min_acceleration;
+ return result;
+}
+
+/**
+ * Compute acceleration. Takes into account averaging, nv-reset, etc.
+ */
+static float
+ComputeAcceleration(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float threshold,
+ float acc){
+ float res;
+
+ if(vel->velocity <= 0){
+ DebugAccelF("(dix ptracc) profile skipped\n");
+ /*
+ * If we have no idea about device velocity, don't pretend it.
+ */
+ return 1;
+ }
+
+ if(vel->average_accel && vel->velocity != vel->last_velocity){
+ /* use simpson's rule to average acceleration between
+ * current and previous velocity.
+ * Though being the more natural choice, it causes a minor delay
+ * in comparison, so it can be disabled. */
+ res = BasicComputeAcceleration(
+ dev, vel, vel->velocity, threshold, acc);
+ res += BasicComputeAcceleration(
+ dev, vel, vel->last_velocity, threshold, acc);
+ res += 4.0f * BasicComputeAcceleration(dev, vel,
+ (vel->last_velocity + vel->velocity) / 2,
+ threshold, acc);
+ res /= 6.0f;
+ DebugAccelF("(dix ptracc) profile average [%.2f ... %.2f] is %.3f\n",
+ vel->velocity, vel->last_velocity, res);
+ return res;
+ }else{
+ res = BasicComputeAcceleration(dev, vel,
+ vel->velocity, threshold, acc);
+ DebugAccelF("(dix ptracc) profile sample [%.2f] is %.3f\n",
+ vel->velocity, res);
+ return res;
+ }
+}
+
+
+/*****************************************
+ * Acceleration functions and profiles
+ ****************************************/
+
+/**
+ * Polynomial function similar previous one, but with f(1) = 1
+ */
+static float
+PolynomialAccelerationProfile(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float velocity,
+ float ignored,
+ float acc)
+{
+ return pow(velocity, (acc - 1.0) * 0.5);
+}
+
+
+/**
+ * returns acceleration for velocity.
+ * This profile selects the two functions like the old scheme did
+ */
+static float
+ClassicProfile(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float velocity,
+ float threshold,
+ float acc)
+{
+ if (threshold > 0) {
+ return SimpleSmoothProfile (dev,
+ vel,
+ velocity,
+ threshold,
+ acc);
+ } else {
+ return PolynomialAccelerationProfile (dev,
+ vel,
+ velocity,
+ 0,
+ acc);
+ }
+}
+
+
+/**
+ * Power profile
+ * This has a completely smooth transition curve, i.e. no jumps in the
+ * derivatives.
+ *
+ * This has the expense of overall response dependency on min-acceleration.
+ * In effect, min_acceleration mimics const_acceleration in this profile.
+ */
+static float
+PowerProfile(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float velocity,
+ float threshold,
+ float acc)
+{
+ float vel_dist;
+
+ acc = (acc-1.0) * 0.1f + 1.0; /* without this, acc of 2 is unuseable */
+
+ if (velocity <= threshold)
+ return vel->min_acceleration;
+ vel_dist = velocity - threshold;
+ return (pow(acc, vel_dist)) * vel->min_acceleration;
+}
+
+
+/**
+ * just a smooth function in [0..1] -> [0..1]
+ * - point symmetry at 0.5
+ * - f'(0) = f'(1) = 0
+ * - starts faster than a sinoid
+ * - smoothness C1 (Cinf if you dare to ignore endpoints)
+ */
+static inline float
+CalcPenumbralGradient(float x){
+ x *= 2.0f;
+ x -= 1.0f;
+ return 0.5f + (x * sqrt(1.0f - x*x) + asin(x))/M_PI;
+}
+
+
+/**
+ * acceleration function similar to classic accelerated/unaccelerated,
+ * but with smooth transition in between (and towards zero for adaptive dec.).
+ */
+static float
+SimpleSmoothProfile(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float velocity,
+ float threshold,
+ float acc)
+{
+ if(velocity < 1.0f)
+ return CalcPenumbralGradient(0.5 + velocity*0.5) * 2.0f - 1.0f;
+ if(threshold < 1.0f)
+ threshold = 1.0f;
+ if (velocity <= threshold)
+ return 1;
+ velocity /= threshold;
+ if (velocity >= acc)
+ return acc;
+ else
+ return 1.0f + (CalcPenumbralGradient(velocity/acc) * (acc - 1.0f));
+}
+
+
+/**
+ * This profile uses the first half of the penumbral gradient as a start
+ * and then scales linearly.
+ */
+static float
+SmoothLinearProfile(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float velocity,
+ float threshold,
+ float acc)
+{
+ float res, nv;
+
+ if(acc > 1.0f)
+ acc -= 1.0f; /*this is so acc = 1 is no acceleration */
+ else
+ return 1.0f;
+
+ nv = (velocity - threshold) * acc * 0.5f;
+
+ if(nv < 0){
+ res = 0;
+ }else if(nv < 2){
+ res = CalcPenumbralGradient(nv*0.25f)*2.0f;
+ }else{
+ nv -= 2.0f;
+ res = nv * 2.0f / M_PI /* steepness of gradient at 0.5 */
+ + 1.0f; /* gradient crosses 2|1 */
+ }
+ res += vel->min_acceleration;
+ return res;
+}
+
+
+/**
+ * From 0 to threshold, the response graduates smoothly from min_accel to
+ * acceleration. Beyond threshold it is exactly the specified acceleration.
+ */
+static float
+SmoothLimitedProfile(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float velocity,
+ float threshold,
+ float acc)
+{
+ float res;
+
+ if(velocity >= threshold || threshold == 0.0f)
+ return acc;
+
+ velocity /= threshold; /* should be [0..1[ now */
+
+ res = CalcPenumbralGradient(velocity) * (acc - vel->min_acceleration);
+
+ return vel->min_acceleration + res;
+}
+
+
+static float
+LinearProfile(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float velocity,
+ float threshold,
+ float acc)
+{
+ return acc * velocity;
+}
+
+static float
+NoProfile(
+ DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float velocity,
+ float threshold,
+ float acc)
+{
+ return 1.0f;
+}
+
+static PointerAccelerationProfileFunc
+GetAccelerationProfile(
+ DeviceVelocityPtr vel,
+ int profile_num)
+{
+ switch(profile_num){
+ case AccelProfileClassic:
+ return ClassicProfile;
+ case AccelProfileDeviceSpecific:
+ return vel->deviceSpecificProfile;
+ case AccelProfilePolynomial:
+ return PolynomialAccelerationProfile;
+ case AccelProfileSmoothLinear:
+ return SmoothLinearProfile;
+ case AccelProfileSimple:
+ return SimpleSmoothProfile;
+ case AccelProfilePower:
+ return PowerProfile;
+ case AccelProfileLinear:
+ return LinearProfile;
+ case AccelProfileSmoothLimited:
+ return SmoothLimitedProfile;
+ case AccelProfileNone:
+ return NoProfile;
+ default:
+ return NULL;
+ }
+}
+
+/**
+ * Set the profile by number.
+ * Intended to make profiles exchangeable at runtime.
+ * If you created a profile, give it a number here and in the header to
+ * make it selectable. In case some profile-specific init is needed, here
+ * would be a good place, since FreeVelocityData() also calls this with
+ * PROFILE_UNINITIALIZE.
+ *
+ * returns FALSE if profile number is unavailable, TRUE otherwise.
+ */
+int
+SetAccelerationProfile(
+ DeviceVelocityPtr vel,
+ int profile_num)
+{
+ PointerAccelerationProfileFunc profile;
+ profile = GetAccelerationProfile(vel, profile_num);
+
+ if(profile == NULL && profile_num != PROFILE_UNINITIALIZE)
+ return FALSE;
+
+ if(vel->profile_private != NULL){
+ /* Here one could free old profile-private data */
+ xfree(vel->profile_private);
+ vel->profile_private = NULL;
+ }
+ /* Here one could init profile-private data */
+ vel->Profile = profile;
+ vel->statistics.profile_number = profile_num;
+ return TRUE;
+}
+
+/**********************************************
+ * driver interaction
+ **********************************************/
+
+
+/**
+ * device-specific profile
+ *
+ * The device-specific profile is intended as a hook for a driver
+ * which may want to provide an own acceleration profile.
+ * It should not rely on profile-private data, instead
+ * it should do init/uninit in the driver (ie. with DEVICE_INIT and friends).
+ * Users may override or choose it.
+ */
+void
+SetDeviceSpecificAccelerationProfile(
+ DeviceVelocityPtr vel,
+ PointerAccelerationProfileFunc profile)
+{
+ if(vel)
+ vel->deviceSpecificProfile = profile;
+}
+
+/**
+ * Use this function to obtain a DeviceVelocityPtr for a device. Will return NULL if
+ * the predictable acceleration scheme is not in effect.
+ */
+DeviceVelocityPtr
+GetDevicePredictableAccelData(
+ DeviceIntPtr dev)
+{
+ /*sanity check*/
+ if(!dev){
+ ErrorF("[dix] accel: DeviceIntPtr was NULL");
+ return NULL;
+ }
+ if( dev->valuator &&
+ dev->valuator->accelScheme.AccelSchemeProc ==
+ acceleratePointerPredictable &&
+ dev->valuator->accelScheme.accelData != NULL){
+
+ return (DeviceVelocityPtr)dev->valuator->accelScheme.accelData;
+ }
+ return NULL;
+}
+
+/********************************
+ * acceleration schemes
+ *******************************/
+
+/**
+ * Modifies valuators in-place.
+ * This version employs a velocity approximation algorithm to
+ * enable fine-grained predictable acceleration profiles.
+ */
+void
+acceleratePointerPredictable(
+ DeviceIntPtr dev,
+ int first_valuator,
+ int num_valuators,
+ int *valuators,
+ int evtime)
+{
+ float mult = 0.0;
+ int dx = 0, dy = 0;
+ int *px = NULL, *py = NULL;
+ DeviceVelocityPtr velocitydata =
+ (DeviceVelocityPtr) dev->valuator->accelScheme.accelData;
+ float fdx, fdy, tmp; /* no need to init */
+ Bool soften = TRUE;
+
+ if (!num_valuators || !valuators || !velocitydata)
+ return;
+
+ if (velocitydata->statistics.profile_number == AccelProfileNone &&
+ velocitydata->const_acceleration == 1.0f) {
+ return; /*we're inactive anyway, so skip the whole thing.*/
+ }
+
+ if (first_valuator == 0) {
+ dx = valuators[0];
+ px = &valuators[0];
+ }
+ if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
+ dy = valuators[1 - first_valuator];
+ py = &valuators[1 - first_valuator];
+ }
+
+ if (dx || dy){
+ /* reset non-visible state? */
+ if (ProcessVelocityData2D(velocitydata, dx , dy, evtime)) {
+ soften = FALSE;
+ }
+
+ if (dev->ptrfeed && dev->ptrfeed->ctrl.num) {
+ /* invoke acceleration profile to determine acceleration */
+ mult = ComputeAcceleration (dev, velocitydata,
+ dev->ptrfeed->ctrl.threshold,
+ (float)dev->ptrfeed->ctrl.num /
+ (float)dev->ptrfeed->ctrl.den);
+
+ if(mult != 1.0 || velocitydata->const_acceleration != 1.0) {
+ ApplySofteningAndConstantDeceleration( velocitydata,
+ dx, dy,
+ &fdx, &fdy,
+ (mult > 1.0) && soften);
+
+ if (dx) {
+ tmp = mult * fdx + dev->last.remainder[0];
+ /* Since it may not be apparent: lrintf() does not offer
+ * strong statements about rounding; however because we
+ * process each axis conditionally, there's no danger
+ * of a toggling remainder. Its lack of guarantees likely
+ * makes it faster on the average target. */
+ *px = lrintf(tmp);
+ dev->last.remainder[0] = tmp - (float)*px;
+ }
+ if (dy) {
+ tmp = mult * fdy + dev->last.remainder[1];
+ *py = lrintf(tmp);
+ dev->last.remainder[1] = tmp - (float)*py;
+ }
+ DebugAccelF("pos (%i | %i) remainders x: %.3f y: %.3f delta x:%.3f y:%.3f\n",
+ *px, *py, dev->last.remainder[0], dev->last.remainder[1], fdx, fdy);
+ }
+ }
+ }
+ /* remember last motion delta (for softening/slow movement treatment) */
+ velocitydata->last_dx = dx;
+ velocitydata->last_dy = dy;
+}
+
+
+
+/**
+ * Originally a part of xf86PostMotionEvent; modifies valuators
+ * in-place. Retained mostly for embedded scenarios.
+ */
+void
+acceleratePointerLightweight(
+ DeviceIntPtr dev,
+ int first_valuator,
+ int num_valuators,
+ int *valuators,
+ int ignored)
+{
+ float mult = 0.0;
+ int dx = 0, dy = 0;
+ int *px = NULL, *py = NULL;
+
+ if (!num_valuators || !valuators)
+ return;
+
+ if (first_valuator == 0) {
+ dx = valuators[0];
+ px = &valuators[0];
+ }
+ if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
+ dy = valuators[1 - first_valuator];
+ py = &valuators[1 - first_valuator];
+ }
+
+ if (!dx && !dy)
+ return;
+
+ if (dev->ptrfeed && dev->ptrfeed->ctrl.num) {
+ /* modeled from xf86Events.c */
+ if (dev->ptrfeed->ctrl.threshold) {
+ if ((abs(dx) + abs(dy)) >= dev->ptrfeed->ctrl.threshold) {
+ dev->last.remainder[0] = ((float)dx *
+ (float)(dev->ptrfeed->ctrl.num)) /
+ (float)(dev->ptrfeed->ctrl.den) +
+ dev->last.remainder[0];
+ if (px) {
+ *px = (int)dev->last.remainder[0];
+ dev->last.remainder[0] = dev->last.remainder[0] -
+ (float)(*px);
+ }
+
+ dev->last.remainder[1] = ((float)dy *
+ (float)(dev->ptrfeed->ctrl.num)) /
+ (float)(dev->ptrfeed->ctrl.den) +
+ dev->last.remainder[1];
+ if (py) {
+ *py = (int)dev->last.remainder[1];
+ dev->last.remainder[1] = dev->last.remainder[1] -
+ (float)(*py);
+ }
+ }
+ }
+ else {
+ mult = pow((float)dx * (float)dx + (float)dy * (float)dy,
+ ((float)(dev->ptrfeed->ctrl.num) /
+ (float)(dev->ptrfeed->ctrl.den) - 1.0) /
+ 2.0) / 2.0;
+ if (dx) {
+ dev->last.remainder[0] = mult * (float)dx +
+ dev->last.remainder[0];
+ *px = (int)dev->last.remainder[0];
+ dev->last.remainder[0] = dev->last.remainder[0] -
+ (float)(*px);
+ }
+ if (dy) {
+ dev->last.remainder[1] = mult * (float)dy +
+ dev->last.remainder[1];
+ *py = (int)dev->last.remainder[1];
+ dev->last.remainder[1] = dev->last.remainder[1] -
+ (float)(*py);
+ }
+ }
+ }
+}
diff --git a/xorg-server/doc/c-extensions b/xorg-server/doc/c-extensions
new file mode 100644
index 000000000..eb33e272b
--- /dev/null
+++ b/xorg-server/doc/c-extensions
@@ -0,0 +1,61 @@
+First of all: C89 or better. If you don't have that, port gcc first.
+
+Use of C language extensions throughout the X server tree
+---------------------------------------------------------
+
+Optional extensions:
+The server will still build if your toolchain does not support these
+extensions, although the results may not be optimal.
+
+ * _X_SENTINEL(x): member x of the passed structure must be NULL, e.g.:
+ void parseOptions(Option *options _X_SENTINEL(0));
+ parseOptions("foo", "bar", NULL); /* this is OK */
+ parseOptions("foo", "bar", "baz"); /* this is not */
+ This definition comes from Xfuncproto.h in the core
+ protocol headers.
+ * _X_ATTRIBUTE_PRINTF(x, y): This function has printf-like semantics;
+ check the format string when built with
+ -Wformat (gcc) or similar.
+ * _X_EXPORT: this function should appear in symbol tables.
+ * _X_HIDDEN: this function should not appear in the _dynamic_ symbol
+ table.
+ * _X_INTERNAL: like _X_HIDDEN, but attempt to ensure that this function
+ is never called from another module.
+ * _X_INLINE: inline this functon if possible (generally obeyed unless
+ disabling optimisations).
+ * _X_DEPRECATED: warn on use of this function.
+
+Mandatory extensions:
+The server will not build if your toolchain does not support these extensions.
+
+ * named initialisers: explicitly initialising structure members, e.g.:
+ struct foo bar = { .baz = quux, .brian = "dog" };
+ * variadic macros: macros with a variable number of arguments, e.g.:
+ #define DebugF(x, ...) /**/
+ * interleaved code and declarations: { foo = TRUE; int bar; do_stuff(); }
+
+
+Use of OS and library facilities throughout the X server tree
+-------------------------------------------------------------
+
+Non-OS-dependent code can assume facilities at least as good as
+the non-OS-facility parts of POSIX-1.2001. Ideally this would
+be C99, but even gcc+glibc doesn't implement that yet.
+
+Unix-like systems are assumed to be at least as good as UNIX03.
+
+Linux systems must be at least 2.4 or later. As a practical matter
+though, 2.4 kernels never receive any testing. Use 2.6 already.
+
+TODO: Solaris.
+
+TODO: *BSD.
+
+Code that needs to be portable to Windows should be careful to,
+well, be portable. Note that there are two Windows ports, cygwin and
+mingw. Cygwin is more or less like Linux, but mingw is a bit more
+restrictive. TODO: document which versions of Windows we actually care
+about.
+
+OSX support is generally limited to the most recent version. Currently
+that means 10.5.
diff --git a/xorg-server/exa/exa.c b/xorg-server/exa/exa.c
index b3c5bfffe..c5ac7dec2 100644
--- a/xorg-server/exa/exa.c
+++ b/xorg-server/exa/exa.c
@@ -425,9 +425,6 @@ exaFinishAccess(DrawablePtr pDrawable, int index)
/* We always hide the devPrivate.ptr. */
pPixmap->devPrivate.ptr = NULL;
- if (pExaScr->finish_access)
- pExaScr->finish_access(pPixmap, index);
-
if (!pExaScr->info->FinishAccess || !exaPixmapHasGpuCopy(pPixmap))
return;
@@ -981,7 +978,6 @@ exaDriverInit (ScreenPtr pScreen,
pExaScr->do_move_in_pixmap = exaMoveInPixmap_mixed;
pExaScr->do_move_out_pixmap = NULL;
pExaScr->prepare_access_reg = exaPrepareAccessReg_mixed;
- pExaScr->finish_access = exaFinishAccess_mixed;
} else {
wrap(pExaScr, pScreen, CreatePixmap, exaCreatePixmap_driver);
wrap(pExaScr, pScreen, DestroyPixmap, exaDestroyPixmap_driver);
@@ -991,7 +987,6 @@ exaDriverInit (ScreenPtr pScreen,
pExaScr->do_move_in_pixmap = NULL;
pExaScr->do_move_out_pixmap = NULL;
pExaScr->prepare_access_reg = NULL;
- pExaScr->finish_access = NULL;
}
} else {
wrap(pExaScr, pScreen, CreatePixmap, exaCreatePixmap_classic);
@@ -1002,7 +997,6 @@ exaDriverInit (ScreenPtr pScreen,
pExaScr->do_move_in_pixmap = exaMoveInPixmap_classic;
pExaScr->do_move_out_pixmap = exaMoveOutPixmap_classic;
pExaScr->prepare_access_reg = exaPrepareAccessReg_classic;
- pExaScr->finish_access = NULL;
}
if (!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS)) {
LogMessage(X_INFO, "EXA(%d): Offscreen pixmap area of %lu bytes\n",
diff --git a/xorg-server/exa/exa_accel.c b/xorg-server/exa/exa_accel.c
index bd34f40fd..00a97fdbf 100644
--- a/xorg-server/exa/exa_accel.c
+++ b/xorg-server/exa/exa_accel.c
@@ -157,6 +157,10 @@ exaDoPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
if (pExaScr->fallback_counter || pExaPixmap->accel_blocked || !pExaScr->info->UploadToScreen)
return FALSE;
+ /* If there's a system copy, we want to save the result there */
+ if (pExaPixmap->pDamage)
+ return FALSE;
+
/* Don't bother with under 8bpp, XYPixmaps. */
if (format != ZPixmap || bpp < 8)
return FALSE;
@@ -1043,6 +1047,7 @@ exaFillRegionSolid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel,
pDrawable->width == 1 && pDrawable->height == 1 &&
pDrawable->bitsPerPixel != 24) {
ExaPixmapPriv(pPixmap);
+ RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
switch (pDrawable->bitsPerPixel) {
case 32:
@@ -1057,6 +1062,9 @@ exaFillRegionSolid (DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel,
REGION_UNION(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
pRegion);
+ REGION_UNION(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
+ pRegion);
+ REGION_SUBTRACT(pScreen, pending_damage, pending_damage, pRegion);
}
ret = TRUE;
@@ -1257,35 +1265,16 @@ exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
{
ExaScreenPriv (pDrawable->pScreen);
PixmapPtr pPix = exaGetDrawablePixmap (pDrawable);
+ ExaPixmapPriv(pPix);
int xoff, yoff;
Bool ok;
if (pExaScr->fallback_counter || pExaScr->swappedOut)
goto fallback;
- exaGetDrawableDeltas (pDrawable, pPix, &xoff, &yoff);
-
- if (pExaScr->do_migration) {
- BoxRec Box;
- RegionRec Reg;
- ExaMigrationRec pixmaps[1];
-
- Box.x1 = pDrawable->y + x + xoff;
- Box.y1 = pDrawable->y + y + yoff;
- Box.x2 = Box.x1 + w;
- Box.y2 = Box.y1 + h;
-
- REGION_INIT(pScreen, &Reg, &Box, 1);
-
- pixmaps[0].as_dst = FALSE;
- pixmaps[0].as_src = TRUE;
- pixmaps[0].pPix = pPix;
- pixmaps[0].pReg = &Reg;
-
- exaDoMigration(pixmaps, 1, FALSE);
-
- REGION_UNINIT(pScreen, &Reg);
- }
+ /* If there's a system copy, we want to save the result there */
+ if (pExaPixmap->pDamage)
+ goto fallback;
pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
diff --git a/xorg-server/exa/exa_migration_classic.c b/xorg-server/exa/exa_migration_classic.c
index fced663e0..9e1626c69 100644
--- a/xorg-server/exa/exa_migration_classic.c
+++ b/xorg-server/exa/exa_migration_classic.c
@@ -75,6 +75,9 @@ exaPixmapIsDirty (PixmapPtr pPix)
if (pExaPixmap == NULL)
EXA_FatalErrorDebugWithRet(("EXA bug: exaPixmapIsDirty was called on a non-exa pixmap.\n"), TRUE);
+ if (!pExaPixmap->pDamage)
+ return FALSE;
+
return REGION_NOTEMPTY (pScreen, DamageRegion(pExaPixmap->pDamage)) ||
!REGION_EQUAL(pScreen, &pExaPixmap->validSys, &pExaPixmap->validFB);
}
diff --git a/xorg-server/exa/exa_migration_mixed.c b/xorg-server/exa/exa_migration_mixed.c
index b755b83bb..6816e6c9b 100644
--- a/xorg-server/exa/exa_migration_mixed.c
+++ b/xorg-server/exa/exa_migration_mixed.c
@@ -112,7 +112,8 @@ exaDoMigration_mixed(ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel)
pPixmap->devKind = pExaPixmap->fb_pitch;
exaCopyDirtyToFb(pixmaps + i);
- if (pExaScr->deferred_mixed_pixmap == pPixmap)
+ if (pExaScr->deferred_mixed_pixmap == pPixmap &&
+ !pixmaps[i].as_dst && !pixmaps[i].pReg)
pExaScr->deferred_mixed_pixmap = NULL;
}
@@ -133,10 +134,32 @@ exaMoveInPixmap_mixed(PixmapPtr pPixmap)
exaDoMigration(pixmaps, 1, TRUE);
}
+void
+exaDamageReport_mixed(DamagePtr pDamage, RegionPtr pRegion, void *closure)
+{
+ PixmapPtr pPixmap = closure;
+ ExaPixmapPriv(pPixmap);
+
+ /* Move back results of software rendering on system memory copy of mixed driver
+ * pixmap (see exaPrepareAccessReg_mixed).
+ *
+ * Defer moving the destination back into the driver pixmap, to try and save
+ * overhead on multiple subsequent software fallbacks.
+ */
+ if (!pExaPixmap->use_gpu_copy && exaPixmapHasGpuCopy(pPixmap)) {
+ ExaScreenPriv(pPixmap->drawable.pScreen);
+
+ if (pExaScr->deferred_mixed_pixmap &&
+ pExaScr->deferred_mixed_pixmap != pPixmap)
+ exaMoveInPixmap_mixed(pExaScr->deferred_mixed_pixmap);
+ pExaScr->deferred_mixed_pixmap = pPixmap;
+ }
+}
+
/* With mixed pixmaps, if we fail to get direct access to the driver pixmap, we
* use the DownloadFromScreen hook to retrieve contents to a copy in system
* memory, perform software rendering on that and move back the results with the
- * UploadToScreen hook (see exaFinishAccess_mixed).
+ * UploadToScreen hook (see exaDamageReport_mixed).
*/
void
exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg)
@@ -171,8 +194,9 @@ exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg)
Bool as_dst = pixmaps[0].as_dst;
/* Set up damage tracking */
- pExaPixmap->pDamage = DamageCreate(NULL, NULL, DamageReportNone,
- TRUE, pPixmap->drawable.pScreen,
+ pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL,
+ DamageReportNonEmpty, TRUE,
+ pPixmap->drawable.pScreen,
pPixmap);
DamageRegister(&pPixmap->drawable, pExaPixmap->pDamage);
@@ -223,29 +247,3 @@ exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg)
}
}
-/* Move back results of software rendering on system memory copy of mixed driver
- * pixmap (see exaPrepareAccessReg_mixed).
- *
- * Defer moving the destination back into the driver pixmap, to try and save
- * overhead on multiple consequent software fallbacks.
- */
-void exaFinishAccess_mixed(PixmapPtr pPixmap, int index)
-{
- ExaPixmapPriv(pPixmap);
-
- if (pExaPixmap->pDamage && !pExaPixmap->use_gpu_copy &&
- exaPixmapHasGpuCopy(pPixmap)) {
- DamageRegionProcessPending(&pPixmap->drawable);
-
- if (index == EXA_PREPARE_DEST || index == EXA_PREPARE_AUX_DEST) {
- ExaScreenPriv(pPixmap->drawable.pScreen);
-
- if (pExaScr->deferred_mixed_pixmap &&
- pExaScr->deferred_mixed_pixmap != pPixmap)
- exaMoveInPixmap_mixed(pExaScr->deferred_mixed_pixmap);
- pExaScr->deferred_mixed_pixmap = pPixmap;
- pPixmap->devKind = pExaPixmap->fb_pitch;
- } else
- exaMoveInPixmap_mixed(pPixmap);
- }
-}
diff --git a/xorg-server/exa/exa_mixed.c b/xorg-server/exa/exa_mixed.c
index 155ed47c5..21cc3bd13 100644
--- a/xorg-server/exa/exa_mixed.c
+++ b/xorg-server/exa/exa_mixed.c
@@ -94,9 +94,25 @@ exaCreatePixmap_mixed(ScreenPtr pScreen, int w, int h, int depth,
if (!w || !h) {
exaCreateDriverPixmap_mixed(pPixmap);
pExaPixmap->use_gpu_copy = exaPixmapHasGpuCopy(pPixmap);
- } else
+ } else {
pExaPixmap->use_gpu_copy = FALSE;
+ if (w == 1 && h == 1) {
+ pExaPixmap->sys_ptr = malloc((pPixmap->drawable.bitsPerPixel + 7) / 8);
+
+ /* Set up damage tracking */
+ pExaPixmap->pDamage = DamageCreate(exaDamageReport_mixed, NULL,
+ DamageReportNonEmpty, TRUE,
+ pPixmap->drawable.pScreen,
+ pPixmap);
+
+ DamageRegister(&pPixmap->drawable, pExaPixmap->pDamage);
+ /* This ensures that pending damage reflects the current operation. */
+ /* This is used by exa to optimize migration. */
+ DamageSetReportAfterOp(pExaPixmap->pDamage, TRUE);
+ }
+ }
+
/* During a fallback we must prepare access. */
if (pExaScr->fallback_counter)
exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_AUX_DEST);
diff --git a/xorg-server/exa/exa_priv.h b/xorg-server/exa/exa_priv.h
index 085235524..21d964683 100644
--- a/xorg-server/exa/exa_priv.h
+++ b/xorg-server/exa/exa_priv.h
@@ -165,6 +165,7 @@ typedef struct {
BitmapToRegionProcPtr SavedBitmapToRegion;
CreateScreenResourcesProcPtr SavedCreateScreenResources;
ModifyPixmapHeaderProcPtr SavedModifyPixmapHeader;
+ SourceValidateProcPtr SavedSourceValidate;
#ifdef RENDER
CompositeProcPtr SavedComposite;
TrianglesProcPtr SavedTriangles;
@@ -177,7 +178,6 @@ typedef struct {
void (*do_move_in_pixmap) (PixmapPtr pPixmap);
void (*do_move_out_pixmap) (PixmapPtr pPixmap);
void (*prepare_access_reg)(PixmapPtr pPixmap, int index, RegionPtr pReg);
- void (*finish_access)(PixmapPtr pPixmap, int index);
Bool swappedOut;
enum ExaMigrationHeuristic migration;
@@ -202,6 +202,15 @@ typedef struct {
unsigned int fallback_counter;
ExaGlyphCacheRec glyphCaches[EXA_NUM_GLYPH_CACHES];
+
+ /**
+ * Regions affected by fallback composite source / mask operations.
+ */
+
+ RegionRec srcReg;
+ RegionRec maskReg;
+ PixmapPtr srcPix;
+
} ExaScreenPrivRec, *ExaScreenPrivPtr;
/*
@@ -620,10 +629,10 @@ void
exaMoveInPixmap_mixed(PixmapPtr pPixmap);
void
-exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg);
+exaDamageReport_mixed(DamagePtr pDamage, RegionPtr pRegion, void *closure);
void
-exaFinishAccess_mixed(PixmapPtr pPixmap, int index);
+exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg);
/* exa_render.c */
Bool
diff --git a/xorg-server/exa/exa_unaccel.c b/xorg-server/exa/exa_unaccel.c
index 510d89af6..adbee8413 100644
--- a/xorg-server/exa/exa_unaccel.c
+++ b/xorg-server/exa/exa_unaccel.c
@@ -123,11 +123,36 @@ ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
BoxPtr pbox, int nbox, int dx, int dy, Bool reverse,
Bool upsidedown, Pixel bitplane, void *closure)
{
+ RegionRec reg;
+ int xoff, yoff;
EXA_PRE_FALLBACK_GC(pGC);
EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));
- exaPrepareAccess (pDst, EXA_PREPARE_DEST);
- exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
+
+ if (pExaScr->prepare_access_reg) {
+ PixmapPtr pPixmap = exaGetDrawablePixmap(pSrc);
+
+ exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
+ REGION_INIT(pScreen, &reg, pbox, nbox);
+ REGION_TRANSLATE(pScreen, &reg, xoff + dx, yoff + dy);
+ pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, &reg);
+ REGION_UNINIT(pScreen, &reg);
+ } else
+ exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
+
+ if (pExaScr->prepare_access_reg &&
+ !exaGCReadsDestination(pDst, pGC->planemask, pGC->fillStyle,
+ pGC->alu, pGC->clientClipType)) {
+ PixmapPtr pPixmap = exaGetDrawablePixmap(pDst);
+
+ exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
+ REGION_INIT(pScreen, &reg, pbox, nbox);
+ REGION_TRANSLATE(pScreen, &reg, xoff, yoff);
+ pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST, &reg);
+ REGION_UNINIT(pScreen, &reg);
+ } else
+ exaPrepareAccess (pDst, EXA_PREPARE_DEST);
+
/* This will eventually call fbCopyNtoN, with some calculation overhead. */
while (nbox--) {
pGC->ops->CopyArea (pSrc, pDst, pGC, pbox->x1 - pSrc->x + dx, pbox->y1 - pSrc->y + dy,
@@ -139,6 +164,40 @@ ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
EXA_POST_FALLBACK_GC(pGC);
}
+static void
+ExaFallbackPrepareReg(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x, int y, int width, int height,
+ int index, Bool checkReads)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ ExaScreenPriv(pScreen);
+
+ if (pExaScr->prepare_access_reg &&
+ !(checkReads && exaGCReadsDestination(pDrawable,
+ pGC->planemask,
+ pGC->fillStyle,
+ pGC->alu,
+ pGC->clientClipType))) {
+ BoxRec box;
+ RegionRec reg;
+ int xoff, yoff;
+ PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable);
+
+ exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
+ box.x1 = pDrawable->x + x + xoff;
+ box.y1 = pDrawable->y + y + yoff;
+ box.x2 = box.x1 + width;
+ box.y2 = box.y1 + height;
+
+ REGION_INIT(pScreen, &reg, &box, 1);
+ pExaScr->prepare_access_reg(pPixmap, index, &reg);
+ REGION_UNINIT(pScreen, &reg);
+ } else
+ exaPrepareAccess(pDrawable, index);
+}
+
+
RegionPtr
ExaCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int srcx, int srcy, int w, int h, int dstx, int dsty)
@@ -148,8 +207,10 @@ ExaCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
EXA_PRE_FALLBACK_GC(pGC);
EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));
- exaPrepareAccess (pDst, EXA_PREPARE_DEST);
- exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
+ ExaFallbackPrepareReg(pSrc, pGC, srcx, srcy, w, h,
+ EXA_PREPARE_SRC, FALSE);
+ ExaFallbackPrepareReg(pDst, pGC, dstx, dsty, w, h,
+ EXA_PREPARE_DEST, TRUE);
ret = pGC->ops->CopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
exaFinishAccess (pSrc, EXA_PREPARE_SRC);
exaFinishAccess (pDst, EXA_PREPARE_DEST);
@@ -168,8 +229,10 @@ ExaCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
EXA_PRE_FALLBACK_GC(pGC);
EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));
- exaPrepareAccess (pDst, EXA_PREPARE_DEST);
- exaPrepareAccess (pSrc, EXA_PREPARE_SRC);
+ ExaFallbackPrepareReg(pSrc, pGC, srcx, srcy, w, h,
+ EXA_PREPARE_SRC, FALSE);
+ ExaFallbackPrepareReg(pDst, pGC, dstx, dsty, w, h,
+ EXA_PREPARE_DEST, TRUE);
ret = pGC->ops->CopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty,
bitPlane);
exaFinishAccess (pSrc, EXA_PREPARE_SRC);
@@ -295,8 +358,10 @@ ExaCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
EXA_FALLBACK(("from %p to %p (%c,%c)\n", pBitmap, pDrawable,
exaDrawableLocation(&pBitmap->drawable),
exaDrawableLocation(pDrawable)));
- exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
- exaPrepareAccess (&pBitmap->drawable, EXA_PREPARE_SRC);
+ ExaFallbackPrepareReg(pDrawable, pGC, x, y, w, h,
+ EXA_PREPARE_DEST, TRUE);
+ ExaFallbackPrepareReg(&pBitmap->drawable, pGC, 0, 0, w, h,
+ EXA_PREPARE_SRC, FALSE);
exaPrepareAccessGC (pGC);
pGC->ops->PushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
exaFinishAccessGC (pGC);
@@ -313,8 +378,18 @@ ExaCheckCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
EXA_PRE_FALLBACK(pScreen);
EXA_FALLBACK(("from %p\n", pWin));
- /* being both src and dest, src is safest. */
- exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);
+ /* Only need the source bits, the destination region will be overwritten */
+ if (pExaScr->prepare_access_reg) {
+ PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
+ int xoff, yoff;
+
+ exaGetDrawableDeltas(&pWin->drawable, pPixmap, &xoff, &yoff);
+ REGION_TRANSLATE(pScreen, prgnSrc, xoff, yoff);
+ pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, prgnSrc);
+ REGION_TRANSLATE(pScreen, prgnSrc, -xoff, -yoff);
+ } else
+ exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);
+
swap(pExaScr, pScreen, CopyWindow);
pScreen->CopyWindow (pWin, ptOldOrg, prgnSrc);
swap(pExaScr, pScreen, CopyWindow);
@@ -327,29 +402,12 @@ ExaCheckGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
unsigned int format, unsigned long planeMask, char *d)
{
ScreenPtr pScreen = pDrawable->pScreen;
- PixmapPtr pPix = exaGetDrawablePixmap (pDrawable);
EXA_PRE_FALLBACK(pScreen);
EXA_FALLBACK(("from %p (%c)\n", pDrawable,
exaDrawableLocation(pDrawable)));
- if (pExaScr->prepare_access_reg) {
- int xoff, yoff;
- BoxRec Box;
- RegionRec Reg;
-
- exaGetDrawableDeltas(pDrawable, pPix, &xoff, &yoff);
-
- Box.x1 = pDrawable->y + x + xoff;
- Box.y1 = pDrawable->y + y + yoff;
- Box.x2 = Box.x1 + w;
- Box.y2 = Box.y1 + h;
-
- REGION_INIT(pScreen, &Reg, &Box, 1);
-
- pExaScr->prepare_access_reg(pPix, EXA_PREPARE_SRC, &Reg);
- } else
- exaPrepareAccess(pDrawable, EXA_PREPARE_SRC);
-
+ ExaFallbackPrepareReg(pDrawable, NULL, x, y, w, h,
+ EXA_PREPARE_SRC, FALSE);
swap(pExaScr, pScreen, GetImage);
pScreen->GetImage (pDrawable, x, y, w, h, format, planeMask, d);
swap(pExaScr, pScreen, GetImage);
@@ -377,6 +435,173 @@ ExaCheckGetSpans (DrawablePtr pDrawable,
EXA_POST_FALLBACK(pScreen);
}
+static void
+ExaSrcValidate(DrawablePtr pDrawable,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ ExaScreenPriv(pScreen);
+ PixmapPtr pPix = exaGetDrawablePixmap (pDrawable);
+ BoxRec box;
+ RegionRec reg;
+ RegionPtr dst;
+ int xoff, yoff;
+
+ exaGetDrawableDeltas(pDrawable, pPix, &xoff, &yoff);
+
+ box.x1 = x + xoff;
+ box.y1 = y + yoff;
+ box.x2 = box.x1 + width;
+ box.y2 = box.y1 + height;
+
+ dst = (pExaScr->srcPix == pPix) ? &pExaScr->srcReg :
+ &pExaScr->maskReg;
+
+ REGION_INIT(pScreen, &reg, &box, 1);
+ REGION_UNION(pScreen, dst, dst, &reg);
+ REGION_UNINIT(pScreen, &reg);
+
+ swap(pExaScr, pScreen, SourceValidate);
+ pScreen->SourceValidate(pDrawable, x, y, width, height);
+ swap(pExaScr, pScreen, SourceValidate);
+}
+
+static Bool
+ExaPrepareCompositeReg(ScreenPtr pScreen,
+ CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ RegionRec region;
+ RegionPtr dstReg = NULL;
+ RegionPtr srcReg = NULL;
+ RegionPtr maskReg = NULL;
+ PixmapPtr pSrcPix = NULL;
+ PixmapPtr pMaskPix = NULL;
+ PixmapPtr pDstPix;
+ ExaScreenPriv(pScreen);
+ Bool ret;
+
+
+ REGION_NULL(pScreen, &region);
+
+ if (pSrc->pDrawable) {
+ pSrcPix = exaGetDrawablePixmap(pSrc->pDrawable);
+ REGION_NULL(pScreen, &pExaScr->srcReg);
+ srcReg = &pExaScr->srcReg;
+ pExaScr->srcPix = pSrcPix;
+ if (pSrc != pDst)
+ REGION_TRANSLATE(pScreen, pSrc->pCompositeClip,
+ -pSrc->pDrawable->x,
+ -pSrc->pDrawable->y);
+ }
+
+ if (pMask && pMask->pDrawable) {
+ pMaskPix = exaGetDrawablePixmap(pMask->pDrawable);
+ REGION_NULL(pScreen, &pExaScr->maskReg);
+ maskReg = &pExaScr->maskReg;
+ if (pMask != pDst && pMask != pSrc)
+ REGION_TRANSLATE(pScreen, pMask->pCompositeClip,
+ -pMask->pDrawable->x,
+ -pMask->pDrawable->y);
+ }
+
+ REGION_TRANSLATE(pScreen, pDst->pCompositeClip,
+ -pDst->pDrawable->x,
+ -pDst->pDrawable->y);
+
+ pExaScr->SavedSourceValidate = ExaSrcValidate;
+ swap(pExaScr, pScreen, SourceValidate);
+ ret = miComputeCompositeRegion (&region, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask,
+ xDst,
+ yDst,
+ width, height);
+ swap(pExaScr, pScreen, SourceValidate);
+
+ REGION_TRANSLATE(pScreen, pDst->pCompositeClip,
+ pDst->pDrawable->x,
+ pDst->pDrawable->y);
+ if (pSrc->pDrawable && pSrc != pDst)
+ REGION_TRANSLATE(pScreen, pSrc->pCompositeClip,
+ pSrc->pDrawable->x,
+ pSrc->pDrawable->y);
+ if (pMask && pMask->pDrawable && pMask != pDst && pMask != pSrc)
+ REGION_TRANSLATE(pScreen, pMask->pCompositeClip,
+ pMask->pDrawable->x,
+ pMask->pDrawable->y);
+
+ if (!ret) {
+ if (srcReg)
+ REGION_UNINIT(pScreen, srcReg);
+ if (maskReg)
+ REGION_UNINIT(pScreen, maskReg);
+
+ return FALSE;
+ }
+
+ /**
+ * Don't limit alphamaps readbacks for now until we've figured out how that
+ * should be done.
+ */
+
+ if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
+ pExaScr->prepare_access_reg(exaGetDrawablePixmap(pSrc->alphaMap->pDrawable),
+ EXA_PREPARE_AUX_SRC,
+ NULL);
+ if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
+ pExaScr->prepare_access_reg(exaGetDrawablePixmap(pMask->alphaMap->pDrawable),
+ EXA_PREPARE_AUX_MASK,
+ NULL);
+
+ if (pSrcPix)
+ pExaScr->prepare_access_reg(pSrcPix,
+ EXA_PREPARE_SRC,
+ srcReg);
+
+ if (pMaskPix)
+ pExaScr->prepare_access_reg(pMaskPix,
+ EXA_PREPARE_MASK,
+ maskReg);
+
+ if (srcReg)
+ REGION_UNINIT(pScreen, srcReg);
+ if (maskReg)
+ REGION_UNINIT(pScreen, maskReg);
+
+ pDstPix = exaGetDrawablePixmap(pDst->pDrawable);
+ if (!exaOpReadsDestination(op)) {
+ int xoff;
+ int yoff;
+
+ exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &xoff, &yoff);
+ REGION_TRANSLATE(pScreen, &region, pDst->pDrawable->x + xoff,
+ pDst->pDrawable->y + yoff);
+ dstReg = &region;
+ }
+
+ if (pDst->alphaMap && pDst->alphaMap->pDrawable)
+ pExaScr->prepare_access_reg(exaGetDrawablePixmap(pDst->alphaMap->pDrawable),
+ EXA_PREPARE_AUX_DEST,
+ dstReg);
+ pExaScr->prepare_access_reg(pDstPix, EXA_PREPARE_DEST, dstReg);
+
+ REGION_UNINIT(pScreen, &region);
+ return TRUE;
+}
+
void
ExaCheckComposite (CARD8 op,
PicturePtr pSrc,
@@ -395,54 +620,38 @@ ExaCheckComposite (CARD8 op,
#ifdef RENDER
PictureScreenPtr ps = GetPictureScreen(pScreen);
#endif /* RENDER */
- RegionRec region;
- int xoff, yoff;
EXA_PRE_FALLBACK(pScreen);
- REGION_NULL(pScreen, &region);
-
- /* We need to prepare access to any separate alpha maps first, in case the
- * driver doesn't support EXA_PREPARE_AUX*, in which case EXA_PREPARE_SRC
- * may be used for moving them out.
- */
- if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
- exaPrepareAccess(pSrc->alphaMap->pDrawable, EXA_PREPARE_AUX_SRC);
- if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
- exaPrepareAccess(pMask->alphaMap->pDrawable, EXA_PREPARE_AUX_MASK);
-
- if (!exaOpReadsDestination(op) && pExaScr->prepare_access_reg) {
- PixmapPtr pDstPix;
-
- if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask,
- xDst + pDst->pDrawable->x,
- yDst + pDst->pDrawable->y,
- width, height))
- goto skip;
-
- pDstPix = exaGetDrawablePixmap(pDst->pDrawable);
- exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &xoff, &yoff);
- REGION_TRANSLATE(pScreen, &region, xoff, yoff);
+ if (pExaScr->prepare_access_reg) {
+ if (!ExaPrepareCompositeReg(pScreen, op, pSrc, pMask, pDst, xSrc,
+ ySrc, xMask, yMask, xDst, yDst, width,
+ height))
+ goto out_no_clip;
+ } else {
- if (pDst->alphaMap && pDst->alphaMap->pDrawable)
- pExaScr->prepare_access_reg(exaGetDrawablePixmap(pDst->alphaMap->pDrawable),
- EXA_PREPARE_AUX_DEST, &region);
+ /* We need to prepare access to any separate alpha maps first,
+ * in case the driver doesn't support EXA_PREPARE_AUX*,
+ * in which case EXA_PREPARE_SRC may be used for moving them out.
+ */
- pExaScr->prepare_access_reg(pDstPix, EXA_PREPARE_DEST, &region);
- } else {
+ if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
+ exaPrepareAccess(pSrc->alphaMap->pDrawable, EXA_PREPARE_AUX_SRC);
+ if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
+ exaPrepareAccess(pMask->alphaMap->pDrawable, EXA_PREPARE_AUX_MASK);
if (pDst->alphaMap && pDst->alphaMap->pDrawable)
exaPrepareAccess(pDst->alphaMap->pDrawable, EXA_PREPARE_AUX_DEST);
exaPrepareAccess (pDst->pDrawable, EXA_PREPARE_DEST);
- }
- EXA_FALLBACK(("from picts %p/%p to pict %p\n",
- pSrc, pMask, pDst));
+ EXA_FALLBACK(("from picts %p/%p to pict %p\n",
+ pSrc, pMask, pDst));
+
+ if (pSrc->pDrawable != NULL)
+ exaPrepareAccess (pSrc->pDrawable, EXA_PREPARE_SRC);
+ if (pMask && pMask->pDrawable != NULL)
+ exaPrepareAccess (pMask->pDrawable, EXA_PREPARE_MASK);
+ }
- if (pSrc->pDrawable != NULL)
- exaPrepareAccess (pSrc->pDrawable, EXA_PREPARE_SRC);
- if (pMask && pMask->pDrawable != NULL)
- exaPrepareAccess (pMask->pDrawable, EXA_PREPARE_MASK);
#ifdef RENDER
swap(pExaScr, ps, Composite);
ps->Composite (op,
@@ -466,14 +675,12 @@ ExaCheckComposite (CARD8 op,
exaFinishAccess (pDst->pDrawable, EXA_PREPARE_DEST);
if (pDst->alphaMap && pDst->alphaMap->pDrawable)
exaFinishAccess(pDst->alphaMap->pDrawable, EXA_PREPARE_AUX_DEST);
-
-skip:
if (pSrc->alphaMap && pSrc->alphaMap->pDrawable)
exaFinishAccess(pSrc->alphaMap->pDrawable, EXA_PREPARE_AUX_SRC);
if (pMask && pMask->alphaMap && pMask->alphaMap->pDrawable)
exaFinishAccess(pMask->alphaMap->pDrawable, EXA_PREPARE_AUX_MASK);
- REGION_UNINIT(pScreen, &region);
+out_no_clip:
EXA_POST_FALLBACK(pScreen);
}
diff --git a/xorg-server/hw/dmx/dmxinput.c b/xorg-server/hw/dmx/dmxinput.c
index d9118b6a0..c099349d8 100644
--- a/xorg-server/hw/dmx/dmxinput.c
+++ b/xorg-server/hw/dmx/dmxinput.c
@@ -103,7 +103,8 @@ void dmxUpdateWindowInfo(DMXUpdateType type, WindowPtr pWindow)
}
int
-NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
+NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
+ DeviceIntPtr *pdev)
{
return BadRequest;
}
diff --git a/xorg-server/hw/kdrive/Xkdrive.man b/xorg-server/hw/kdrive/Xkdrive.man
new file mode 100644
index 000000000..b37f9f10a
--- /dev/null
+++ b/xorg-server/hw/kdrive/Xkdrive.man
@@ -0,0 +1,57 @@
+.\" $RCSId: xc/programs/Xserver/hw/kdrive/Xkdrive.man,v 1.3 2001/01/24 00:06:10 dawes Exp $
+.\"
+.TH Xkdrive 1 __vendorversion__
+.SH NAME
+Xkdrive \- tiny X server
+.SH SYNOPSIS
+.B Xvesa
+.RI [ :display ]
+.RI [ option ...]
+
+.B Xfbdev
+.RI [ :display ]
+.RI [ option ...]
+.SH DESCRIPTION
+.B Xkdrive
+is a family of X servers designed to be particularly small. This
+manual page describes the common functionality of the
+.B Xkdrive
+servers; for information on a specific X server, please refer to the
+relevant manual page.
+.SH OPTIONS
+In addition to the standard options accepted by all X servers (see
+Xserver(1)), all the
+.B Xkdrive
+servers accept the following options:
+.TP 8
+.B -card \fIpcmcia\fP
+use pcmcia card as additional screen.
+.TP 8
+.B -dumb
+disable hardware acceleration.
+.TP 8
+.B -origin \fIX\fP,\fIY\fP
+Locates the next screen in the Xinerama virtual screen.
+.TP 8
+.B -screen \fIwidth\fBx\fIheight\fR[\fBx\fIdepth\fR[\fBx\fIfreq\fR]]\fR[\fB@\fIrotation\fR]\fB
+use a screen of the specified \fIwidth\fP, \fIheight\fP, screen \fIdepth\fP, \fIfrequency\fP, and \fIrotation\fP (0, 90, 180 and 270 are legal values).
+.TP 8
+.B -softCursor
+disable the hardware cursor.
+.TP 8
+.B -videoTest
+start the server, pause momentarily, and exit.
+.TP 8
+.B -zaphod
+disable switching screens by moving the pointer across a screen boundary.
+.TP 8
+.B -2button
+enable emulation of a middle mouse button by chording.
+.TP 8
+.B -3button
+disable emulation of a middle mouse button by chording.
+.SH SEE ALSO
+X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1), Xvesa(1), Xfbdev(1).
+.SH AUTHORS
+The Xkdrive common core was written by Keith Packard,
+and is based on the Sample Implementation of X.
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.c b/xorg-server/hw/kdrive/ephyr/ephyr.c
index 87e48afaf..c3b3aeff5 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.c
@@ -1085,8 +1085,7 @@ MouseInit (KdPointerInfo *pi)
((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
pi->nAxes = 3;
pi->nButtons = 32;
- if (pi->name)
- xfree(pi->name);
+ xfree(pi->name);
pi->name = strdup("Xephyr virtual mouse");
ephyrMouse = pi;
return Success;
@@ -1136,8 +1135,7 @@ EphyrKeyboardInit (KdKeyboardInfo *ki)
}
ki->minScanCode = ephyrKeySyms.minKeyCode;
ki->maxScanCode = ephyrKeySyms.maxKeyCode;
- if (ki->name)
- xfree(ki->name);
+ xfree(ki->name);
ki->name = strdup("Xephyr virtual keyboard");
ephyrKbd = ki;
return Success;
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.h b/xorg-server/hw/kdrive/ephyr/ephyr.h
index dd22bd150..5479736e3 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.h
@@ -1,204 +1,203 @@
-/*
- * Xephyr - A kdrive X server thats runs in a host X window.
- * Authored by Matthew Allum <mallum@o-hand.com>
- *
- * Copyright © 2004 Nokia
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Nokia not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Nokia makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _EPHYR_H_
-#define _EPHYR_H_
-#include <stdio.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#include <libgen.h>
-#endif
-#include <signal.h>
-
-#include "os.h" /* for OsSignal() */
-#include "kdrive.h"
-#include "hostx.h"
-#include "exa.h"
-
-#ifdef RANDR
-#include "randrstr.h"
-#endif
-
-#include "damage.h"
-
-typedef struct _ephyrPriv {
- CARD8 *base;
- int bytes_per_line;
-} EphyrPriv;
-
-typedef struct _ephyrFakexaPriv {
- ExaDriverPtr exa;
- Bool is_synced;
-
- /* The following are arguments and other information from Prepare* calls
- * which are stored for use in the inner calls.
- */
- int op;
- PicturePtr pSrcPicture, pMaskPicture, pDstPicture;
- void *saved_ptrs[3];
- PixmapPtr pDst, pSrc, pMask;
- GCPtr pGC;
-} EphyrFakexaPriv;
-
-typedef struct _ephyrScrPriv {
- Rotation randr;
- Bool shadow;
- PixmapPtr pShadow;
- DamagePtr pDamage;
- EphyrFakexaPriv *fakexa;
-} EphyrScrPriv;
-
-extern KdCardFuncs ephyrFuncs;
-extern KdKeyboardInfo *ephyrKbd;
-extern KdPointerInfo *ephyrMouse;
-
-extern miPointerScreenFuncRec ephyrPointerScreenFuncs;
-
-Bool
-ephyrInitialize (KdCardInfo *card, EphyrPriv *priv);
-
-Bool
-ephyrCardInit (KdCardInfo *card);
-
-Bool
-ephyrScreenInit (KdScreenInfo *screen);
-
-Bool
-ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv);
-
-Bool
-ephyrInitScreen (ScreenPtr pScreen);
-
-Bool
-ephyrFinishInitScreen (ScreenPtr pScreen);
-
-Bool
-ephyrCreateResources (ScreenPtr pScreen);
-
-void
-ephyrPreserve (KdCardInfo *card);
-
-Bool
-ephyrEnable (ScreenPtr pScreen);
-
-Bool
-ephyrDPMS (ScreenPtr pScreen, int mode);
-
-void
-ephyrDisable (ScreenPtr pScreen);
-
-void
-ephyrRestore (KdCardInfo *card);
-
-void
-ephyrScreenFini (KdScreenInfo *screen);
-
-void
-ephyrCardFini (KdCardInfo *card);
-
-void
-ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
-
-void
-ephyrPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
-
-Bool
-ephyrMapFramebuffer (KdScreenInfo *screen);
-
-void *
-ephyrWindowLinear (ScreenPtr pScreen,
- CARD32 row,
- CARD32 offset,
- int mode,
- CARD32 *size,
- void *closure);
-
-void
-ephyrSetScreenSizes (ScreenPtr pScreen);
-
-Bool
-ephyrUnmapFramebuffer (KdScreenInfo *screen);
-
-void
-ephyrUnsetInternalDamage (ScreenPtr pScreen);
-
-Bool
-ephyrSetInternalDamage (ScreenPtr pScreen);
-
-Bool
-ephyrCreateColormap (ColormapPtr pmap);
-
-void
-ephyrPoll(void);
-
-#ifdef RANDR
-Bool
-ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
-
-Bool
-ephyrRandRSetConfig (ScreenPtr pScreen,
- Rotation randr,
- int rate,
- RRScreenSizePtr pSize);
-Bool
-ephyrRandRInit (ScreenPtr pScreen);
-
-void
-ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
-
-#endif
-
-void
-ephyrUpdateModifierState(unsigned int state);
-
-extern KdPointerDriver EphyrMouseDriver;
-
-extern KdKeyboardDriver EphyrKeyboardDriver;
-
-extern KdOsFuncs EphyrOsFuncs;
-
-extern Bool ephyrCursorInit(ScreenPtr pScreen);
-
-extern void ephyrCursorEnable(ScreenPtr pScreen);
-
-/* ephyr_draw.c */
-
-Bool
-ephyrDrawInit(ScreenPtr pScreen);
-
-void
-ephyrDrawEnable(ScreenPtr pScreen);
-
-void
-ephyrDrawDisable(ScreenPtr pScreen);
-
-void
-ephyrDrawFini(ScreenPtr pScreen);
-
-/*ephyvideo.c*/
-
-Bool ephyrInitVideo(ScreenPtr pScreen) ;
-
-#endif
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@o-hand.com>
+ *
+ * Copyright © 2004 Nokia
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Nokia not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Nokia makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _EPHYR_H_
+#define _EPHYR_H_
+#include <stdio.h>
+#ifndef _MSC_VER
+#include <unistd.h>
+#include <libgen.h>
+#endif
+#include <signal.h>
+
+#include "os.h" /* for OsSignal() */
+#include "kdrive.h"
+#include "hostx.h"
+#include "exa.h"
+
+#ifdef RANDR
+#include "randrstr.h"
+#endif
+
+#include "damage.h"
+
+typedef struct _ephyrPriv {
+ CARD8 *base;
+ int bytes_per_line;
+} EphyrPriv;
+
+typedef struct _ephyrFakexaPriv {
+ ExaDriverPtr exa;
+ Bool is_synced;
+
+ /* The following are arguments and other information from Prepare* calls
+ * which are stored for use in the inner calls.
+ */
+ int op;
+ PicturePtr pSrcPicture, pMaskPicture, pDstPicture;
+ void *saved_ptrs[3];
+ PixmapPtr pDst, pSrc, pMask;
+ GCPtr pGC;
+} EphyrFakexaPriv;
+
+typedef struct _ephyrScrPriv {
+ Rotation randr;
+ Bool shadow;
+ DamagePtr pDamage;
+ EphyrFakexaPriv *fakexa;
+} EphyrScrPriv;
+
+extern KdCardFuncs ephyrFuncs;
+extern KdKeyboardInfo *ephyrKbd;
+extern KdPointerInfo *ephyrMouse;
+
+extern miPointerScreenFuncRec ephyrPointerScreenFuncs;
+
+Bool
+ephyrInitialize (KdCardInfo *card, EphyrPriv *priv);
+
+Bool
+ephyrCardInit (KdCardInfo *card);
+
+Bool
+ephyrScreenInit (KdScreenInfo *screen);
+
+Bool
+ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv);
+
+Bool
+ephyrInitScreen (ScreenPtr pScreen);
+
+Bool
+ephyrFinishInitScreen (ScreenPtr pScreen);
+
+Bool
+ephyrCreateResources (ScreenPtr pScreen);
+
+void
+ephyrPreserve (KdCardInfo *card);
+
+Bool
+ephyrEnable (ScreenPtr pScreen);
+
+Bool
+ephyrDPMS (ScreenPtr pScreen, int mode);
+
+void
+ephyrDisable (ScreenPtr pScreen);
+
+void
+ephyrRestore (KdCardInfo *card);
+
+void
+ephyrScreenFini (KdScreenInfo *screen);
+
+void
+ephyrCardFini (KdCardInfo *card);
+
+void
+ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+void
+ephyrPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+Bool
+ephyrMapFramebuffer (KdScreenInfo *screen);
+
+void *
+ephyrWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure);
+
+void
+ephyrSetScreenSizes (ScreenPtr pScreen);
+
+Bool
+ephyrUnmapFramebuffer (KdScreenInfo *screen);
+
+void
+ephyrUnsetInternalDamage (ScreenPtr pScreen);
+
+Bool
+ephyrSetInternalDamage (ScreenPtr pScreen);
+
+Bool
+ephyrCreateColormap (ColormapPtr pmap);
+
+void
+ephyrPoll(void);
+
+#ifdef RANDR
+Bool
+ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
+
+Bool
+ephyrRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize);
+Bool
+ephyrRandRInit (ScreenPtr pScreen);
+
+void
+ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
+
+#endif
+
+void
+ephyrUpdateModifierState(unsigned int state);
+
+extern KdPointerDriver EphyrMouseDriver;
+
+extern KdKeyboardDriver EphyrKeyboardDriver;
+
+extern KdOsFuncs EphyrOsFuncs;
+
+extern Bool ephyrCursorInit(ScreenPtr pScreen);
+
+extern void ephyrCursorEnable(ScreenPtr pScreen);
+
+/* ephyr_draw.c */
+
+Bool
+ephyrDrawInit(ScreenPtr pScreen);
+
+void
+ephyrDrawEnable(ScreenPtr pScreen);
+
+void
+ephyrDrawDisable(ScreenPtr pScreen);
+
+void
+ephyrDrawFini(ScreenPtr pScreen);
+
+/*ephyvideo.c*/
+
+Bool ephyrInitVideo(ScreenPtr pScreen) ;
+
+#endif
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
index f741d7420..5f5fd3bff 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
@@ -440,10 +440,9 @@ ephyrDRIClipNotify (WindowPtr a_win,
is_ok = TRUE ;
out:
- if (rects) {
- xfree (rects) ;
- rects = NULL ;
- }
+ xfree (rects) ;
+ rects = NULL ;
+
EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
/*do cleanup here*/
}
@@ -566,10 +565,9 @@ EphyrDuplicateVisual (unsigned int a_screen,
is_ok = TRUE ;
out:
- if (new_visuals) {
- xfree (new_visuals) ;
- new_visuals = NULL ;
- }
+ xfree (new_visuals) ;
+ new_visuals = NULL ;
+
EPHYR_LOG ("leave\n") ;
return is_ok ;
}
@@ -1254,10 +1252,9 @@ ProcXF86DRIGetDrawableInfo (register ClientPtr client)
sizeof(drm_clip_rect_t) * rep.numBackClipRects,
(char *)backClipRects);
}
- if (clipRects) {
- xfree(clipRects);
- clipRects = NULL ;
- }
+ xfree(clipRects);
+ clipRects = NULL ;
+
EPHYR_LOG ("leave\n") ;
return (client->noClientException);
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrglxext.c b/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
index 63c4ceda4..a0278cc2b 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
@@ -243,10 +243,9 @@ ephyrGLXGetVisualConfigsReal (__GLXclientState *a_cl,
out:
EPHYR_LOG ("leave\n") ;
- if (props_buf) {
- xfree (props_buf) ;
- props_buf = NULL ;
- }
+ xfree (props_buf) ;
+ props_buf = NULL ;
+
return res ;
}
@@ -301,10 +300,9 @@ ephyrGLXGetFBConfigsSGIXReal (__GLXclientState *a_cl,
out:
EPHYR_LOG ("leave\n") ;
- if (props_buf) {
- xfree (props_buf) ;
- props_buf = NULL ;
- }
+ xfree (props_buf) ;
+ props_buf = NULL ;
+
return res ;
}
@@ -391,14 +389,12 @@ ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc)
out:
EPHYR_LOG ("leave\n") ;
- if (server_string) {
- xfree (server_string) ;
- server_string = NULL;
- }
- if (buf) {
- xfree (buf);
- buf = NULL;
- }
+ xfree (server_string) ;
+ server_string = NULL;
+
+ xfree (buf);
+ buf = NULL;
+
return res ;
}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.c b/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.c
new file mode 100644
index 000000000..ce3f01852
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.c
@@ -0,0 +1,94 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#include <X11/Xlibint.h>
+#define _HAVE_XALLOC_DECLS
+#include "ephyrlog.h"
+#include "ephyrhostproxy.h"
+#include "hostx.h"
+
+/* byte swap a short */
+#define swaps(x, n) { \
+ n = ((char *) (x))[0];\
+ ((char *) (x))[0] = ((char *) (x))[1];\
+ ((char *) (x))[1] = n; }
+
+#define GetXReq(req) \
+ WORD64ALIGN ;\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *)(dpy->last_req = dpy->bufptr);\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+
+
+Bool
+ephyrHostProxyDoForward (pointer a_request_buffer,
+ struct XReply *a_reply,
+ Bool a_do_swap)
+{
+ Bool is_ok = FALSE ;
+ int n=0 ;
+ Display *dpy=hostx_get_display () ;
+ xReq *in_req = (xReq*) a_request_buffer ;
+ xReq *forward_req=NULL ;
+ struct XReply reply ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (in_req && dpy, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (a_do_swap) {
+ swaps (&in_req->length, n) ;
+ }
+ EPHYR_LOG ("Req {type:%d, data:%d, length:%d}\n",
+ in_req->reqType, in_req->data, in_req->length) ;
+ GetXReq (forward_req) ;
+ memmove (forward_req, in_req, 4) ;
+
+ if (!_XReply (dpy, (xReply*) &reply, 0, FALSE)) {
+ EPHYR_LOG_ERROR ("failed to get reply\n") ;
+ goto out;
+ }
+ EPHYR_LOG ("XReply{type:%d, foo:%d, seqnum:%d, length:%d}\n",
+ reply.type, reply.foo, reply.sequence_number, reply.length) ;
+
+ if (a_reply) {
+ memmove (a_reply, &reply, sizeof (reply)) ;
+ }
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.h b/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.h
new file mode 100644
index 000000000..720c986ff
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostproxy.h
@@ -0,0 +1,51 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+
+#ifndef __EPHYRHOSTPROXY_H__
+#define __EPHYRHOSTPROXY_H__
+
+struct XReply {
+ int8_t type ;/*X_Reply*/
+ int8_t foo;
+ int16_t sequence_number ;
+ int32_t length ;
+ /*following is some data up to 32 bytes lenght*/
+ int32_t pad0 ;
+ int32_t pad1 ;
+ int32_t pad2 ;
+ int32_t pad3 ;
+ int32_t pad4 ;
+ int32_t pad5 ;
+};
+
+Bool
+ephyrHostProxyDoForward (pointer a_request_buffer,
+ struct XReply *a_reply,
+ Bool a_do_swap) ;
+
+#endif /*__EPHYRHOSTPROXY_H__*/
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c b/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c
index 41c0b755b..f4a1b9d17 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c
@@ -485,10 +485,8 @@ ephyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
if (!a_encodings)
return ;
for (i=0; i < a_num_encodings; i++) {
- if (a_encodings[i].name) {
- xfree (a_encodings[i].name) ;
- a_encodings[i].name = NULL ;
- }
+ xfree (a_encodings[i].name) ;
+ a_encodings[i].name = NULL ;
}
xfree (a_encodings) ;
}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrproxyext.c b/xorg-server/hw/kdrive/ephyr/ephyrproxyext.c
new file mode 100644
index 000000000..0c070f4c7
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrproxyext.c
@@ -0,0 +1,119 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+
+/*
+ * \file
+ * This file defines a proxy extension that forwards requests.
+ * When a request to extension FOO is sent to Xephyr, that request is forwared
+ * to the host X, without even trying to know what the request means.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "ephyrproxyext.h"
+#define _HAVE_XALLOC_DECLS
+#include "ephyrlog.h"
+#include "ephyrhostproxy.h"
+#include "hostx.h"
+
+static Bool ephyrProxyGetHostExtensionInfo (const char *a_ext_name,
+ int *a_major_opcode,
+ int *a_first_event,
+ int *a_first_error) ;
+
+static int ephyrProxyProcDispatch (ClientPtr client) ;
+
+static Bool
+ephyrProxyGetHostExtensionInfo (const char *a_ext_name,
+ int *a_major_opcode,
+ int *a_first_event,
+ int *a_first_error)
+{
+ return hostx_get_extension_info (a_ext_name, a_major_opcode,
+ a_first_event, a_first_error) ;
+}
+
+static int
+ephyrProxyProcDispatch (ClientPtr a_client)
+{
+ int res=BadImplementation ;
+ struct XReply reply ;
+
+ if (!ephyrHostProxyDoForward (a_client->requestBuffer, &reply, FALSE)) {
+ EPHYR_LOG_ERROR ("forwarding failed\n") ;
+ goto out ;
+ }
+ reply.sequence_number = a_client->sequence;
+ res = Success ;
+
+ WriteToClient(a_client, 32, (char *)&reply);
+
+out:
+ return res ;
+}
+
+static void
+ephyrProxyProcReset (ExtensionEntry *a_entry)
+{
+}
+
+Bool
+ephyrProxyExtensionInit (const char *a_extension_name)
+{
+ Bool is_ok = FALSE ;
+ int major_opcode=0, first_event=0, first_error=0;
+ ExtensionEntry *ext=NULL ;
+
+ if (!ephyrProxyGetHostExtensionInfo (a_extension_name,
+ &major_opcode,
+ &first_event,
+ &first_error)) {
+ EPHYR_LOG ("failed to query extension %s from host\n", a_extension_name) ;
+ goto out;
+ }
+ ext = AddExtension ((char*)a_extension_name, 0, 0,
+ ephyrProxyProcDispatch,
+ ephyrProxyProcDispatch,
+ ephyrProxyProcReset,
+ StandardMinorOpcode) ;
+ if (!ext) {
+ EPHYR_LOG_ERROR ("failed to add the extension\n") ;
+ goto out ;
+ }
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrproxyext.h b/xorg-server/hw/kdrive/ephyr/ephyrproxyext.h
new file mode 100644
index 000000000..e52f8d887
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrproxyext.h
@@ -0,0 +1,34 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifndef __EPHYRPROXYEXT_H__
+#define __EPHYRPROXYEXT_H__
+
+Bool ephyrProxyExtensionInit (const char *a_extension_name) ;
+
+#endif /*__EPHYRPROXYEXT_H__*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
index 5058ebe03..bb2ee1032 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
@@ -371,10 +371,8 @@ ephyrXVPrivDelete (EphyrXVPriv *a_this)
ephyrHostXVAdaptorArrayDelete (a_this->host_adaptors) ;
a_this->host_adaptors = NULL ;
}
- if (a_this->adaptors) {
- xfree (a_this->adaptors) ;
- a_this->adaptors = NULL ;
- }
+ xfree (a_this->adaptors) ;
+ a_this->adaptors = NULL ;
xfree (a_this) ;
EPHYR_LOG ("leave\n") ;
}
@@ -675,14 +673,11 @@ ephyrXVPrivRegisterAdaptors (EphyrXVPriv *a_this,
is_ok = TRUE ;
out:
- if (registered_adaptors) {
- xfree (registered_adaptors) ;
- registered_adaptors = NULL ;
- }
- if (adaptors) {
- xfree (adaptors) ;
- adaptors=NULL ;
- }
+ xfree (registered_adaptors) ;
+ registered_adaptors = NULL ;
+ xfree (adaptors) ;
+ adaptors = NULL ;
+
EPHYR_LOG ("leave\n") ;
return is_ok ;
}
diff --git a/xorg-server/hw/kdrive/fake/fake.c b/xorg-server/hw/kdrive/fake/fake.c
index ff597981d..ea88f0edb 100644
--- a/xorg-server/hw/kdrive/fake/fake.c
+++ b/xorg-server/hw/kdrive/fake/fake.c
@@ -457,9 +457,8 @@ void
fakeCardFini (KdCardInfo *card)
{
FakePriv *priv = card->driver;
-
- if (priv->base)
- free (priv->base);
+
+ free (priv->base);
xfree (priv);
}
diff --git a/xorg-server/hw/kdrive/fake/fake.h b/xorg-server/hw/kdrive/fake/fake.h
index 88d209674..3c4a51bbc 100644
--- a/xorg-server/hw/kdrive/fake/fake.h
+++ b/xorg-server/hw/kdrive/fake/fake.h
@@ -38,7 +38,6 @@ typedef struct _fakePriv {
typedef struct _fakeScrPriv {
Rotation randr;
Bool shadow;
- PixmapPtr pShadow;
} FakeScrPriv;
extern KdCardFuncs fakeFuncs;
diff --git a/xorg-server/hw/kdrive/fbdev/Xfbdev.man b/xorg-server/hw/kdrive/fbdev/Xfbdev.man
new file mode 100644
index 000000000..bfdae168f
--- /dev/null
+++ b/xorg-server/hw/kdrive/fbdev/Xfbdev.man
@@ -0,0 +1,28 @@
+.\" $RCSId: xc/programs/Xserver/hw/kdrive/fbdev/Xfbdev.man,v 1.4 2001/01/27 18:20:40 dawes Exp $
+.\"
+.TH Xfbdev 1 __vendorversion__
+.SH NAME
+Xfbdev \- Linux framebuffer device tiny X server
+.SH SYNOPSIS
+.B Xfbdev
+.RI [ :display ]
+.RI [ option ...]
+.SH DESCRIPTION
+.B Xfbdev
+is a generic X server for Linux.
+.B Xfbdev
+doesn't know about any particular hardware, and uses the framebuffer
+provided by the Linux framebuffer device.
+.SH OPTIONS
+.B Xfbdev
+accepts the common options of the Xkdrive family of servers. Please
+see Xkdrive(1).
+.SH KEYBOARD
+To be written.
+.SH SEE ALSO
+X(__miscmansuffix__), Xserver(1), Xkdrive(1), xdm(1), xinit(1).
+.SH AUTHORS
+The
+.B Xfbdev
+server was written by Keith Packard.
+
diff --git a/xorg-server/hw/kdrive/fbdev/fbdev.h b/xorg-server/hw/kdrive/fbdev/fbdev.h
index 9e322dacb..3da8e4753 100644
--- a/xorg-server/hw/kdrive/fbdev/fbdev.h
+++ b/xorg-server/hw/kdrive/fbdev/fbdev.h
@@ -42,11 +42,10 @@ typedef struct _fbdevPriv {
char *fb;
char *fb_base;
} FbdevPriv;
-
+
typedef struct _fbdevScrPriv {
Rotation randr;
Bool shadow;
- PixmapPtr pShadow;
} FbdevScrPriv;
extern KdCardFuncs fbdevFuncs;
@@ -63,7 +62,7 @@ fbdevScreenInit (KdScreenInfo *screen);
Bool
fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv);
-
+
Bool
fbdevInitScreen (ScreenPtr pScreen);
@@ -122,7 +121,7 @@ fbdevSetShadow (ScreenPtr pScreen);
Bool
fbdevCreateColormap (ColormapPtr pmap);
-
+
#ifdef RANDR
Bool
fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
diff --git a/xorg-server/hw/kdrive/linux/bus.c b/xorg-server/hw/kdrive/linux/bus.c
index 93c3ea5f3..de9b90f5a 100644
--- a/xorg-server/hw/kdrive/linux/bus.c
+++ b/xorg-server/hw/kdrive/linux/bus.c
@@ -75,8 +75,7 @@ BusInit (KdPointerInfo *pi)
if ((fd = open (BusNames[i], 0)) >= 0)
{
close(fd);
- if (pi->path)
- xfree(pi->path);
+ xfree(pi->path);
pi->path = strdup(BusNames[i]);
return Success;
}
diff --git a/xorg-server/hw/kdrive/linux/keyboard.c b/xorg-server/hw/kdrive/linux/keyboard.c
index 79cf59898..6eed7aed3 100644
--- a/xorg-server/hw/kdrive/linux/keyboard.c
+++ b/xorg-server/hw/kdrive/linux/keyboard.c
@@ -231,7 +231,7 @@ readKernelMapping(KdKeyboardInfo *ki)
return;
fd = LinuxConsoleFd;
-
+
minKeyCode = NR_KEYS;
maxKeyCode = 0;
row = 0;
@@ -241,7 +241,7 @@ readKernelMapping(KdKeyboardInfo *ki)
kbe.kb_index = LNX_KEY_INDEX(i);
k = ki->keySyms.map + row * ki->keySyms.mapWidth;
-
+
for (j = 0; j < ki->keySyms.mapWidth; ++j)
{
unsigned short kval;
@@ -463,7 +463,7 @@ readKernelMapping(KdKeyboardInfo *ki)
k[j] = (kbe.kb_value & 0xFF) + 0x1008FF00;
break;
#endif
-
+
default:
break;
}
@@ -720,7 +720,7 @@ static void
LinuxKeyboardDisable (KdKeyboardInfo *ki)
{
int fd;
-
+
if (!ki)
return;
@@ -737,11 +737,9 @@ LinuxKeyboardInit (KdKeyboardInfo *ki)
if (!ki)
return !Success;
- if (ki->path)
- xfree(ki->path);
+ xfree(ki->path);
ki->path = strdup("console");
- if (ki->name)
- xfree(ki->name);
+ xfree(ki->name);
ki->name = strdup("Linux console keyboard");
readKernelMapping (ki);
diff --git a/xorg-server/hw/kdrive/linux/tslib.c b/xorg-server/hw/kdrive/linux/tslib.c
index 7cc23e637..322ccc7d5 100644
--- a/xorg-server/hw/kdrive/linux/tslib.c
+++ b/xorg-server/hw/kdrive/linux/tslib.c
@@ -9,7 +9,7 @@
* Copyright © 2002 MontaVista Software Inc.
* Copyright © 2005 OpenedHand Ltd.
* Copyright © 2006 Nokia Corporation
- *
+ *
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
@@ -76,7 +76,7 @@ TsRead (int fd, void *closure)
if (event.pressure) {
flags = KD_BUTTON_1;
- /*
+ /*
* Here we test for the touch screen driver actually being on the
* touch screen, if it is we send absolute coordinates. If not,
* then we send delta's so that we can track the entire vga screen.
@@ -127,7 +127,7 @@ TslibEnable (KdPointerInfo *pi)
}
KdRegisterFd(private->fd, TsRead, pi);
-
+
return Success;
}
@@ -155,7 +155,7 @@ TslibInit (KdPointerInfo *pi)
if (!pi || !pi->dixdev)
return !Success;
-
+
pi->driverPrivate = (struct TslibPrivate *)
xcalloc(sizeof(struct TslibPrivate), 1);
if (!pi->driverPrivate)
@@ -175,10 +175,8 @@ TslibInit (KdPointerInfo *pi)
static void
TslibFini (KdPointerInfo *pi)
{
- if (pi->driverPrivate) {
- xfree(pi->driverPrivate);
- pi->driverPrivate = NULL;
- }
+ xfree(pi->driverPrivate);
+ pi->driverPrivate = NULL;
}
diff --git a/xorg-server/hw/kdrive/src/kinfo.c b/xorg-server/hw/kdrive/src/kinfo.c
index 4551fd76b..95afc7963 100644
--- a/xorg-server/hw/kdrive/src/kinfo.c
+++ b/xorg-server/hw/kdrive/src/kinfo.c
@@ -138,40 +138,28 @@ KdFreePointer(KdPointerInfo *pi)
{
InputOption *option, *prev = NULL;
- if (pi->name)
- xfree(pi->name);
- if (pi->path)
- xfree(pi->path);
+ xfree(pi->name);
+ xfree(pi->path);
for (option = pi->options; option; option = option->next) {
- if (prev)
- xfree(prev);
- if (option->key)
- xfree(option->key);
- if (option->value)
- xfree(option->value);
+ xfree(prev);
+ xfree(option->key);
+ xfree(option->value);
prev = option;
}
- if (prev)
- xfree(prev);
-
+ xfree(prev);
xfree(pi);
}
-
+
void
KdFreeKeyboard(KdKeyboardInfo *ki)
{
- if (ki->name)
- xfree(ki->name);
- if (ki->path)
- xfree(ki->path);
- if (ki->xkbRules)
- xfree(ki->xkbRules);
- if (ki->xkbModel)
- xfree(ki->xkbModel);
- if (ki->xkbLayout)
- xfree(ki->xkbLayout);
+ xfree(ki->name);
+ xfree(ki->path);
+ xfree(ki->xkbRules);
+ xfree(ki->xkbModel);
+ xfree(ki->xkbLayout);
ki->next = NULL;
xfree(ki);
}
diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c
index 5222e9509..9ba90e63f 100644
--- a/xorg-server/hw/kdrive/src/kinput.c
+++ b/xorg-server/hw/kdrive/src/kinput.c
@@ -76,7 +76,7 @@ static KdPointerMatrix kdPointerMatrix = {
};
void KdResetInputMachine (void);
-
+
#define KD_MAX_INPUT_FDS 8
typedef struct _kdInputFd {
@@ -108,7 +108,7 @@ KdBlockSigio (void)
__asm int 3;
#else
sigset_t set;
-
+
sigemptyset (&set);
sigaddset (&set, SIGIO);
sigprocmask (SIG_BLOCK, &set, 0);
@@ -122,7 +122,7 @@ KdUnblockSigio (void)
__asm int 3;
#else
sigset_t set;
-
+
sigemptyset (&set);
sigaddset (&set, SIGIO);
sigprocmask (SIG_UNBLOCK, &set, 0);
@@ -190,7 +190,7 @@ KdAddFd (int fd)
#else
struct sigaction act;
sigset_t set;
-
+
kdnFds++;
fcntl (fd, F_SETOWN, getpid());
KdNonBlockFd (fd);
@@ -215,7 +215,7 @@ KdRemoveFd (int fd)
#else
struct sigaction act;
int flags;
-
+
kdnFds--;
RemoveEnabledDevice (fd);
flags = fcntl (fd, F_GETFL);
@@ -344,7 +344,7 @@ KdEnableInput (void)
InternalEvent ev;
KdKeyboardInfo *ki;
KdPointerInfo *pi;
-
+
kdInputEnabled = TRUE;
for (ki = kdKeyboards; ki; ki = ki->next) {
@@ -372,7 +372,7 @@ KdFindKeyboardDriver (char *name)
/* ask a stupid question ... */
if (!name)
return NULL;
-
+
for (ret = kdKeyboardDrivers; ret; ret = ret->next) {
if (strcmp(ret->name, name) == 0)
return ret;
@@ -507,11 +507,11 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
pi->name ? pi->name : "Generic KDrive Pointer");
return Success;
-
+
case DEVICE_ON:
if (pDev->on == TRUE)
return Success;
-
+
if (!pi->driver->Enable) {
ErrorF("no enable function\n");
return BadImplementation;
@@ -558,7 +558,7 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
(*pi->driver->Fini) (pi);
KdRemovePointer(pi);
-
+
return Success;
}
@@ -579,7 +579,7 @@ KdBell (int volume, DeviceIntPtr pDev, pointer arg, int something)
{
KeybdCtrl *ctrl = arg;
KdKeyboardInfo *ki = NULL;
-
+
for (ki = kdKeyboards; ki; ki = ki->next) {
if (ki->dixdev && ki->dixdev->id == pDev->id)
break;
@@ -587,7 +587,7 @@ KdBell (int volume, DeviceIntPtr pDev, pointer arg, int something)
if (!ki || !ki->dixdev || ki->dixdev->id != pDev->id || !ki->driver)
return;
-
+
KdRingBell(ki, volume, ctrl->bell_pitch, ctrl->bell_duration);
}
@@ -613,7 +613,7 @@ KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
{
if (!ki || !ki->driver || !ki->driver->Bell)
return;
-
+
if (kdInputEnabled)
(*ki->driver->Bell) (ki, volume, pitch, duration);
}
@@ -714,7 +714,7 @@ KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
KdSetLeds(ki, ctrl->leds);
ki->bellPitch = ctrl->bell_pitch;
- ki->bellDuration = ctrl->bell_duration;
+ ki->bellDuration = ctrl->bell_duration;
}
extern KeybdCtrl defaultKeyboardControl;
@@ -817,7 +817,7 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
pDev->on = FALSE;
return Success;
-
+
break;
case DEVICE_CLOSE:
@@ -958,7 +958,7 @@ KdAddKeyboard (KdKeyboardInfo *ki)
if (!ki)
return !Success;
-
+
ki->dixdev = AddInputDevice(serverClient, KdKeyboardProc, TRUE);
if (!ki->dixdev) {
ErrorF("Couldn't register keyboard device %s\n",
@@ -1065,12 +1065,12 @@ KdRemovePointer (KdPointerInfo *pi)
KdFreePointer(pi);
}
-/*
+/*
* You can call your kdriver server with something like:
* $ ./hw/kdrive/yourserver/X :1 -mouse evdev,,device=/dev/input/event4 -keybd
- * evdev,,device=/dev/input/event1,xkbmodel=abnt2,xkblayout=br
+ * evdev,,device=/dev/input/event1,xkbmodel=abnt2,xkblayout=br
*/
-static Bool
+static Bool
KdGetOptions (InputOption **options, char *string)
{
InputOption *newopt = NULL, **tmpo = NULL;
@@ -1081,7 +1081,7 @@ KdGetOptions (InputOption **options, char *string)
return FALSE;
for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next)
- ; /* Hello, I'm here */
+ ; /* Hello, I'm here */
*tmpo = newopt;
if (strchr(string, '='))
@@ -1122,7 +1122,7 @@ KdParseKbdOptions (KdKeyboardInfo *ki)
else if (!strcasecmp (option->key, "device"))
ki->path = strdup(option->value);
else
- ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
+ ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
option->key, option->value);
}
}
@@ -1183,11 +1183,11 @@ KdParseKeyboard (char *arg)
{
arg = KdParseFindNext (arg, ",", save, &delim);
- if (!KdGetOptions(&options, save))
+ if (!KdGetOptions(&options, save))
{
KdFreeKeyboard(ki);
return NULL;
- }
+ }
}
if (options)
@@ -1219,7 +1219,7 @@ KdParsePointerOptions (KdPointerInfo *pi)
else if (!strcasecmp (option->key, "protocol"))
pi->protocol = strdup(option->value);
else
- ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
+ ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
option->key, option->value);
}
}
@@ -1471,7 +1471,7 @@ KdInitInput (void)
* <> -> (deliver) synthetic_2_down_1
* k -> (deliver) synthetic_2_down_1
*/
-
+
typedef enum _inputClass {
down_1, up_1,
down_2, up_2,
@@ -1651,7 +1651,7 @@ KdInsideEmulationWindow (KdPointerInfo *pi, int x, int y, int z)
return (abs (pi->emulationDx) < EMULATION_WINDOW &&
abs (pi->emulationDy) < EMULATION_WINDOW);
}
-
+
static KdInputClass
KdClassifyInput (KdPointerInfo *pi, int type, int x, int y, int z, int b)
{
@@ -1929,7 +1929,7 @@ KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
if (!pi)
return;
-
+
ms = GetTimeInMillis();
/* we don't need to transform z, so we don't. */
@@ -2024,7 +2024,7 @@ KdBlockHandler (int screen,
if (pi->timeoutPending)
{
int ms;
-
+
ms = pi->emulationTimeout - GetTimeInMillis ();
if (ms < 1)
ms = 1;
@@ -2043,7 +2043,7 @@ KdBlockHandler (int screen,
}
void
-KdWakeupHandler (int screen,
+KdWakeupHandler (int screen,
pointer data,
unsigned long lresult,
pointer readmask)
@@ -2052,7 +2052,7 @@ KdWakeupHandler (int screen,
fd_set *pReadmask = (fd_set *) readmask;
int i;
KdPointerInfo *pi;
-
+
if (kdInputEnabled && result > 0)
{
for (i = 0; i < kdNumInputFds; i++)
@@ -2092,13 +2092,13 @@ KdCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
int best_x, best_y;
int n_best_x, n_best_y;
CARD32 ms;
-
+
if (kdDisableZaphod || screenInfo.numScreens <= 1)
return FALSE;
if (0 <= *x && *x < pScreen->width && 0 <= *y && *y < pScreen->height)
return FALSE;
-
+
ms = GetTimeInMillis ();
if (kdOffScreen && (int) (ms - kdOffScreenTime) < 1000)
return FALSE;
@@ -2111,7 +2111,7 @@ KdCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
for (n = 0; n < screenInfo.numScreens; n++)
{
pNewScreen = screenInfo.screens[n];
- if (pNewScreen == pScreen)
+ if (pNewScreen == pScreen)
continue;
dx = KdScreenOrigin(pNewScreen)->x - KdScreenOrigin(pScreen)->x;
dy = KdScreenOrigin(pNewScreen)->y - KdScreenOrigin(pScreen)->y;
@@ -2153,17 +2153,17 @@ KdCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
if (n_best_x == -1)
return FALSE;
pNewScreen = screenInfo.screens[n_best_x];
-
+
if (*x < 0)
*x += pNewScreen->width;
if (*y < 0)
*y += pNewScreen->height;
-
+
if (*x >= pScreen->width)
*x -= pScreen->width;
if (*y >= pScreen->height)
*y -= pScreen->height;
-
+
*ppScreen = pNewScreen;
return TRUE;
}
@@ -2190,7 +2190,7 @@ KdWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
KdUnblockSigio ();
}
-miPointerScreenFuncRec kdPointerScreenFuncs =
+miPointerScreenFuncRec kdPointerScreenFuncs =
{
KdCursorOffScreen,
KdCrossScreen,
@@ -2274,7 +2274,8 @@ ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
}
int
-NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
+NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
+ DeviceIntPtr *pdev)
{
InputOption *option = NULL;
KdPointerInfo *pi = NULL;
@@ -2305,6 +2306,14 @@ NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
return BadValue;
}
#endif
+#ifdef CONFIG_UDEV
+ else if (strcmp(option->key, "_source") == 0 &&
+ strcmp(option->value, "server/udev") == 0)
+ {
+ ErrorF("Ignoring device from udev.\n");
+ return BadValue;
+ }
+#endif
}
if (!ki && !pi) {
diff --git a/xorg-server/hw/kdrive/src/kxv.c b/xorg-server/hw/kdrive/src/kxv.c
index 9a74654af..27ecc5d6c 100644
--- a/xorg-server/hw/kdrive/src/kxv.c
+++ b/xorg-server/hw/kdrive/src/kxv.c
@@ -1,6 +1,6 @@
-/*
+/*
- XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
+ XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
Adapted for KDrive by Pontus Lidman <pontus.lidman@nokia.com>
Copyright (C) 2000, 2001 - Nokia Home Communications
@@ -67,29 +67,29 @@ static int KdXVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
static int KdXVAllocatePort(unsigned long, XvPortPtr, XvPortPtr*);
static int KdXVFreePort(XvPortPtr);
static int KdXVPutVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
static int KdXVPutStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
static int KdXVGetVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
static int KdXVGetStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16);
static int KdXVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
static int KdXVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
static int KdXVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *);
static int KdXVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
- CARD16, CARD16,CARD16, CARD16,
+ CARD16, CARD16,CARD16, CARD16,
unsigned int*, unsigned int*);
static int KdXVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
INT16, INT16, CARD16, CARD16,
XvImagePtr, unsigned char*, Bool,
CARD16, CARD16);
-static int KdXVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
+static int KdXVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
CARD16*, CARD16*, int*, int*);
@@ -134,12 +134,12 @@ KdXVRegisterGenericAdaptorDriver(
/* fprintf(stderr,"KdXVRegisterGenericAdaptorDriver\n"); */
- newdrivers = xrealloc(GenDrivers, sizeof(KdXVInitGenericAdaptorPtr) *
+ newdrivers = xrealloc(GenDrivers, sizeof(KdXVInitGenericAdaptorPtr) *
(1 + NumGenDrivers));
if (!newdrivers)
return 0;
GenDrivers = newdrivers;
-
+
GenDrivers[NumGenDrivers++] = InitFunc;
return 1;
@@ -184,7 +184,7 @@ KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr)
Bool
KdXVScreenInit(
- ScreenPtr pScreen,
+ ScreenPtr pScreen,
KdVideoAdaptorPtr *adaptors,
int num
){
@@ -197,7 +197,7 @@ KdXVScreenInit(
KdXVGeneration = serverGeneration;
if(!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
- return FALSE;
+ return FALSE;
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
@@ -247,20 +247,18 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
{
int i;
- if(pAdaptor->name)
- xfree(pAdaptor->name);
+ xfree(pAdaptor->name);
if(pAdaptor->pEncodings) {
XvEncodingPtr pEncode = pAdaptor->pEncodings;
for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++) {
- if(pEncode->name) xfree(pEncode->name);
+ xfree(pEncode->name);
}
xfree(pAdaptor->pEncodings);
}
- if(pAdaptor->pFormats)
- xfree(pAdaptor->pFormats);
+ xfree(pAdaptor->pFormats);
if(pAdaptor->pPorts) {
XvPortPtr pPort = pAdaptor->pPorts;
@@ -269,9 +267,9 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
for(i = 0; i < pAdaptor->nPorts; i++, pPort++) {
pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
if(pPriv) {
- if(pPriv->clientClip)
+ if(pPriv->clientClip)
REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip);
- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip);
xfree(pPriv);
}
@@ -283,22 +281,20 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
XvAttributePtr pAttribute = pAdaptor->pAttributes;
for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) {
- if(pAttribute->name) xfree(pAttribute->name);
+ xfree(pAttribute->name);
}
xfree(pAdaptor->pAttributes);
}
- if(pAdaptor->nImages)
- xfree(pAdaptor->pImages);
-
- if(pAdaptor->devPriv.ptr)
- xfree(pAdaptor->devPriv.ptr);
+ xfree(pAdaptor->pImages);
+
+ xfree(pAdaptor->devPriv.ptr);
}
static Bool
KdXVInitAdaptors(
- ScreenPtr pScreen,
+ ScreenPtr pScreen,
KdVideoAdaptorPtr *infoPtr,
int number
) {
@@ -329,7 +325,7 @@ KdXVInitAdaptors(
pxvs->nAdaptors = 0;
pxvs->pAdaptors = NULL;
- if(!(pAdaptor = xcalloc(number, sizeof(XvAdaptorRec))))
+ if(!(pAdaptor = xcalloc(number, sizeof(XvAdaptorRec))))
return FALSE;
for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
@@ -343,7 +339,7 @@ KdXVInitAdaptors(
if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
continue;
- pa->type = adaptorPtr->type;
+ pa->type = adaptorPtr->type;
if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
pa->type &= ~XvVideoMask;
@@ -354,19 +350,19 @@ KdXVInitAdaptors(
if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
pa->type &= ~XvImageMask;
- if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
+ if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
!adaptorPtr->PutStill)
pa->type &= ~XvInputMask;
if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
pa->type &= ~XvOutputMask;
-
- if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
+
+ if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
continue;
- if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
+ if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
continue;
- pa->pScreen = pScreen;
+ pa->pScreen = pScreen;
pa->ddAllocatePort = KdXVAllocatePort;
pa->ddFreePort = KdXVFreePort;
pa->ddPutVideo = KdXVPutVideo;
@@ -385,8 +381,8 @@ KdXVInitAdaptors(
if(adaptorPtr->nEncodings &&
(pEncode = xcalloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
- for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
- i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++)
+ for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
+ i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++)
{
pe->id = encodingPtr->id;
pe->pScreen = pScreen;
@@ -398,14 +394,14 @@ KdXVInitAdaptors(
pe->rate.denominator = encodingPtr->rate.denominator;
}
pa->nEncodings = adaptorPtr->nEncodings;
- pa->pEncodings = pEncode;
- }
+ pa->pEncodings = pEncode;
+ }
if(adaptorPtr->nImages &&
(pImage = xcalloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
- i < adaptorPtr->nImages; i++, pi++, imagePtr++)
+ i < adaptorPtr->nImages; i++, pi++, imagePtr++)
{
pi->id = imagePtr->id;
pi->type = imagePtr->type;
@@ -437,8 +433,8 @@ KdXVInitAdaptors(
if(adaptorPtr->nAttributes &&
(pAttribute = xcalloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec))))
{
- for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0;
- i < adaptorPtr->nAttributes; pat++, i++, attributePtr++)
+ for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0;
+ i < adaptorPtr->nAttributes; pat++, i++, attributePtr++)
{
pat->flags = attributePtr->flags;
pat->min_value = attributePtr->min_value;
@@ -447,8 +443,8 @@ KdXVInitAdaptors(
strcpy(pat->name, attributePtr->name);
}
pa->nAttributes = adaptorPtr->nAttributes;
- pa->pAttributes = pAttribute;
- }
+ pa->pAttributes = pAttribute;
+ }
totFormat = adaptorPtr->nFormats;
@@ -457,8 +453,8 @@ KdXVInitAdaptors(
KdXVFreeAdaptor(pa);
continue;
}
- for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats;
- i < adaptorPtr->nFormats; i++, formatPtr++)
+ for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats;
+ i < adaptorPtr->nFormats; i++, formatPtr++)
{
numVisuals = pScreen->numVisuals;
pVisual = pScreen->visuals;
@@ -468,26 +464,26 @@ KdXVInitAdaptors(
(pVisual->nplanes == formatPtr->depth)) {
if(numFormat >= totFormat) {
- void *moreSpace;
+ void *moreSpace;
totFormat *= 2;
- moreSpace = xrealloc(pFormat,
+ moreSpace = xrealloc(pFormat,
totFormat * sizeof(XvFormatRec));
if(!moreSpace) break;
pFormat = moreSpace;
pf = pFormat + numFormat;
}
- pf->visual = pVisual->vid;
+ pf->visual = pVisual->vid;
pf->depth = formatPtr->depth;
pf++;
numFormat++;
}
pVisual++;
- }
+ }
}
pa->nFormats = numFormat;
- pa->pFormats = pFormat;
+ pa->pFormats = pFormat;
if(!numFormat) {
KdXVFreeAdaptor(pa);
continue;
@@ -517,15 +513,15 @@ KdXVInitAdaptors(
KdXVFreeAdaptor(pa);
continue;
}
- for(pp = pPort, i = 0, numPort = 0;
+ for(pp = pPort, i = 0, numPort = 0;
i < adaptorPtr->nPorts; i++) {
- if(!(pp->id = FakeClientID(0)))
+ if(!(pp->id = FakeClientID(0)))
continue;
- if(!(portPriv = xcalloc(1, sizeof(XvPortRecPrivate))))
+ if(!(portPriv = xcalloc(1, sizeof(XvPortRecPrivate))))
continue;
-
+
if(!AddResource(pp->id, PortResource, pp)) {
xfree(portPriv);
continue;
@@ -542,7 +538,7 @@ KdXVInitAdaptors(
portPriv->screen = screen;
portPriv->AdaptorRec = adaptorPriv;
portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
-
+
pp++;
numPort++;
}
@@ -554,7 +550,7 @@ KdXVInitAdaptors(
}
pa->base_id = pPort->id;
-
+
pa++;
numAdaptor++;
}
@@ -580,13 +576,13 @@ KdXVInitAdaptors(
the GC and used it's clip list when they needed to reclip the window,
even if the client clip was different from the one the video was
initialized with. If the original GC was destroyed, they had to stop
- the video. I like the new method better (MArk).
+ the video. I like the new method better (MArk).
This function only works for windows. Will need to rewrite when
(if) we support pixmap rendering.
*/
-static void
+static void
KdXVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
{
RegionPtr pregWin, pCompositeClip;
@@ -623,7 +619,7 @@ KdXVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
if(freeCompClip) {
REGION_DESTROY(pWin->pScreen, pregWin);
- }
+ }
}
/* Save the current clientClip and update the CompositeClip whenever
@@ -631,7 +627,7 @@ KdXVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
static void
KdXVCopyClip(
- XvPortRecPrivatePtr portPriv,
+ XvPortRecPrivatePtr portPriv,
GCPtr pGC
){
/* copy the new clip if it exists */
@@ -672,12 +668,12 @@ KdXVRegetVideo(XvPortRecPrivatePtr portPriv)
WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
WinBox.x2 = WinBox.x1 + portPriv->drw_w;
WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
+
/* clip to the window composite clip */
REGION_INIT(portPriv->pDraw->pScreen, &WinRegion, &WinBox, 1);
REGION_INIT(portPriv->pDraw->pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
+ REGION_INTERSECT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
/* that's all if it's totally obscured */
if(!REGION_NOTEMPTY(portPriv->pDraw->pScreen, &ClipRegion)) {
clippedAway = TRUE;
@@ -689,10 +685,10 @@ KdXVRegetVideo(XvPortRecPrivatePtr portPriv)
}
ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->screen, portPriv->pDraw,
- portPriv->vid_x, portPriv->vid_y,
- WinBox.x1, WinBox.y1,
- portPriv->vid_w, portPriv->vid_h,
- portPriv->drw_w, portPriv->drw_h,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
&ClipRegion, portPriv->DevPriv.ptr);
if(ret == Success)
@@ -736,11 +732,11 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv)
WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
WinBox.x2 = WinBox.x1 + portPriv->drw_w;
WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
+
/* clip to the window composite clip */
REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* clip and translate to the viewport */
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -753,10 +749,10 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv)
VPBox.y2 = screen->height;
REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
REGION_UNINIT(pScreen, &VPReg);
}
-
+
/* that's all if it's totally obscured */
if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
clippedAway = TRUE;
@@ -767,8 +763,8 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv)
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
BoxPtr clipBox = REGION_RECTS(&ClipRegion);
if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
@@ -780,10 +776,10 @@ KdXVReputVideo(XvPortRecPrivatePtr portPriv)
}
ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->screen, portPriv->pDraw,
- portPriv->vid_x, portPriv->vid_y,
+ portPriv->vid_x, portPriv->vid_y,
WinBox.x1, WinBox.y1,
- portPriv->vid_w, portPriv->vid_h,
- portPriv->drw_w, portPriv->drw_h,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
&ClipRegion, portPriv->DevPriv.ptr);
if(ret == Success) portPriv->isOn = XV_ON;
@@ -825,11 +821,11 @@ KdXVReputImage(XvPortRecPrivatePtr portPriv)
WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
WinBox.x2 = WinBox.x1 + portPriv->drw_w;
WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
+
/* clip to the window composite clip */
REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* clip and translate to the viewport */
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -842,10 +838,10 @@ KdXVReputImage(XvPortRecPrivatePtr portPriv)
VPBox.y2 = screen->height;
REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
REGION_UNINIT(pScreen, &VPReg);
}
-
+
/* that's all if it's totally obscured */
if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
clippedAway = TRUE;
@@ -856,8 +852,8 @@ KdXVReputImage(XvPortRecPrivatePtr portPriv)
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
BoxPtr clipBox = REGION_RECTS(&ClipRegion);
if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
@@ -897,10 +893,10 @@ static int
KdXVReputAllVideo(WindowPtr pWin, pointer data)
{
KdXVWindowPtr WinPriv;
-
+
if (pWin->drawable.type != DRAWABLE_WINDOW)
return WT_DONTWALKCHILDREN;
-
+
WinPriv = GET_KDXV_WINDOW(pWin);
while(WinPriv) {
@@ -917,7 +913,7 @@ KdXVReputAllVideo(WindowPtr pWin, pointer data)
static int
KdXVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
{
- KdXVWindowPtr winPriv, PrivRoot;
+ KdXVWindowPtr winPriv, PrivRoot;
winPriv = PrivRoot = GET_KDXV_WINDOW(pWin);
@@ -934,7 +930,7 @@ KdXVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
winPriv->PortRec = portPriv;
winPriv->next = PrivRoot;
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv);
- }
+ }
return Success;
}
@@ -948,14 +944,14 @@ KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
while(winPriv) {
if(winPriv->PortRec == portPriv) {
- if(prevPriv)
+ if(prevPriv)
prevPriv->next = winPriv->next;
- else
+ else
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv->next);
xfree(winPriv);
break;
}
- prevPriv = winPriv;
+ prevPriv = winPriv;
winPriv = winPriv->next;
}
portPriv->pDraw = NULL;
@@ -1033,7 +1029,7 @@ KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
/* filter out XClearWindow/Area */
if (!pWin->valdata) return;
-
+
pPrev = NULL;
while(WinPriv) {
@@ -1044,10 +1040,10 @@ KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
switch(pPriv->type) {
case XvInputMask:
KdXVReputVideo(pPriv);
- break;
+ break;
case XvOutputMask:
- KdXVRegetVideo(pPriv);
- break;
+ KdXVRegetVideo(pPriv);
+ break;
default: /* overlaid still/image*/
if (pPriv->AdaptorRec->ReputImage)
KdXVReputImage(pPriv);
@@ -1061,7 +1057,7 @@ KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
}
pPriv->pDraw = NULL;
- if(!pPrev)
+ if(!pPrev)
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, WinPriv->next);
else
pPrev->next = WinPriv->next;
@@ -1078,7 +1074,7 @@ KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
}
-static void
+static void
KdXVClipNotify(WindowPtr pWin, int dx, int dy)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
@@ -1097,7 +1093,7 @@ KdXVClipNotify(WindowPtr pWin, int dx, int dy)
pPriv->pCompositeClip = NULL;
- /* Stop everything except images, but stop them too if the
+ /* Stop everything except images, but stop them too if the
window isn't visible. But we only remove the images. */
if(pPriv->type || !visible) {
@@ -1110,7 +1106,7 @@ KdXVClipNotify(WindowPtr pWin, int dx, int dy)
if(!pPriv->type) { /* overlaid still/image */
pPriv->pDraw = NULL;
- if(!pPrev)
+ if(!pPrev)
dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, WinPriv->next);
else
pPrev->next = WinPriv->next;
@@ -1153,16 +1149,13 @@ KdXVCloseScreen(int i, ScreenPtr pScreen)
/* fprintf(stderr,"XV: Unwrapping screen funcs\n"); */
- for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
+ for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
KdXVFreeAdaptor(pa);
}
- if(pxvs->pAdaptors)
- xfree(pxvs->pAdaptors);
-
+ xfree(pxvs->pAdaptors);
xfree(ScreenPriv);
-
return TRUE;
}
@@ -1193,9 +1186,9 @@ KdXVEnable(ScreenPtr pScreen)
{
if (!KdXVRunning (pScreen))
return TRUE;
-
- WalkTree(pScreen, KdXVReputAllVideo, 0);
-
+
+ WalkTree(pScreen, KdXVReputAllVideo, 0);
+
return TRUE;
}
@@ -1214,7 +1207,7 @@ KdXVDisable(ScreenPtr pScreen)
pxvs = GET_XV_SCREEN(pScreen);
ScreenPriv = GET_KDXV_SCREEN(pScreen);
-
+
for(i = 0; i < pxvs->nAdaptors; i++) {
pAdaptor = &pxvs->pAdaptors[i];
for(j = 0; j < pAdaptor->nPorts; j++) {
@@ -1263,8 +1256,8 @@ KdXVPutVideo(
DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y,
CARD16 drw_w, CARD16 drw_h
){
@@ -1277,7 +1270,7 @@ KdXVPutVideo(
pPort->pDraw = (DrawablePtr)NULL;
return BadAlloc;
}
-
+
/* If we are changing windows, unregister our port in the old window */
if(portPriv->pDraw && (portPriv->pDraw != pDraw))
KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
@@ -1302,7 +1295,7 @@ KdXVPutVideo(
pPort->pDraw = pDraw;
if (!pScreenPriv->enabled) return Success;
-
+
return(KdXVReputVideo(portPriv));
}
@@ -1312,13 +1305,13 @@ KdXVPutStill(
DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y,
CARD16 drw_w, CARD16 drw_h
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- ScreenPtr pScreen = pDraw->pScreen;
+ ScreenPtr pScreen = pDraw->pScreen;
KdScreenPriv(pScreen);
KdScreenInfo *screen=pScreenPriv->screen;
RegionRec WinRegion;
@@ -1336,10 +1329,10 @@ KdXVPutStill(
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
-
+
REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
@@ -1351,7 +1344,7 @@ KdXVPutStill(
VPBox.y2 = screen->height;
REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
REGION_UNINIT(pScreen, &VPReg);
}
@@ -1367,7 +1360,7 @@ KdXVPutStill(
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
BoxPtr clipBox = REGION_RECTS(&ClipRegion);
if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
clippedAway = TRUE;
@@ -1417,8 +1410,8 @@ KdXVGetVideo(
DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y,
CARD16 drw_w, CARD16 drw_h
){
@@ -1431,7 +1424,7 @@ KdXVGetVideo(
pPort->pDraw = (DrawablePtr)NULL;
return BadAlloc;
}
-
+
/* If we are changing windows, unregister our port in the old window */
if(portPriv->pDraw && (portPriv->pDraw != pDraw))
KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
@@ -1454,7 +1447,7 @@ KdXVGetVideo(
/* To indicate to the DI layer that we were successful */
pPort->pDraw = pDraw;
-
+
if(!pScreenPriv->enabled) return Success;
return(KdXVRegetVideo(portPriv));
@@ -1466,8 +1459,8 @@ KdXVGetStill(
DrawablePtr pDraw,
XvPortPtr pPort,
GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y,
CARD16 drw_w, CARD16 drw_h
){
@@ -1489,10 +1482,10 @@ KdXVGetStill(
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
-
+
REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->pDraw) {
KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
@@ -1526,7 +1519,7 @@ GET_STILL_BAILOUT:
return ret;
}
-
+
static int
KdXVStopVideo(
@@ -1539,7 +1532,7 @@ KdXVStopVideo(
if(pDraw->type != DRAWABLE_WINDOW)
return BadAlloc;
-
+
KdXVRemovePortFromWindow((WindowPtr)pDraw, portPriv);
if(!pScreenPriv->enabled) return Success;
@@ -1563,8 +1556,8 @@ KdXVSetPortAttribute(
INT32 value
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->screen,
+
+ return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->screen,
attribute, value, portPriv->DevPriv.ptr));
}
@@ -1577,8 +1570,8 @@ KdXVGetPortAttribute(
INT32 *p_value
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->screen,
+
+ return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->screen,
attribute, (int *) p_value, portPriv->DevPriv.ptr));
}
@@ -1594,8 +1587,8 @@ KdXVQueryBestSize(
unsigned int *p_w, unsigned int *p_h
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- (*portPriv->AdaptorRec->QueryBestSize)(portPriv->screen,
+
+ (*portPriv->AdaptorRec->QueryBestSize)(portPriv->screen,
(Bool)motion, vid_w, vid_h, drw_w, drw_h,
p_w, p_h, portPriv->DevPriv.ptr);
@@ -1603,14 +1596,14 @@ KdXVQueryBestSize(
}
-static int
+static int
KdXVPutImage(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
GCPtr pGC,
- INT16 src_x, INT16 src_y,
- CARD16 src_w, CARD16 src_h,
+ INT16 src_x, INT16 src_y,
+ CARD16 src_w, CARD16 src_h,
INT16 drw_x, INT16 drw_y,
CARD16 drw_w, CARD16 drw_h,
XvImagePtr format,
@@ -1636,10 +1629,10 @@ KdXVPutImage(
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
-
+
REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
@@ -1651,7 +1644,7 @@ KdXVPutImage(
VPBox.y2 = pScreen->height;
REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
REGION_UNINIT(pScreen, &VPReg);
}
@@ -1667,7 +1660,7 @@ KdXVPutImage(
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
BoxPtr clipBox = REGION_RECTS(&ClipRegion);
if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
clippedAway = TRUE;
@@ -1712,19 +1705,19 @@ PUT_IMAGE_BAILOUT:
}
-static int
+static int
KdXVQueryImageAttributes(
- ClientPtr client,
+ ClientPtr client,
XvPortPtr pPort,
- XvImagePtr format,
- CARD16 *width,
- CARD16 *height,
+ XvImagePtr format,
+ CARD16 *width,
+ CARD16 *height,
int *pitches,
int *offsets
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->screen,
+ return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->screen,
format->id, width, height, pitches, offsets);
}
@@ -1878,7 +1871,7 @@ KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
xRectangle *rects, *r;
BoxPtr pBox = REGION_RECTS (pRgn);
int nBox = REGION_NUM_RECTS (pRgn);
-
+
rects = xalloc (nBox * sizeof (xRectangle));
if (!rects)
goto bail0;
@@ -1892,18 +1885,18 @@ KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
r++;
pBox++;
}
-
+
pGC = GetScratchGC (pDraw->depth, pDraw->pScreen);
if (!pGC)
goto bail1;
-
+
val[0] = fg;
val[1] = IncludeInferiors;
ChangeGC (pGC, GCForeground|GCSubwindowMode, val);
-
+
ValidateGC (pDraw, pGC);
-
- (*pGC->ops->PolyFillRect) (pDraw, pGC,
+
+ (*pGC->ops->PolyFillRect) (pDraw, pGC,
REGION_NUM_RECTS (pRgn), rects);
FreeScratchGC (pGC);
diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
index a6199b0e8..1c4595e36 100644
--- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c
+++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
@@ -272,7 +272,8 @@ xf86AutoConfig(void)
for (cp = builtinConfig; *cp; cp++)
xf86ErrorFVerb(3, "\t%s", *cp);
xf86MsgVerb(X_DEFAULT, 3, "--- End of built-in configuration ---\n");
-
+
+ xf86initConfigFiles();
xf86setBuiltinConfig(builtinConfig);
ret = xf86HandleConfigFile(TRUE);
FreeConfig();
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index 6fbf61346..1abc182da 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -95,6 +95,23 @@ extern DeviceAssocRec mouse_assoc;
"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
"%P/lib/X11/%X"
#endif
+#ifndef ROOT_CONFIGDIRPATH
+#define ROOT_CONFIGDIRPATH "%A," "%R," \
+ "/etc/X11/%R," "%P/etc/X11/%R," \
+ "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+#ifndef USER_CONFIGDIRPATH
+#define USER_CONFIGDIRPATH "/etc/X11/%S," "%P/etc/X11/%S," \
+ "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
#ifndef PROJECTROOT
#define PROJECTROOT "/usr/X11R6"
#endif
@@ -1444,12 +1461,19 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
if (xf86Info.allowEmptyInput && !(foundPointer && foundKeyboard)) {
-#ifdef CONFIG_HAL
- xf86Msg(X_INFO, "The server relies on HAL to provide the list of "
+#if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
+ const char *config_backend;
+#if defined(CONFIG_HAL)
+ config_backend = "HAL";
+#else
+ config_backend = "udev";
+#endif
+ xf86Msg(X_INFO, "The server relies on %s to provide the list of "
"input devices.\n\tIf no devices become available, "
- "reconfigure HAL or disable AutoAddDevices.\n");
+ "reconfigure %s or disable AutoAddDevices.\n",
+ config_backend, config_backend);
#else
- xf86Msg(X_INFO, "HAL is disabled and no input devices were configured.\n"
+ xf86Msg(X_INFO, "Hotplugging is disabled and no input devices were configured.\n"
"\tTry disabling AllowEmptyInput.\n");
#endif
}
@@ -1471,6 +1495,45 @@ static OptionInfoRec LayoutOptions[] = {
{0}, FALSE },
};
+static Bool
+configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
+{
+ XF86ConfInputrefPtr irp;
+ IDevPtr *indp;
+ int count = 0;
+
+ /*
+ * Count the number of input devices.
+ */
+ irp = layout->lay_input_lst;
+ while (irp) {
+ count++;
+ irp = (XF86ConfInputrefPtr)irp->list.next;
+ }
+ DebugF("Found %d input devices in the layout section %s\n",
+ count, layout.lay_identifier);
+ indp = xnfcalloc((count + 1), sizeof(IDevPtr));
+ indp[count] = NULL;
+ irp = layout->lay_input_lst;
+ count = 0;
+ while (irp) {
+ indp[count] = xnfalloc(sizeof(IDevRec));
+ if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
+ while(count--)
+ xfree(indp[count]);
+ xfree(indp);
+ return FALSE;
+ }
+ indp[count]->extraOptions = irp->iref_option_lst;
+ count++;
+ irp = (XF86ConfInputrefPtr)irp->list.next;
+ }
+ servlayoutp->inputs = indp;
+
+ return TRUE;
+}
+
+
/*
* figure out which layout is active, which screens are used in that layout,
* which drivers and monitors are used in these screens
@@ -1481,14 +1544,12 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
{
XF86ConfAdjacencyPtr adjp;
XF86ConfInactivePtr idp;
- XF86ConfInputrefPtr irp;
int count = 0;
int scrnum;
XF86ConfLayoutPtr l;
MessageType from;
screenLayoutPtr slp;
GDevPtr gdp;
- IDevPtr* indp;
int i = 0, j;
if (!servlayoutp)
@@ -1639,45 +1700,6 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
}
}
-#ifdef LAYOUT_DEBUG
- ErrorF("Layout \"%s\"\n", conf_layout->lay_identifier);
- for (i = 0; i < count; i++) {
- ErrorF("Screen: \"%s\" (%d):\n", slp[i].screen->id,
- slp[i].screen->screennum);
- switch (slp[i].where) {
- case PosObsolete:
- ErrorF("\tObsolete format: \"%s\" \"%s\" \"%s\" \"%s\"\n",
- slp[i].top, slp[i].bottom, slp[i].left, slp[i].right);
- break;
- case PosAbsolute:
- if (slp[i].x == -1)
- if (slp[i].screen->screennum == 0)
- ErrorF("\tImplicitly left-most\n");
- else
- ErrorF("\tImplicitly right of screen %d\n",
- slp[i].screen->screennum - 1);
- else
- ErrorF("\t%d %d\n", slp[i].x, slp[i].y);
- break;
- case PosRightOf:
- ErrorF("\tRight of \"%s\"\n", slp[i].refscreen->id);
- break;
- case PosLeftOf:
- ErrorF("\tLeft of \"%s\"\n", slp[i].refscreen->id);
- break;
- case PosAbove:
- ErrorF("\tAbove \"%s\"\n", slp[i].refscreen->id);
- break;
- case PosBelow:
- ErrorF("\tBelow \"%s\"\n", slp[i].refscreen->id);
- break;
- case PosRelative:
- ErrorF("\t%d %d relative to \"%s\"\n", slp[i].x, slp[i].y,
- slp[i].refscreen->id);
- break;
- }
- }
-#endif
/*
* Count the number of inactive devices.
*/
@@ -1701,37 +1723,13 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
count++;
idp = (XF86ConfInactivePtr)idp->list.next;
}
- /*
- * Count the number of input devices.
- */
- count = 0;
- irp = conf_layout->lay_input_lst;
- while (irp) {
- count++;
- irp = (XF86ConfInputrefPtr)irp->list.next;
- }
- DebugF("Found %d input devices in the layout section %s\n",
- count, conf_layout->lay_identifier);
- indp = xnfcalloc((count + 1), sizeof(IDevPtr));
- indp[count] = NULL;
- irp = conf_layout->lay_input_lst;
- count = 0;
- while (irp) {
- indp[count] = xnfalloc(sizeof(IDevRec));
- if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
- while(count--)
- xfree(indp[count]);
- xfree(indp);
- return FALSE;
- }
- indp[count]->extraOptions = irp->iref_option_lst;
- count++;
- irp = (XF86ConfInputrefPtr)irp->list.next;
- }
+
+ if (!configInputDevices(conf_layout, servlayoutp))
+ return FALSE;
+
servlayoutp->id = conf_layout->lay_identifier;
servlayoutp->screens = slp;
servlayoutp->inactives = gdp;
- servlayoutp->inputs = indp;
servlayoutp->options = conf_layout->lay_option_lst;
from = X_DEFAULT;
@@ -1743,12 +1741,14 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
* the only active screen.
*/
static Bool
-configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
+configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
+ XF86ConfigPtr xf86configptr)
{
MessageType from;
XF86ConfScreenPtr s;
screenLayoutPtr slp;
IDevPtr *indp;
+ XF86ConfLayoutRec layout;
if (!servlayoutp)
return FALSE;
@@ -1784,10 +1784,19 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
servlayoutp->screens = slp;
servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec));
servlayoutp->options = NULL;
- /* Set up an empty input device list, then look for some core devices. */
- indp = xnfalloc(sizeof(IDevPtr));
- *indp = NULL;
- servlayoutp->inputs = indp;
+
+ memset(&layout, 0, sizeof(layout));
+ layout.lay_identifier = servlayoutp->id;
+ if (xf86layoutAddInputDevices(xf86configptr, &layout) > 0) {
+ if (!configInputDevices(&layout, servlayoutp))
+ return FALSE;
+ from = X_DEFAULT;
+ } else {
+ /* Set up an empty input device list, then look for some core devices. */
+ indp = xnfalloc(sizeof(IDevPtr));
+ *indp = NULL;
+ servlayoutp->inputs = indp;
+ }
return TRUE;
}
@@ -2428,34 +2437,53 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
ConfigStatus
xf86HandleConfigFile(Bool autoconfig)
{
- const char *filename;
- char *searchpath;
- MessageType from = X_DEFAULT;
+ const char *filename, *dirname;
+ char *filesearch, *dirsearch;
+ MessageType filefrom = X_DEFAULT;
+ MessageType dirfrom = X_DEFAULT;
char *scanptr;
Bool singlecard = 0;
Bool implicit_layout = FALSE;
if (!autoconfig) {
- if (getuid() == 0)
- searchpath = ROOT_CONFIGPATH;
- else
- searchpath = USER_CONFIGPATH;
+ if (getuid() == 0) {
+ filesearch = ROOT_CONFIGPATH;
+ dirsearch = ROOT_CONFIGDIRPATH;
+ } else {
+ filesearch = USER_CONFIGPATH;
+ dirsearch = USER_CONFIGDIRPATH;
+ }
if (xf86ConfigFile)
- from = X_CMDLINE;
+ filefrom = X_CMDLINE;
+ if (xf86ConfigDir)
+ dirfrom = X_CMDLINE;
- filename = xf86openConfigFile(searchpath, xf86ConfigFile, PROJECTROOT);
+ xf86initConfigFiles();
+ filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT);
+ dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT);
if (filename) {
- xf86MsgVerb(from, 0, "Using config file: \"%s\"\n", filename);
+ xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename);
xf86ConfigFile = xnfstrdup(filename);
} else {
if (xf86ConfigFile)
xf86Msg(X_ERROR, "Unable to locate/open config file: \"%s\"\n",
xf86ConfigFile);
- return CONFIG_NOFILE;
}
+ if (dirname) {
+ xf86MsgVerb(dirfrom, 0, "Using config directory: \"%s\"\n",
+ dirname);
+ xf86ConfigDir = xnfstrdup(dirname);
+ } else {
+ if (xf86ConfigDir)
+ xf86Msg(X_ERROR,
+ "Unable to locate/open config directory: \"%s\"\n",
+ xf86ConfigDir);
+ }
+ if (!filename && !dirname)
+ return CONFIG_NOFILE;
}
-
+
if ((xf86configptr = xf86readConfigFile ()) == NULL) {
xf86Msg(X_ERROR, "Problem parsing the config file\n");
return CONFIG_PARSE_ERROR;
@@ -2481,7 +2509,8 @@ xf86HandleConfigFile(Bool autoconfig)
"No Layout section. Using the first Screen section.\n");
}
if (!configImpliedLayout(&xf86ConfigLayout,
- xf86configptr->conf_screen_lst)) {
+ xf86configptr->conf_screen_lst,
+ xf86configptr)) {
xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
return CONFIG_PARSE_ERROR;
}
diff --git a/xorg-server/hw/xfree86/common/xf86Globals.c b/xorg-server/hw/xfree86/common/xf86Globals.c
index 98f828483..8b483f35c 100644
--- a/xorg-server/hw/xfree86/common/xf86Globals.c
+++ b/xorg-server/hw/xfree86/common/xf86Globals.c
@@ -132,7 +132,7 @@ xf86InfoRec xf86Info = {
.kbdCustomKeycodes = FALSE,
.disableRandR = FALSE,
.randRFrom = X_DEFAULT,
-#ifdef CONFIG_HAL
+#if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
.allowEmptyInput = TRUE,
.autoAddDevices = TRUE,
.autoEnableDevices = TRUE
@@ -143,6 +143,7 @@ xf86InfoRec xf86Info = {
#endif
};
const char *xf86ConfigFile = NULL;
+const char *xf86ConfigDir = NULL;
const char *xf86ModulePath = DEFAULT_MODULE_PATH;
MessageType xf86ModPathFrom = X_DEFAULT;
const char *xf86LogFile = DEFAULT_LOGPREFIX;
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index 3b25c89a6..670744802 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/hw/xfree86/common/xf86Init.c
@@ -1387,6 +1387,19 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86ConfigFile = argv[i + 1];
return 2;
}
+ if (!strcmp(argv[i], "-configdir"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
+ FatalError("\nInvalid argument for %s\n"
+ "\tFor non-root users, the file specified with %s must be\n"
+ "\ta relative path and must not contain any \"..\" elements.\n"
+ "\tUsing default "__XCONFIGDIR__" search path.\n\n",
+ argv[i], argv[i]);
+ }
+ xf86ConfigDir = argv[i + 1];
+ return 2;
+ }
if (!strcmp(argv[i],"-flipPixels"))
{
xf86FlipPixels = TRUE;
@@ -1670,6 +1683,8 @@ ddxUseMsg(void)
}
ErrorF("-config file specify a configuration file, relative to the\n");
ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n");
+ ErrorF("-configdir dir specify a configuration directory, relative to the\n");
+ ErrorF(" "__XCONFIGDIR__" search path, only root can use absolute\n");
ErrorF("-verbose [n] verbose startup messages\n");
ErrorF("-logverbose [n] verbose log messages\n");
ErrorF("-quiet minimal startup messages\n");
diff --git a/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h
index 8e5d5cfb5..bbf5786c9 100644
--- a/xorg-server/hw/xfree86/common/xf86Module.h
+++ b/xorg-server/hw/xfree86/common/xf86Module.h
@@ -83,7 +83,7 @@ typedef enum {
*/
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(7, 0)
-#define ABI_XINPUT_VERSION SET_ABI_VERSION(8, 0)
+#define ABI_XINPUT_VERSION SET_ABI_VERSION(9, 0)
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(3, 0)
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
diff --git a/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c
index ad8d1c426..a2868bf21 100644
--- a/xorg-server/hw/xfree86/common/xf86Option.c
+++ b/xorg-server/hw/xfree86/common/xf86Option.c
@@ -42,6 +42,7 @@
#include "xf86.h"
#include "xf86Xinput.h"
#include "xf86Optrec.h"
+#include "xf86Parser.h"
static Bool ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
Bool markUsed);
@@ -456,29 +457,7 @@ xf86ShowUnusedOptions(int scrnIndex, pointer options)
static Bool
GetBoolValue(OptionInfoPtr p, const char *s)
{
- if (*s == '\0') {
- p->value.bool = TRUE;
- } else {
- if (xf86NameCmp(s, "1") == 0)
- p->value.bool = TRUE;
- else if (xf86NameCmp(s, "on") == 0)
- p->value.bool = TRUE;
- else if (xf86NameCmp(s, "true") == 0)
- p->value.bool = TRUE;
- else if (xf86NameCmp(s, "yes") == 0)
- p->value.bool = TRUE;
- else if (xf86NameCmp(s, "0") == 0)
- p->value.bool = FALSE;
- else if (xf86NameCmp(s, "off") == 0)
- p->value.bool = FALSE;
- else if (xf86NameCmp(s, "false") == 0)
- p->value.bool = FALSE;
- else if (xf86NameCmp(s, "no") == 0)
- p->value.bool = FALSE;
- else
- return FALSE;
- }
- return TRUE;
+ return xf86getBoolValue(&p->value.bool, s);
}
static Bool
diff --git a/xorg-server/hw/xfree86/common/xf86Priv.h b/xorg-server/hw/xfree86/common/xf86Priv.h
index 3bb15718c..0612c9c4e 100644
--- a/xorg-server/hw/xfree86/common/xf86Priv.h
+++ b/xorg-server/hw/xfree86/common/xf86Priv.h
@@ -46,6 +46,7 @@
* The global state of these things is held in xf86InfoRec (when appropriate).
*/
extern _X_EXPORT const char *xf86ConfigFile;
+extern _X_EXPORT const char *xf86ConfigDir;
extern _X_EXPORT Bool xf86AllowMouseOpenFail;
#ifdef XF86VIDMODE
extern _X_EXPORT Bool xf86VidModeDisabled;
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index f637cfe19..57db056d8 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.c
@@ -57,9 +57,11 @@
#include <X11/Xatom.h>
#include "xf86.h"
#include "xf86Priv.h"
+#include "xf86Config.h"
#include "xf86Xinput.h"
#include "XIstubs.h"
#include "xf86Optrec.h"
+#include "xf86Parser.h"
#include "mipointer.h"
#include "xf86InPriv.h"
#include "compiler.h"
@@ -74,6 +76,11 @@
#include "exglobals.h"
#include "eventstr.h"
+#include <string.h> /* InputClassMatches */
+#ifdef HAVE_FNMATCH_H
+#include <fnmatch.h>
+#endif
+
#include "extnsionst.h"
#include "windowstr.h" /* screenIsSaved */
@@ -466,6 +473,85 @@ AddOtherInputDevices(void)
{
}
+/*
+ * Classes without any Match statements match all devices. Otherwise, all
+ * statements must match.
+ */
+static Bool
+InputClassMatches(XF86ConfInputClassPtr iclass, InputAttributes *attrs)
+{
+ if (iclass->match_product &&
+ (!attrs->product || !strstr(attrs->product, iclass->match_product)))
+ return False;
+ if (iclass->match_vendor &&
+ (!attrs->vendor || !strstr(attrs->vendor, iclass->match_vendor)))
+ return False;
+ if (iclass->match_device &&
+#ifdef HAVE_FNMATCH_H
+ (!attrs->device ||
+ fnmatch(iclass->match_device, attrs->device, 0) != 0))
+#else
+ (!attrs->device || !strstr(attrs->device, iclass->match_device)))
+#endif
+ return False;
+ if (iclass->is_keyboard.set &&
+ iclass->is_keyboard.val != !!(attrs->flags & ATTR_KEYBOARD))
+ return False;
+ if (iclass->is_pointer.set &&
+ iclass->is_pointer.val != !!(attrs->flags & ATTR_POINTER))
+ return False;
+ if (iclass->is_joystick.set &&
+ iclass->is_joystick.val != !!(attrs->flags & ATTR_JOYSTICK))
+ return False;
+ if (iclass->is_tablet.set &&
+ iclass->is_tablet.val != !!(attrs->flags & ATTR_TABLET))
+ return False;
+ if (iclass->is_touchpad.set &&
+ iclass->is_touchpad.val != !!(attrs->flags & ATTR_TOUCHPAD))
+ return False;
+ if (iclass->is_touchscreen.set &&
+ iclass->is_touchscreen.val != !!(attrs->flags & ATTR_TOUCHSCREEN))
+ return False;
+ return True;
+}
+
+/*
+ * Merge in any InputClass configurations. Each InputClass section can
+ * add to the original device configuration as well as any previous
+ * InputClass sections.
+ */
+static int
+MergeInputClasses(IDevPtr idev, InputAttributes *attrs)
+{
+ XF86ConfInputClassPtr cl;
+ XF86OptionPtr classopts;
+
+ for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
+ if (!InputClassMatches(cl, attrs))
+ continue;
+
+ xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n",
+ idev->identifier, cl->identifier);
+ if (cl->driver && !idev->driver) {
+ idev->driver = xstrdup(cl->driver);
+ if (!idev->driver) {
+ xf86Msg(X_ERROR, "Could not allocate memory while merging "
+ "InputClass configuration");
+ return BadAlloc;
+ }
+ }
+
+ classopts = xf86optionListDup(cl->option_lst);
+ if (idev->commonOptions)
+ idev->commonOptions = xf86optionListMerge(classopts,
+ idev->commonOptions);
+ else
+ idev->commonOptions = classopts;
+ }
+
+ return Success;
+}
+
/**
* Create a new input device, activate and enable it.
*
@@ -568,7 +654,8 @@ unwind:
}
int
-NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
+NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
+ DeviceIntPtr *pdev)
{
IDevRec *idev = NULL;
InputOption *option = NULL;
@@ -605,9 +692,9 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
}
}
- /* Right now, the only automatic config we know of is HAL. */
if (strcmp(option->key, "_source") == 0 &&
- strcmp(option->value, "server/hal") == 0) {
+ (strcmp(option->value, "server/hal") == 0 ||
+ strcmp(option->value, "server/udev") == 0)) {
is_auto = 1;
if (!xf86Info.autoAddDevices) {
rval = BadMatch;
@@ -615,6 +702,23 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
}
}
}
+
+ for (option = options; option; option = option->next) {
+ /* Steal option key/value strings from the provided list.
+ * We need those strings, the InputOption list doesn't. */
+ idev->commonOptions = xf86addNewOption(idev->commonOptions,
+ option->key, option->value);
+ option->key = NULL;
+ option->value = NULL;
+ }
+
+ /* Apply InputClass settings */
+ if (attrs) {
+ rval = MergeInputClasses(idev, attrs);
+ if (rval != Success)
+ goto unwind;
+ }
+
if (!idev->driver || !idev->identifier) {
xf86Msg(X_ERROR, "No input driver/identifier specified (ignoring)\n");
rval = BadRequest;
@@ -626,15 +730,6 @@ NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
return BadMatch;
}
- for (option = options; option; option = option->next) {
- /* Steal option key/value strings from the provided list.
- * We need those strings, the InputOption list doesn't. */
- idev->commonOptions = xf86addNewOption(idev->commonOptions,
- option->key, option->value);
- option->key = NULL;
- option->value = NULL;
- }
-
rval = xf86NewInputDevice(idev, pdev,
(!is_auto || (is_auto && xf86Info.autoEnableDevices)));
if (rval == Success)
diff --git a/xorg-server/hw/xfree86/doc/README.modes b/xorg-server/hw/xfree86/doc/README.modes
new file mode 100644
index 000000000..894e21313
--- /dev/null
+++ b/xorg-server/hw/xfree86/doc/README.modes
@@ -0,0 +1,474 @@
+ Multi-monitor Mode Setting APIs
+ Keith Packard, <keithp@keithp.com
+ 6 March 2007
+
+1. Introduction
+
+This document describes a set of mode setting APIs added in X server version
+1.3 that support multiple monitors per card. These interfaces expose the
+underlying hardware CRTC and output concepts to the xf86 DDX layer so that
+the implementation of initial server setup and mode changes through
+extensions can be shared across drivers. In addition, these new interfaces
+support a new configuration mechanism as well which allows each monitor to
+be customized separately providing a consistent cross-driver configuration
+mechanism that supports the full range of output features.
+
+All of the code implementing this interface can be found in hw/xfree86/modes
+in the X server sources.
+
+2. Overview
+
+This document describes both the driver API and the configuration data
+placed in xorg.conf; these are entirely separate as the driver has no
+interaction with the configuration information at all. Much of the structure
+here is cloned from the RandR extension version 1.2 additions which deal
+with the same kinds of information.
+
+2.1 API overview
+
+The mode setting API is expressed through two new driver-visible objects,
+the 'CRTC' (xf86CrtcRec) and the 'Output' (xf86OutputRec). A CRTC refers to
+hardware within the video system that can scan a subset of the framebuffer
+and generate a video signal. An Output receives that signal and transmits it
+to a monitor, projector or other device.
+
+The xf86CrtcRec and xf86OutputRec contain a small amount of state data
+related to the object along with a pointer to a set of functions provided by
+the driver that manipulate the object in fairly simple ways.
+
+To emulate older behaviour, one of the outputs is picked as the 'compat'
+output; this output changes over time as outputs are detected and used, the
+goal is to always have one 'special' output which is used for operations
+which need a single defined monitor (like XFree86-VidModeExtension mode
+setting, RandR 1.1 mode setting, DDC property setting, etc.).
+
+2.1.1 Output overview
+
+As outputs are connected to monitors, they hold a list of modes supported by
+the monitor. If the monitor and output support DDC, then the list of modes
+generally comes from the EDID data in the monitor. Otherwise, the server
+uses the standard VESA modes, pruned by monitor timing. If the configuration
+file doesn't contain monitor timing data, the server uses default timing
+information which supports 640x480, 800x600 and 1024x768 all with a 60Hz
+refresh rate.
+
+As hardware often limits possible configuration combinations, each output
+knows the set of CRTCs that it can be connected to as well as the set of
+other outputs which can be simutaneously connected to a CRTC.
+
+2.1.2 CRTC overview
+
+CRTCs serve only to stream frame buffer data to outputs using a mode line.
+Ideally, they would not be presented to the user at all, and in fact the
+configuration file doesn't expose them. The RandR 1.2 protocol does, but the
+hope there is that client-side applications will hide them carefully away.
+
+Each crtc has an associated cursor, along with the current configuration.
+All of the data needed to determine valid configurations is contained within
+the Outputs.
+
+2.2 Configuration overview
+
+As outputs drive monitors, the "Monitor" section has been repurposed to
+define their configuration. This provides for a bit more syntax than
+the large list of driver-specific options that were used in the past for
+similar configuration.
+
+However, the existing "Monitor" section referenced by the active "Screen"
+section no longer has any use at all; some sensible meaning for this
+parameter is needed now that a Screen can have multiple Monitors.
+
+3. Public Functions
+
+3.1 PreInit functions
+
+These functions should be used during the driver PreInit phase, they are
+arranged in the order they should be invoked.
+
+ void
+ xf86CrtcConfigInit (ScrnInfoPtr scrn
+ const xf86CrtcConfigFuncsRec *funcs)
+
+This function allocates and initializes structures needed to track CRTC and
+Output state.
+
+ void
+ xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
+ int minWidth, int minHeight,
+ int maxWidth, int maxHeight)
+
+This sets the range of screen sizes supported by the driver.
+
+ xf86CrtcPtr
+ xf86CrtcCreate (ScrnInfoPtr scrn,
+ const xf86CrtcFuncsRec *funcs)
+
+Create one CRTC object. See the discussion below for a description of the
+contents of the xf86CrtcFuncsRec. Note that this is done in PreInit, so it
+should not be re-invoked at each server generation. Create one of these for
+each CRTC present in the hardware.
+
+ xf86OutputPtr
+ xf86OutputCreate (ScrnInfoPtr scrn,
+ const xf86OutputFuncsRec *funcs,
+ const char *name)
+
+Create one Output object. See the discussion below for a description of the
+contents of the xf86OutputFuncsRec. This is also called from PreInit and
+need not be re-invoked at each ScreenInit time. An Output should be created
+for every Output present in the hardware, not just for outputs which have
+detected monitors.
+
+ Bool
+ xf86OutputRename (xf86OutputPtr output, const char *name)
+
+If necessary, the name of an output can be changed after it is created using
+this function.
+
+ Bool
+ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
+
+Using the resources provided, and the configuration specified by the user,
+this function computes an initial configuration for the server. It tries to
+enable as much hardware as possible using some fairly simple heuristics.
+
+The 'canGrow' parameter indicates that the frame buffer does not have a fixed
+size (fixed size frame buffers are required by XAA). When the frame buffer
+has a fixed size, the configuration selects a 'reasonablely large' frame
+buffer so that common reconfiguration options are possible. For resizable
+frame buffers, the frame buffer is set to the smallest size that encloses
+the desired configuration.
+
+3.2 ScreenInit functions
+
+These functions should be used during the driver ScreenInit phase.
+
+ Bool
+ xf86DiDGAInit (ScreenPtr screen, unsigned long dga_address)
+
+This function provides driver-independent accelerated DGA support for some
+of the DGA operations; using this, the driver can avoid needing to implement
+any of the rest of DGA.
+
+ Bool
+ xf86SaveScreen(ScreenPtr pScreen, int mode)
+
+Stick this in pScreen->SaveScreen and the core X screen saver will be
+implemented by disabling outputs and crtcs using their dpms functions.
+
+ void
+ xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags)
+
+Pass this function to xf86DPMSInit and all DPMS mode switching will be
+managed by using the dpms functions provided by the Outputs and CRTCs.
+
+ Bool
+ xf86CrtcScreenInit (ScreenPtr screen)
+
+This function completes the screen initialization process for the crtc and
+output objects. Call it near the end of the ScreenInit function, after the
+frame buffer and acceleration layers have been added.
+
+3.3 EnterVT functions
+
+Functions used during EnterVT, or whenever the current configuration needs
+to be applied to the hardware.
+
+ Bool
+ xf86SetDesiredModes (ScrnInfoPtr scrn)
+
+xf86InitialConfiguration selects the desired configuration at PreInit time;
+when the server finally hits ScreenInit, xf86SetDesiredModes is used by the
+driver to take that configuration and apply it to the hardware. In addition,
+successful mode selection at other times updates the configuration that will
+be used by this function, so LeaveVT/EnterVT pairs can simply invoke this
+and return to the previous configuration.
+
+3.4 SwitchMode functions
+
+Functions called from the pScrn->SwitchMode hook, which is used by the
+XFree86-VidModeExtension and the keypad mode switch commands.
+
+ Bool
+ xf86SetSingleMode (ScrnInfoPtr scrn,
+ DisplayModePtr desired,
+ Rotation rotation)
+
+This function applies the specified mode to all active outputs. Which is to
+say, it picks reasonable modes for all active outputs, attempting to get the
+screen to the specified size while not breaking anything that is currently
+working.
+
+3.7 get_modes functions
+
+Functions called during output->get_modes to help build lists of modes
+
+ xf86MonPtr
+ xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus)
+
+This returns the EDID data structure for the 'output' using the I2C bus
+'pDDCBus'. This has no effect on 'output' itself.
+
+ void
+ xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon)
+
+Once the EDID data has been fetched, this call applies the EDID data to the
+output object, setting the physical size and also various properties, like
+the DDC root window property (when output is the 'compat' output), and the
+RandR 1.2 EDID output properties.
+
+ DisplayModePtr
+ xf86OutputGetEDIDModes (xf86OutputPtr output)
+
+Given an EDID data structure, this function computes a list of suitable
+modes. This function also applies a sequence of 'quirks' during this process
+so that the returned modes may not actually match the mode data present in
+the EDID data.
+
+3.6 Other functions
+
+These remaining functions in the API can be used by the driver as needed.
+
+ Bool
+ xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
+ int x, int y)
+
+Applies a mode to a CRTC. All of the outputs which are currently using the
+specified CRTC are included in the mode setting process. 'x' and 'y' are the
+offset within the frame buffer that the crtc is placed at. No checking is
+done in this function to ensure that the mode is usable by the active
+outputs.
+
+ void
+ xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY)
+
+This discards the mode lists for all outputs, re-detects monitor presence
+and then acquires new mode lists for all monitors which are not disconnected.
+Monitor configuration data is used to modify the mode lists returned by the
+outputs. 'maxX' and 'maxY' limit the maximum size modes that will be
+returned.
+
+ void
+ xf86SetScrnInfoModes (ScrnInfoPtr pScrn)
+
+This copies the 'compat' output mode list into the pScrn modes list which is
+used by the XFree86-VidModeExtension and the keypad mode switching
+operations. The current 'desired' mode for the CRTC associated with the
+'compat' output is placed first in this list to indicate the current mode.
+Usually, the driver won't need to call this function as
+xf86InitialConfiguration will do so automatically, as well as any RandR
+functions which reprobe for modes. However, if the driver reprobes for modes
+at other times using xf86ProbeOutputModes, this function needs to be called.
+
+ Bool
+ xf86DiDGAReInit (ScreenPtr pScreen)
+
+This is similar to xf86SetScrnInfoModes, but it applies the 'compat' output
+mode list to the set of modes advertised by the DGA extension; it needs to
+be called whenever xf86ProbeOutputModes is invoked.
+
+ void
+ xf86DisableUnusedFunctions(ScrnInfoPtr pScrn)
+
+After any sequence of calls using xf86CrtcSetMode, this function cleans up
+any leftover Output and CRTC objects by disabling them, saving power. It is
+safe to call this whenever the server is running as it only disables objects
+which are not currently in use.
+
+4. CRTC operations
+
+4.1 CRTC functions
+
+These functions provide an abstract interface for the CRTC object; most
+manipulation of the CRTC object is done through these functions.
+
+ void
+ crtc->funcs->dpms (xf86CrtcPtr crtc, int mode)
+
+Where 'mode' is one of DPMSModeOff, DPMSModeSuspend, DPMSModeStandby or
+DPMSModeOn. This requests that the crtc go to the specified power state.
+When changing power states, the output dpms functions are invoked before the
+crtc dpms functions.
+
+ void
+ crtc->funcs->save (xf86CrtcPtr crtc)
+
+ void
+ crtc->funcs->restore (xf86CrtcPtr crtc)
+
+Preserve/restore any register contents related to the CRTC. These are
+strictly a convenience for the driver writer; if the existing driver has
+fully operation save/restore functions, you need not place any additional
+code here. In particular, the server itself never uses this function.
+
+ Bool
+ crtc->funcs->lock (xf86CrtcPtr crtc)
+
+ void
+ crtc->funcs->unlock (xf86CrtcPtr crtc)
+
+These functions are invoked around mode setting operations; the intent is
+that DRI locking be done here to prevent DRI applications from manipulating
+the hardware while the server is busy changing the output configuration. If
+the lock function returns FALSE, the unlock function will not be invoked.
+
+ Bool
+ crtc->funcs->mode_fixup (xf86CrtcPtr crtc,
+ DisplayModePtr mode,
+ DisplayModePtr adjusted_mode)
+
+This call gives the CRTC a chance to see what mode will be set and to
+comment on the mode by changing 'adjusted_mode' as needed. This function
+shall not modify the state of the crtc hardware at all. If the CRTC cannot
+accept this mode, this function may return FALSE.
+
+ void
+ crtc->funcs->prepare (xf86CrtcPtr crtc)
+
+This call is made just before the mode is set to make the hardware ready for
+the operation. A usual function to perform here is to disable the crtc so
+that mode setting can occur with clocks turned off and outputs deactivated.
+
+ void
+ crtc->funcs->mode_set (xf86CrtcPtr crtc,
+ DisplayModePtr mode,
+ DisplayModePtr adjusted_mode)
+
+This function applies the specified mode (possibly adjusted by the CRTC
+and/or Outputs).
+
+ void
+ crtc->funcs->commit (xf86CrtcPtr crtc)
+
+Once the mode has been applied to the CRTC and Outputs, this function is
+invoked to let the hardware turn things back on.
+
+ void
+ crtc->funcs->gamma_set (xf86CrtcPtr crtc, CARD16 *red,
+ CARD16 *green, CARD16 *blue, int size)
+
+This function adjusts the gamma ramps for the specified crtc.
+
+ void *
+ crtc->funcs->shadow_allocate (xf86CrtcPtr crtc, int width, int height)
+
+This function allocates frame buffer space for a shadow frame buffer. When
+allocated, the crtc must scan from the shadow instead of the main frame
+buffer. This is used for rotation. The address returned is passed to the
+shadow_create function. This function should return NULL on failure.
+
+ PixmapPtr
+ crtc->funcs->shadow_create (xf86CrtcPtr crtc, void *data,
+ int width, int height)
+
+This function creates a pixmap object that will be used as a shadow of the
+main frame buffer for CRTCs which are rotated or reflected. 'data' is the
+value returned by shadow_allocate.
+
+ void
+ crtc->funcs->shadow_destroy (xf86CrtcPtr crtc, PixmapPtr pPixmap,
+ void *data)
+
+Destroys any associated shadow objects. If pPixmap is NULL, then a pixmap
+was not created, but 'data' may still be non-NULL indicating that the shadow
+had been allocated.
+
+ void
+ crtc->funcs->destroy (xf86CrtcPtr crtc)
+
+When a CRTC is destroyed (which only happens in error cases), this function
+can clean up any driver-specific data.
+
+4.2 CRTC fields
+
+The CRTC object is not opaque; there are several fields of interest to the
+driver writer.
+
+ struct _xf86Crtc {
+ /**
+ * Associated ScrnInfo
+ */
+ ScrnInfoPtr scrn;
+
+ /**
+ * Active state of this CRTC
+ *
+ * Set when this CRTC is driving one or more outputs
+ */
+ Bool enabled;
+
+ /** Track whether cursor is within CRTC range */
+ Bool cursorInRange;
+
+ /** Track state of cursor associated with this CRTC */
+ Bool cursorShown;
+
+ /**
+ * Active mode
+ *
+ * This reflects the mode as set in the CRTC currently
+ * It will be cleared when the VT is not active or
+ * during server startup
+ */
+ DisplayModeRec mode;
+ Rotation rotation;
+ PixmapPtr rotatedPixmap;
+ void *rotatedData;
+
+ /**
+ * Position on screen
+ *
+ * Locates this CRTC within the frame buffer
+ */
+ int x, y;
+
+ /**
+ * Desired mode
+ *
+ * This is set to the requested mode, independent of
+ * whether the VT is active. In particular, it receives
+ * the startup configured mode and saves the active mode
+ * on VT switch.
+ */
+ DisplayModeRec desiredMode;
+ Rotation desiredRotation;
+ int desiredX, desiredY;
+
+ /** crtc-specific functions */
+ const xf86CrtcFuncsRec *funcs;
+
+ /**
+ * Driver private
+ *
+ * Holds driver-private information
+ */
+ void *driver_private;
+ #ifdef RANDR_12_INTERFACE
+ /**
+ * RandR crtc
+ *
+ * When RandR 1.2 is available, this
+ * points at the associated crtc object
+ */
+ RRCrtcPtr randr_crtc;
+ #else
+ void *randr_crtc;
+ #endif
+ };
+
+
+5. Output functions.
+
+6. Configuration
+
+Because the configuration file syntax is fixed,
+this was done by creating new "Driver" section options that hook specific
+outputs to specific "Monitor" sections in the file. The option:
+section of the form:
+
+ Option "monitor-VGA" "My VGA Monitor"
+
+connects the VGA output of this driver to the "Monitor" section with
+Identifier "My VGA Monitor". All of the usual monitor options can now be
+placed in that "Monitor" section and will be applied to the VGA output
+configuration.
diff --git a/xorg-server/hw/xfree86/doc/man/Xorg.man.pre b/xorg-server/hw/xfree86/doc/man/Xorg.man.pre
index fe3280038..46d0e4468 100644
--- a/xorg-server/hw/xfree86/doc/man/Xorg.man.pre
+++ b/xorg-server/hw/xfree86/doc/man/Xorg.man.pre
@@ -109,7 +109,7 @@ script.
.B __xservername__
supports several mechanisms for supplying/obtaining configuration and
run-time parameters: command line options, environment variables, the
-__xconfigfile__(__filemansuffix__) configuration file, auto-detection, and
+__xconfigfile__(__filemansuffix__) configuration files, auto-detection, and
fallback defaults. When the same information is supplied in more than
one way, the highest precedence mechanism is used. The list of mechanisms
is ordered from highest precedence to lowest. Note that not all parameters
@@ -176,6 +176,13 @@ This option will work for any file when the server is run as root (i.e,
with real-uid 0), or for files relative to a directory in the config
search path for all other users.
.TP 8
+.BI \-configdir " directory"
+Read the server configuration files from
+.IR directory .
+This option will work for any directory when the server is run as root
+(i.e, with real-uid 0), or for directories relative to a directory in the
+config directory search path for all other users.
+.TP 8
.B \-configure
When this option is specified, the
.B __xservername__
@@ -421,25 +428,18 @@ The
.B __xservername__
server is normally configured to recognize various special combinations
of key presses that instruct the server to perform some action, rather
-than just sending the key press event to a client application. The
-default XKEYBOARD keymap defines the key combinations listed below.
-The kbd (__drivermansuffix__) driver also has these key combinations
-builtin to its event handler
-for cases where the XKEYBOARD extension is not being used. When using
-the XKEYBOARD extension, which key combinations perform which actions
-is completely configurable.
+than just sending the key press event to a client application. These actions
+depend on the XKB keymap loaded by a particular keyboard device and may or
+may not be available on a given configuration.
.PP
-The special combinations of key presses recognized directly
-by
-.B __xservername__
-are:
+The following key combinations are commonly part of the default XKEYBOARD
+keymap.
.TP 8
.B Ctrl+Alt+Backspace
-Immediately kills the server -- no questions asked. This is disabled by
-default. It can be enabled with the -retro command line flag or by setting
-the
+Immediately kills the server -- no questions asked. It can be disabled by
+setting the
.B DontZap
-__xconfigfile__(__filemansuffix__) file option to a FALSE value.
+__xconfigfile__(__filemansuffix__) file option to a TRUE value.
.TP 8
.B Ctrl+Alt+Keypad-Plus
Change video mode to next one specified in the configuration file.
@@ -463,6 +463,10 @@ __xconfigfile__(__filemansuffix__) file option.
.B __xservername__
typically uses a configuration file called
.B __xconfigfile__
+and configuration files with the suffix
+.I .conf
+in a directory called
+.B __xconfigdir__
for its initial setup.
Refer to the __xconfigfile__(__filemansuffix__) manual page for information
about the format of this file.
@@ -471,7 +475,9 @@ about the format of this file.
has a mechanism for automatically generating a built-in configuration
at run-time when no
.B __xconfigfile__
-file is present. The current version of this automatic configuration
+file or
+.B __xconfigdir__
+files are present. The current version of this automatic configuration
mechanism works in two ways.
.PP
The first is via enhancements that have made many components of the
@@ -493,7 +499,7 @@ supported by __xservername__. Enhancements are planned for future releases.
.SH FILES
The
.B __xservername__
-server config file can be found in a range of locations. These are
+server config files can be found in a range of locations. These are
documented fully in the __xconfigfile__(__filemansuffix__) manual page. The
most commonly used locations are shown here.
.TP 30
@@ -512,6 +518,21 @@ Server configuration file.
.B __projectroot__/lib/X11/__xconfigfile__
Server configuration file.
.TP 30
+.B /etc/X11/__xconfigdir__
+Server configuration directory.
+.TP 30
+.B /etc/X11/__xconfigdir__-4
+Server configuration directory.
+.TP 30
+.B /etc/__xconfigdir__
+Server configuration directory.
+.TP 30
+.B __projectroot__/etc/__xconfigdir__
+Server configuration directory.
+.TP 30
+.B __projectroot__/lib/X11/__xconfigdir__
+Server configuration directory.
+.TP 30
.BI __logdir__/__xservername__. n .log
Server log file for display
.IR n .
diff --git a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre
index ace041c92..5b98bda63 100644
--- a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -2,27 +2,35 @@
.ds q \N'34'
.TH __xconfigfile__ __filemansuffix__ __vendorversion__
.SH NAME
-__xconfigfile__ \- configuration File for __xservername__ X server
+__xconfigfile__ and __xconfigdir__ \- configuration files for
+__xservername__ X server
.SH INTRODUCTION
.B __xservername__
supports several mechanisms for supplying/obtaining configuration and
run-time parameters: command line options, environment variables, the
-__xconfigfile__ configuration file, auto-detection, and fallback defaults.
-When the same information is supplied in more than one way, the highest
-precedence mechanism is used. The list of mechanisms is ordered from
-highest precedence to lowest. Note that not all parameters can be
-supplied via all methods. The available command line options and
-environment variables (and some defaults) are described in the Xserver(__appmansuffix__)
-and __xservername__(__appmansuffix__) manual pages. Most configuration file parameters, with
-their defaults, are described below. Driver and module specific
-configuration parameters are described in the relevant driver or module
-manual page.
+__xconfigfile__ and __xconfigdir__ configuration files, auto-detection,
+and fallback defaults. When the same information is supplied in more
+than one way, the highest precedence mechanism is used. The list of
+mechanisms is ordered from highest precedence to lowest. Note that not
+all parameters can be supplied via all methods. The available command
+line options and environment variables (and some defaults) are
+described in the Xserver(__appmansuffix__) and
+__xservername__(__appmansuffix__) manual pages. Most configuration file
+parameters, with their defaults, are described below. Driver and module
+specific configuration parameters are described in the relevant driver
+or module manual page.
.SH DESCRIPTION
.B __xservername__
uses a configuration file called
.I __xconfigfile__
+and files ending in the suffix
+.I .conf
+from the directory
+.I __xconfigdir__
for its initial setup.
-This configuration file is searched for in the following places when the
+The
+.I __xconfigfile__
+configuration file is searched for in the following places when the
server is started as a normal user:
.PP
.RS 4
@@ -93,9 +101,28 @@ directory), and
is the machine's hostname as reported by
.BR gethostname (__libmansuffix__).
.PP
+Additional configuration files are searched for in the following
+directories:
+.PP
+.RS 4
+.nf
+.I /etc/X11/__xconfigdir__\-4
+.I /etc/X11/__xconfigdir__
+.I /etc/__xconfigdir__
+.IR __projectroot__/etc/X11/__xconfigdir__. <hostname>
+.I __projectroot__/etc/X11/__xconfigdir__\-4
+.I __projectroot__/etc/X11/__xconfigdir__
+.IR __projectroot__/lib/X11/__xconfigdir__. <hostname>
+.I __projectroot__/lib/X11/__xconfigdir__\-4
+.I __projectroot__/lib/X11/__xconfigdir__
+.fi
+.RE
+.PP
The
.I __xconfigfile__
-file is composed of a number of sections which may be present in any order,
+and
+.I __xconfigdir__
+files are composed of a number of sections which may be present in any order,
or omitted to use default configuration values.
Each section has the form:
.PP
@@ -117,6 +144,7 @@ The section names are:
.BR "Module " "Dynamic module loading"
.BR "Extensions " "Extension enabling"
.BR "InputDevice " "Input device description"
+.BR "InputClass " "Input class description"
.BR "Device " "Graphics device description"
.BR "VideoAdaptor " "Xv video adaptor description"
.BR "Monitor " "Monitor description"
@@ -769,11 +797,28 @@ Example: the MIT-SHM extension can be disabled with the following entry:
The config file may have multiple
.B InputDevice
sections.
-If HAL is not being used for input device configuration, there will normally
-be at least two: one for the core (primary) keyboard,
-and one of the core pointer.
+Recent X servers employ input hotplugging to add input devices, with the HAL
+backend being the default backend for X servers since 1.4. It is usually not
+necessary to provide
+.B InputDevice
+sections in the xorg.conf if hotplugging is enabled.
+.PP
+If hotplugging is disabled, there will normally
+be at least two: one for the core (primary) keyboard
+and one for the core pointer.
If either of these two is missing, a default configuration for the missing
-ones will be used.
+ones will be used. In the absence of an explicitly specified core input
+device, the first
+.B InputDevice
+marked as
+.B CorePointer
+(or
+.BR CoreKeyboard )
+is used.
+If there is no match there, the first
+.B InputDevice
+that uses the \(lqmouse\(rq (or \(lqkbd\(rq) driver is used.
+The final fallback is to use built\-in default configurations.
Currently the default configuration may not work as expected on all platforms.
.PP
.B InputDevice
@@ -828,17 +873,6 @@ and
.BR mousedrv (__drivermansuffix__)
on other platforms.
.PP
-In the absence of an explicitly specified core input device, the first
-.B InputDevice
-marked as
-.B CorePointer
-(or
-.BR CoreKeyboard )
-is used.
-If there is no match there, the first
-.B InputDevice
-that uses the \(lqmouse\(rq (or \(lqkbd\(rq) driver is used.
-The final fallback is to use built\-in default configurations.
.PP
.B InputDevice
sections recognise some driver\-independent
@@ -847,48 +881,135 @@ which are described here.
See the individual input driver manual pages for a description of the
device\-specific options.
.TP 7
+.BI "Option \*qAutoServerLayout\*q \*q" boolean \*q
+Always add the device to the ServerLayout section used by this instance of
+the server. This affects implied layouts as well as explicit layouts
+specified in the configuration and/or on the command line.
+.TP 7
.BI "Option \*qCorePointer\*q"
-When this is set, the input device is installed as the core (primary)
-pointer device.
-There must be exactly one core pointer.
-If this option is not set here, or in the
-.B ServerLayout
-section, or from the
-.B \-pointer
-command line option, then the first input device that is capable of
-being used as a core pointer will be selected as the core pointer.
-This option is implicitly set when the obsolete
-.B Pointer
-section is used.
+Deprecated, use
+.B SendCoreEvents
+instead.
.TP 7
.BI "Option \*qCoreKeyboard\*q"
-When this is set, the input device is to be installed as the core
-(primary) keyboard device.
-There must be exactly one core keyboard.
-If this option is not set here, in the
-.B ServerLayout
-section, or from the
-.B \-keyboard
-command line option, then the first input device that is capable of
-being used as a core keyboard will be selected as the core keyboard.
-This option is implicitly set when the obsolete
-.B Keyboard
-section is used.
+Deprecated, use
+.B SendCoreEvents
+instead.
.TP 7
.BI "Option \*qAlwaysCore\*q \*q" boolean \*q
+.B
+Deprecated, use
+.B SendCoreEvents
+instead.
.TP 7
.BI "Option \*qSendCoreEvents\*q \*q" boolean \*q
Both of these options are equivalent, and when enabled cause the
-input device to always report core events.
-This can be used, for example, to allow an additional pointer device to
-generate core pointer events (like moving the cursor, etc).
-.TP 4
-.BI "Option \*qHistorySize\*q \*q" number \*q
-Sets the motion history size.
-Default: 0.
+input device to report core events through the master device. They are
+enabled by default. Any device configured to send core events will be
+attached to the virtual core pointer or keyboard and control the cursor by
+default. Devices with
+.B SendCoreEvents
+disabled will be \*qfloating\*q and only accessible by clients employing the
+X Input extension. This option controls the startup behavior only, a device
+may be reattached or set floating at runtime.
.TP 7
.BI "Option \*qSendDragEvents\*q \*q" boolean \*q
???
+.SH "INPUTCLASS SECTION"
+The config file may have multiple
+.B InputClass
+sections.
+These sections are optional and are used to provide configuration for a
+class of input devices as they are automatically added. An input device can
+match more than one
+.B InputClass
+section. Each class can only supplement settings from a previous class, so
+it is best to arrange the sections with the most generic matches last.
+.PP
+.B InputClass
+sections have the following format:
+.PP
+.RS 4
+.nf
+.B "Section \*qInputClass\*q"
+.BI " Identifier \*q" name \*q
+.I " entries"
+.I " ..."
+.I " options"
+.I " ..."
+.B "EndSection"
+.fi
+.RE
+.PP
+The
+.B Identifier
+entry is required in all
+.B InputClass
+sections.
+All other entries are optional.
+.PP
+The
+.B Identifier
+entry specifies the unique name for this input class.
+The
+.B Driver
+entry specifies the name of the driver to use for this input device.
+After all classes have been examined, the
+.RI \*q inputdriver \*q
+module from the final
+.B Driver
+entry will be enabled when using the loadable server.
+.PP
+When an input device is automatically added, its characteristics are
+checked against all
+.B InputClass
+sections. Each section can contain optional entries to narrow the match
+of the class. If none of the optional entries appear, the
+.B InputClass
+section is generic and will match any input device. If more than one of
+these entries appear, they all must match for the configuration to apply.
+The allowed matching entries are shown below.
+.PP
+.TP 7
+.BI "MatchProduct \*q" matchproduct \*q
+This entry can be used to check if the substring
+.RI \*q matchproduct \*q
+occurs in the device's product name.
+.TP 7
+.BI "MatchVendor \*q" matchvendor \*q
+This entry can be used to check if the substring
+.RI \*q matchvendor \*q
+occurs in the device's vendor name.
+.TP 7
+.BI "MatchDevicePath \*q" matchdevice \*q
+This entry can be used to check if the device file matches the
+.RI \*q matchdevice \*q
+pathname pattern.
+.TP 7
+.BI "MatchIsKeyboard \*q" bool \*q
+.TP 7
+.BI "MatchIsPointer \*q" bool \*q
+.TP 7
+.BI "MatchIsJoystick \*q" bool \*q
+.TP 7
+.BI "MatchIsTablet \*q" bool \*q
+.TP 7
+.BI "MatchIsTouchpad \*q" bool \*q
+.TP 7
+.BI "MatchIsTouchscreen \*q" bool \*q
+Match device types. These entries take a boolean argument similar to
+.B Option
+entries.
+.PP
+When an input device has been matched to the
+.B InputClass
+section, any
+.B Option
+entries are applied to the device. See the
+.B InputDevice
+section above for a description of the various
+.B Option
+entries.
.SH "DEVICE SECTION"
The config file may have multiple
.B Device
diff --git a/xorg-server/hw/xfree86/exa/examodule.c b/xorg-server/hw/xfree86/exa/examodule.c
index 601288c73..bcb6a405c 100644
--- a/xorg-server/hw/xfree86/exa/examodule.c
+++ b/xorg-server/hw/xfree86/exa/examodule.c
@@ -122,24 +122,25 @@ exaDDXDriverInit(ScreenPtr pScreen)
memcpy(pScreenPriv->options, EXAOptions, sizeof(EXAOptions));
xf86ProcessOptions (pScrn->scrnIndex, pScrn->options, pScreenPriv->options);
- if ((pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) &&
- pExaScr->info->offScreenBase < pExaScr->info->memorySize)
- {
- char *heuristicName;
-
- heuristicName = xf86GetOptValString (pScreenPriv->options,
- EXAOPT_MIGRATION_HEURISTIC);
- if (heuristicName != NULL) {
- if (strcmp(heuristicName, "greedy") == 0)
- pExaScr->migration = ExaMigrationGreedy;
- else if (strcmp(heuristicName, "always") == 0)
- pExaScr->migration = ExaMigrationAlways;
- else if (strcmp(heuristicName, "smart") == 0)
- pExaScr->migration = ExaMigrationSmart;
- else {
- xf86DrvMsg (pScreen->myNum, X_WARNING,
- "EXA: unknown migration heuristic %s\n",
- heuristicName);
+ if (pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) {
+ if (!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS) &&
+ pExaScr->info->offScreenBase < pExaScr->info->memorySize) {
+ char *heuristicName;
+
+ heuristicName = xf86GetOptValString (pScreenPriv->options,
+ EXAOPT_MIGRATION_HEURISTIC);
+ if (heuristicName != NULL) {
+ if (strcmp(heuristicName, "greedy") == 0)
+ pExaScr->migration = ExaMigrationGreedy;
+ else if (strcmp(heuristicName, "always") == 0)
+ pExaScr->migration = ExaMigrationAlways;
+ else if (strcmp(heuristicName, "smart") == 0)
+ pExaScr->migration = ExaMigrationSmart;
+ else {
+ xf86DrvMsg (pScreen->myNum, X_WARNING,
+ "EXA: unknown migration heuristic %s\n",
+ heuristicName);
+ }
}
}
diff --git a/xorg-server/hw/xfree86/parser/Configint.h b/xorg-server/hw/xfree86/parser/Configint.h
index cdc7be806..03509b397 100644
--- a/xorg-server/hw/xfree86/parser/Configint.h
+++ b/xorg-server/hw/xfree86/parser/Configint.h
@@ -148,6 +148,8 @@ else\
"The %s keyword requires a number to follow it."
#define POSITIVE_INT_MSG \
"The %s keyword requires a positive integer to follow it."
+#define BOOL_MSG \
+"The %s keyword requires a boolean to follow it."
#define ZAXISMAPPING_MSG \
"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it."
#define AUTOREPEAT_MSG \
diff --git a/xorg-server/hw/xfree86/parser/Input.c b/xorg-server/hw/xfree86/parser/Input.c
index 4e3c04e53..8c8e46fb4 100644
--- a/xorg-server/hw/xfree86/parser/Input.c
+++ b/xorg-server/hw/xfree86/parser/Input.c
@@ -172,13 +172,6 @@ xf86validateInput (XF86ConfigPtr p)
{
XF86ConfInputPtr input = p->conf_input_lst;
-#if 0 /* Enable this later */
- if (!input) {
- xf86validationError ("At least one InputDevice section is required.");
- return (FALSE);
- }
-#endif
-
while (input) {
if (!input->inp_driver) {
xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier);
diff --git a/xorg-server/hw/xfree86/parser/InputClass.c b/xorg-server/hw/xfree86/parser/InputClass.c
new file mode 100644
index 000000000..1c9816012
--- /dev/null
+++ b/xorg-server/hw/xfree86/parser/InputClass.c
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2009 Dan Nicholson
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static
+xf86ConfigSymTabRec InputClassTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {DRIVER, "driver"},
+ {MATCH_PRODUCT, "matchproduct"},
+ {MATCH_VENDOR, "matchvendor"},
+ {MATCH_DEVICE_PATH, "matchdevicepath"},
+ {MATCH_IS_KEYBOARD, "matchiskeyboard"},
+ {MATCH_IS_POINTER, "matchispointer"},
+ {MATCH_IS_JOYSTICK, "matchisjoystick"},
+ {MATCH_IS_TABLET, "matchistablet"},
+ {MATCH_IS_TOUCHPAD, "matchistouchpad"},
+ {MATCH_IS_TOUCHSCREEN, "matchistouchscreen"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeInputClassList
+
+XF86ConfInputClassPtr
+xf86parseInputClassSection(void)
+{
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfInputClassPtr, XF86ConfInputClassRec)
+
+ while ((token = xf86getToken(InputClassTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->comment = xf86addComment(ptr->comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case DRIVER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "Driver");
+ if (strcmp(val.str, "keyboard") == 0)
+ ptr->driver = "kbd";
+ else
+ ptr->driver = val.str;
+ break;
+ case OPTION:
+ ptr->option_lst = xf86parseOption(ptr->option_lst);
+ break;
+ case MATCH_PRODUCT:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchProduct");
+ ptr->match_product = val.str;
+ break;
+ case MATCH_VENDOR:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchVendor");
+ ptr->match_vendor = val.str;
+ break;
+ case MATCH_DEVICE_PATH:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchDevicePath");
+ ptr->match_device = val.str;
+ break;
+ case MATCH_IS_KEYBOARD:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsKeyboard");
+ ptr->is_keyboard.set = xf86getBoolValue(&ptr->is_keyboard.val,
+ val.str);
+ if (!ptr->is_keyboard.set)
+ Error(BOOL_MSG, "MatchIsKeyboard");
+ break;
+ case MATCH_IS_POINTER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsPointer");
+ ptr->is_pointer.set = xf86getBoolValue(&ptr->is_pointer.val,
+ val.str);
+ if (!ptr->is_pointer.set)
+ Error(BOOL_MSG, "MatchIsPointer");
+ break;
+ case MATCH_IS_JOYSTICK:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsJoystick");
+ ptr->is_joystick.set = xf86getBoolValue(&ptr->is_joystick.val,
+ val.str);
+ if (!ptr->is_joystick.set)
+ Error(BOOL_MSG, "MatchIsJoystick");
+ break;
+ case MATCH_IS_TABLET:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsTablet");
+ ptr->is_tablet.set = xf86getBoolValue(&ptr->is_tablet.val,
+ val.str);
+ if (!ptr->is_tablet.set)
+ Error(BOOL_MSG, "MatchIsTablet");
+ break;
+ case MATCH_IS_TOUCHPAD:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsTouchpad");
+ ptr->is_touchpad.set = xf86getBoolValue(&ptr->is_touchpad.val,
+ val.str);
+ if (!ptr->is_touchpad.set)
+ Error(BOOL_MSG, "MatchIsTouchpad");
+ break;
+ case MATCH_IS_TOUCHSCREEN:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsTouchscreen");
+ ptr->is_touchscreen.set = xf86getBoolValue(&ptr->is_touchscreen.val,
+ val.str);
+ if (!ptr->is_touchscreen.set)
+ Error(BOOL_MSG, "MatchIsTouchscreen");
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error(NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf("InputClass section parsed\n");
+#endif
+
+ return ptr;
+}
+
+void
+xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr)
+{
+ while (ptr) {
+ fprintf(cf, "Section \"InputClass\"\n");
+ if (ptr->comment)
+ fprintf(cf, "%s", ptr->comment);
+ if (ptr->identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->identifier);
+ if (ptr->driver)
+ fprintf(cf, "\tDriver \"%s\"\n", ptr->driver);
+ if (ptr->match_product)
+ fprintf(cf, "\tMatchProduct \"%s\"\n", ptr->match_product);
+ if (ptr->match_vendor)
+ fprintf(cf, "\tMatchVendor \"%s\"\n", ptr->match_vendor);
+ if (ptr->match_device)
+ fprintf(cf, "\tMatchDevicePath \"%s\"\n", ptr->match_device);
+ if (ptr->is_keyboard.set)
+ fprintf(cf, "\tIsKeyboard \"%s\"\n",
+ ptr->is_keyboard.val ? "yes" : "no");
+ if (ptr->is_pointer.set)
+ fprintf(cf, "\tIsPointer \"%s\"\n",
+ ptr->is_pointer.val ? "yes" : "no");
+ if (ptr->is_joystick.set)
+ fprintf(cf, "\tIsJoystick \"%s\"\n",
+ ptr->is_joystick.val ? "yes" : "no");
+ if (ptr->is_tablet.set)
+ fprintf(cf, "\tIsTablet \"%s\"\n",
+ ptr->is_tablet.val ? "yes" : "no");
+ if (ptr->is_touchpad.set)
+ fprintf(cf, "\tIsTouchpad \"%s\"\n",
+ ptr->is_touchpad.val ? "yes" : "no");
+ if (ptr->is_touchscreen.set)
+ fprintf(cf, "\tIsTouchscreen \"%s\"\n",
+ ptr->is_touchscreen.val ? "yes" : "no");
+ xf86printOptionList(cf, ptr->option_lst, 1);
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeInputClassList (XF86ConfInputClassPtr ptr)
+{
+ XF86ConfInputClassPtr prev;
+
+ while (ptr) {
+ TestFree(ptr->identifier);
+ TestFree(ptr->driver);
+ TestFree(ptr->match_product);
+ TestFree(ptr->match_vendor);
+ TestFree(ptr->match_device);
+ TestFree(ptr->comment);
+ xf86optionListFree(ptr->option_lst);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
+}
diff --git a/xorg-server/hw/xfree86/parser/Layout.c b/xorg-server/hw/xfree86/parser/Layout.c
index d548cd210..00c1e7d09 100644
--- a/xorg-server/hw/xfree86/parser/Layout.c
+++ b/xorg-server/hw/xfree86/parser/Layout.c
@@ -64,6 +64,10 @@
#include "Configint.h"
#include <string.h>
+
+/* Needed for auto server layout */
+extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
+
extern LexRec val;
static xf86ConfigSymTabRec LayoutTab[] =
@@ -435,18 +439,58 @@ xf86freeLayoutList (XF86ConfLayoutPtr ptr)
}
}
-#define CheckScreen(str, ptr)\
-if (str[0] != '\0') \
-{ \
-screen = xf86findScreen (str, p->conf_screen_lst); \
-if (!screen) \
-{ \
- xf86validationError (UNDEFINED_SCREEN_MSG, \
- str, layout->lay_identifier); \
- return (FALSE); \
-} \
-else \
- ptr = screen; \
+int
+xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout)
+{
+ int count = 0;
+ XF86ConfInputPtr input = config->conf_input_lst;
+ XF86ConfInputrefPtr inptr;
+
+ /* add all AutoServerLayout devices to the server layout */
+ while (input)
+ {
+ if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE))
+ {
+ XF86ConfInputrefPtr iref = layout->lay_input_lst;
+
+ /* avoid duplicates if referenced but lists AutoServerLayout too */
+ while (iref)
+ {
+ if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0)
+ break;
+ iref = iref->list.next;
+ }
+
+ if (!iref)
+ {
+ XF86ConfInputrefPtr iptr;
+ iptr = calloc(1, sizeof(XF86ConfInputrefRec));
+ iptr->iref_inputdev_str = input->inp_identifier;
+ layout->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem((glp)layout->lay_input_lst, (glp)iptr);
+ count++;
+ }
+ }
+ input = input->list.next;
+ }
+
+ inptr = layout->lay_input_lst;
+ while (inptr)
+ {
+ input = xf86findInput (inptr->iref_inputdev_str,
+ config->conf_input_lst);
+ if (!input)
+ {
+ xf86validationError (UNDEFINED_INPUT_MSG,
+ inptr->iref_inputdev_str, layout->lay_identifier);
+ return -1;
+ }
+ else
+ inptr->iref_inputdev = input;
+ inptr = inptr->list.next;
+ }
+
+ return count;
}
int
@@ -455,10 +499,8 @@ xf86validateLayout (XF86ConfigPtr p)
XF86ConfLayoutPtr layout = p->conf_layout_lst;
XF86ConfAdjacencyPtr adj;
XF86ConfInactivePtr iptr;
- XF86ConfInputrefPtr inptr;
XF86ConfScreenPtr screen;
XF86ConfDevicePtr device;
- XF86ConfInputPtr input;
while (layout)
{
@@ -476,13 +518,6 @@ xf86validateLayout (XF86ConfigPtr p)
else
adj->adj_screen = screen;
-#if 0
- CheckScreen (adj->adj_top_str, adj->adj_top);
- CheckScreen (adj->adj_bottom_str, adj->adj_bottom);
- CheckScreen (adj->adj_left_str, adj->adj_left);
- CheckScreen (adj->adj_right_str, adj->adj_right);
-#endif
-
adj = adj->list.next;
}
iptr = layout->lay_inactive_lst;
@@ -500,21 +535,10 @@ xf86validateLayout (XF86ConfigPtr p)
iptr->inactive_device = device;
iptr = iptr->list.next;
}
- inptr = layout->lay_input_lst;
- while (inptr)
- {
- input = xf86findInput (inptr->iref_inputdev_str,
- p->conf_input_lst);
- if (!input)
- {
- xf86validationError (UNDEFINED_INPUT_MSG,
- inptr->iref_inputdev_str, layout->lay_identifier);
- return (FALSE);
- }
- else
- inptr->iref_inputdev = input;
- inptr = inptr->list.next;
- }
+
+ if (xf86layoutAddInputDevices(p, layout) == -1)
+ return FALSE;
+
layout = layout->list.next;
}
return (TRUE);
diff --git a/xorg-server/hw/xfree86/parser/Makefile.am b/xorg-server/hw/xfree86/parser/Makefile.am
index b8fab2835..49c191f2a 100644
--- a/xorg-server/hw/xfree86/parser/Makefile.am
+++ b/xorg-server/hw/xfree86/parser/Makefile.am
@@ -13,6 +13,7 @@ INTERNAL_SOURCES= \
Files.c \
Flags.c \
Input.c \
+ InputClass.c \
Layout.c \
Module.c \
Video.c \
diff --git a/xorg-server/hw/xfree86/parser/configProcs.h b/xorg-server/hw/xfree86/parser/configProcs.h
index 26ba40ebb..7d8a8e53a 100644
--- a/xorg-server/hw/xfree86/parser/configProcs.h
+++ b/xorg-server/hw/xfree86/parser/configProcs.h
@@ -48,6 +48,10 @@ XF86ConfInputPtr xf86parseInputSection(void);
void xf86printInputSection(FILE *f, XF86ConfInputPtr ptr);
void xf86freeInputList(XF86ConfInputPtr ptr);
int xf86validateInput (XF86ConfigPtr p);
+/* InputClass.c */
+XF86ConfInputClassPtr xf86parseInputClassSection(void);
+void xf86printInputClassSection(FILE *f, XF86ConfInputClassPtr ptr);
+void xf86freeInputClassList(XF86ConfInputClassPtr ptr);
/* Layout.c */
XF86ConfLayoutPtr xf86parseLayoutSection(void);
void xf86printLayoutSection(FILE *cf, XF86ConfLayoutPtr ptr);
diff --git a/xorg-server/hw/xfree86/parser/read.c b/xorg-server/hw/xfree86/parser/read.c
index e965d209e..1091be5e5 100644
--- a/xorg-server/hw/xfree86/parser/read.c
+++ b/xorg-server/hw/xfree86/parser/read.c
@@ -177,6 +177,14 @@ xf86readConfigFile (void)
HANDLE_LIST (conf_input_lst, xf86parseInputSection,
XF86ConfInputPtr);
}
+ else if (xf86nameCompare(val.str, "inputclass") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_inputclass_lst,
+ xf86parseInputClassSection,
+ XF86ConfInputClassPtr);
+ }
else if (xf86nameCompare (val.str, "module") == 0)
{
free(val.str);
diff --git a/xorg-server/hw/xfree86/parser/scan.c b/xorg-server/hw/xfree86/parser/scan.c
index d2e8b6d2b..b80fbfb8f 100644
--- a/xorg-server/hw/xfree86/parser/scan.c
+++ b/xorg-server/hw/xfree86/parser/scan.c
@@ -62,8 +62,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
+#include <dirent.h>
#include <unistd.h>
#include <stdarg.h>
+#include <X11/Xdefs.h>
#include <X11/Xfuncproto.h>
#if defined(_POSIX_SOURCE)
@@ -90,17 +93,24 @@
#include "xf86tokens.h"
#define CONFIG_BUF_LEN 1024
+#define CONFIG_MAX_FILES 64
static int StringToToken (char *, xf86ConfigSymTabRec *);
-static FILE *configFile = NULL;
+static struct {
+ FILE *file;
+ char *path;
+} configFiles[CONFIG_MAX_FILES];
static const char **builtinConfig = NULL;
static int builtinIndex = 0;
static int configPos = 0; /* current readers position */
static int configLineNo = 0; /* linenumber */
static char *configBuf, *configRBuf; /* buffer for lines */
static char *configPath; /* path to config file */
+static char *configDirPath; /* path to config dir */
static char *configSection = NULL; /* name of current section being parsed */
+static int numFiles = 0; /* number of config files */
+static int curFileIndex = 0; /* index of current config file */
static int pushToken = LOCK_TOKEN;
static int eol_seen = 0; /* private state to handle comments */
LexRec val;
@@ -155,7 +165,7 @@ xf86strToUL (char *str)
/*
* xf86getNextLine --
*
- * read from the configFile FILE stream until we encounter a new
+ * read from the configFiles FILE stream until we encounter a new
* line; this is effectively just a big wrapper for fgets(3).
*
* xf86getToken() assumes that we will read up to the next
@@ -213,9 +223,18 @@ xf86getNextLine(void)
/* read in another block of chars */
do {
- ret = fgets(configBuf + pos, configBufLen - pos - 1, configFile);
+ ret = fgets(configBuf + pos, configBufLen - pos - 1,
+ configFiles[curFileIndex].file);
- if (!ret) break;
+ if (!ret) {
+ /* stop if there are no more files */
+ if (++curFileIndex >= numFiles) {
+ curFileIndex = 0;
+ break;
+ }
+ configLineNo = 0;
+ continue;
+ }
/* search for EOL in the new block of chars */
@@ -306,7 +325,7 @@ again:
if (!c)
{
char *ret;
- if (configFile)
+ if (numFiles > 0)
ret = xf86getNextLine();
else {
if (builtinConfig[builtinIndex] == NULL)
@@ -575,6 +594,12 @@ xf86pathIsSafe(const char *path)
#ifndef XCONFIGFILE
#define XCONFIGFILE "xorg.conf"
#endif
+#ifndef XCONFIGDIR
+#define XCONFIGDIR "xorg.conf.d"
+#endif
+#ifndef XCONFIGSUFFIX
+#define XCONFIGSUFFIX ".conf"
+#endif
#ifndef PROJECTROOT
#define PROJECTROOT "/usr/X11R6"
#endif
@@ -616,7 +641,8 @@ xf86pathIsSafe(const char *path)
static char *
DoSubstitution(const char *template, const char *cmdline, const char *projroot,
- int *cmdlineUsed, int *envUsed, char *XConfigFile)
+ int *cmdlineUsed, int *envUsed,
+ const char *XConfigFile)
{
char *result;
int i, l;
@@ -745,7 +771,164 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
return result;
}
-/*
+/*
+ * Given some searching parameters, locate and open the xorg config file.
+ */
+static char *
+OpenConfigFile(const char *path, const char *cmdline, const char *projroot,
+ const char *confname)
+{
+ char *filepath = NULL;
+ char *pathcopy;
+ const char *template;
+ int cmdlineUsed = 0;
+ FILE *file = NULL;
+
+ pathcopy = strdup(path);
+ for (template = strtok(pathcopy, ","); template && !file;
+ template = strtok(NULL, ",")) {
+ filepath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL, confname);
+ if (!filepath)
+ continue;
+ if (cmdline && !cmdlineUsed) {
+ free(filepath);
+ filepath = NULL;
+ continue;
+ }
+ file = fopen(filepath, "r");
+ if (!file) {
+ free(filepath);
+ filepath = NULL;
+ }
+ }
+
+ if (file) {
+ configFiles[numFiles].file = file;
+ configFiles[numFiles].path = strdup(filepath);
+ numFiles++;
+ }
+ return filepath;
+}
+
+/*
+ * Match non-hidden files in the xorg config directory with a .conf
+ * suffix. This filter is passed to scandir(3).
+ */
+static int
+ConfigFilter(const struct dirent *de)
+{
+ const char *name = de->d_name;
+ size_t len = strlen(name);
+ size_t suflen = strlen(XCONFIGSUFFIX);
+
+ if (!name || name[0] == '.' || len <= suflen)
+ return 0;
+ if (strcmp(&name[len-suflen], XCONFIGSUFFIX) != 0)
+ return 0;
+ return 1;
+}
+
+static Bool
+AddConfigDirFiles(const char *dirpath, struct dirent **list, int num)
+{
+ int i;
+ Bool openedFile = FALSE;
+ Bool warnOnce = FALSE;
+
+ for (i = 0; i < num; i++) {
+ char *path;
+ FILE *file;
+
+ if (numFiles >= CONFIG_MAX_FILES) {
+ if (!warnOnce) {
+ ErrorF("Maximum number of configuration "
+ "files opened\n");
+ warnOnce = TRUE;
+ }
+ free(list[i]);
+ continue;
+ }
+
+ path = malloc(PATH_MAX + 1);
+ snprintf(path, PATH_MAX + 1, "%s/%s", dirpath,
+ list[i]->d_name);
+ free(list[i]);
+ file = fopen(path, "r");
+ if (!file) {
+ free(path);
+ continue;
+ }
+ openedFile = TRUE;
+
+ configFiles[numFiles].file = file;
+ configFiles[numFiles].path = path;
+ numFiles++;
+ }
+
+ return openedFile;
+}
+
+/*
+ * Given some searching parameters, locate and open the xorg config
+ * directory. The directory does not need to contain config files.
+ */
+static char *
+OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
+ const char *confname)
+{
+ char *dirpath, *pathcopy;
+ const char *template;
+ Bool found = FALSE;
+ int cmdlineUsed = 0;
+
+ pathcopy = strdup(path);
+ for (template = strtok(pathcopy, ","); template && !found;
+ template = strtok(NULL, ",")) {
+ struct dirent **list = NULL;
+ int num;
+
+ dirpath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL, confname);
+ if (!dirpath)
+ continue;
+ if (cmdline && !cmdlineUsed) {
+ free(dirpath);
+ dirpath = NULL;
+ continue;
+ }
+
+ /* match files named *.conf */
+ num = scandir(dirpath, &list, ConfigFilter, alphasort);
+ found = AddConfigDirFiles(dirpath, list, num);
+ if (!found) {
+ free(dirpath);
+ dirpath = NULL;
+ if (list)
+ free(list);
+ }
+ }
+
+ return dirpath;
+}
+
+/*
+ * xf86initConfigFiles -- Setup global variables and buffers.
+ */
+void
+xf86initConfigFiles(void)
+{
+ curFileIndex = 0;
+ configPos = 0;
+ configLineNo = 0;
+ pushToken = LOCK_TOKEN;
+
+ configBuf = malloc(CONFIG_BUF_LEN);
+ configRBuf = malloc(CONFIG_BUF_LEN);
+ configBuf[0] = '\0'; /* sanity ... */
+}
+
+/*
* xf86openConfigFile --
*
* This function take a config file search path (optional), a command-line
@@ -758,7 +941,7 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
* opened. When no file is found, the return value is NULL.
*
* The escape sequences allowed in the search path are defined above.
- *
+ *
*/
#ifndef DEFAULT_CONF_PATH
@@ -780,117 +963,90 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
const char *
xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
{
- char *pathcopy;
- const char *template;
- int cmdlineUsed = 0;
-
- configFile = NULL;
- configPos = 0; /* current readers position */
- configLineNo = 0; /* linenumber */
- pushToken = LOCK_TOKEN;
-
if (!path || !path[0])
path = DEFAULT_CONF_PATH;
- pathcopy = malloc(strlen(path) + 1);
- strcpy(pathcopy, path);
if (!projroot || !projroot[0])
projroot = PROJECTROOT;
- template = strtok(pathcopy, ",");
-
- /* First, search for a config file. */
- while (template && !configFile) {
- if ((configPath = DoSubstitution(template, cmdline, projroot,
- &cmdlineUsed, NULL,
- XCONFIGFILE))) {
- if ((configFile = fopen(configPath, "r")) != 0) {
- if (cmdline && !cmdlineUsed) {
- fclose(configFile);
- configFile = NULL;
- }
- }
- }
- if (configPath && !configFile) {
- free(configPath);
- configPath = NULL;
- }
- template = strtok(NULL, ",");
- }
-
- /* Then search for fallback */
- if (!configFile) {
- strcpy(pathcopy, path);
- template = strtok(pathcopy, ",");
-
- while (template && !configFile) {
- if ((configPath = DoSubstitution(template, cmdline, projroot,
- &cmdlineUsed, NULL,
- XFREE86CFGFILE))) {
- if ((configFile = fopen(configPath, "r")) != 0) {
- if (cmdline && !cmdlineUsed) {
- fclose(configFile);
- configFile = NULL;
- }
- }
- }
- if (configPath && !configFile) {
- free(configPath);
- configPath = NULL;
- }
- template = strtok(NULL, ",");
- }
- }
-
- free(pathcopy);
- if (!configFile) {
-
- return NULL;
- }
+ /* Search for a config file or a fallback */
+ configPath = OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
+ if (!configPath)
+ configPath = OpenConfigFile(path, cmdline, projroot,
+ XFREE86CFGFILE);
+ return configPath;
+}
- configBuf = malloc (CONFIG_BUF_LEN);
- configRBuf = malloc (CONFIG_BUF_LEN);
- configBuf[0] = '\0'; /* sanity ... */
+/*
+ * xf86openConfigDirFiles --
+ *
+ * This function take a config directory search path (optional), a
+ * command-line specified directory name (optional) and the ProjectRoot path
+ * (optional) and locates and opens a config directory based on that
+ * information. If a command-line name is specified, then this function
+ * fails if it is not found.
+ *
+ * The return value is a pointer to the actual name of the direcoty that was
+ * opened. When no directory is found, the return value is NULL.
+ *
+ * The escape sequences allowed in the search path are defined above.
+ *
+ */
+const char *
+xf86openConfigDirFiles(const char *path, const char *cmdline,
+ const char *projroot)
+{
+ if (!path || !path[0])
+ path = DEFAULT_CONF_PATH;
+ if (!projroot || !projroot[0])
+ projroot = PROJECTROOT;
- return configPath;
+ /* Search for the multiconf directory */
+ configDirPath = OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
+ return configDirPath;
}
void
xf86closeConfigFile (void)
{
+ int i;
+
free (configPath);
configPath = NULL;
+ free (configDirPath);
+ configDirPath = NULL;
free (configRBuf);
configRBuf = NULL;
free (configBuf);
configBuf = NULL;
- if (configFile) {
- fclose (configFile);
- configFile = NULL;
- } else {
+ if (numFiles == 0) {
builtinConfig = NULL;
builtinIndex = 0;
}
+ for (i = 0; i < numFiles; i++) {
+ fclose(configFiles[i].file);
+ configFiles[i].file = NULL;
+ free(configFiles[i].path);
+ configFiles[i].path = NULL;
+ }
+ numFiles = 0;
}
void
xf86setBuiltinConfig(const char *config[])
{
builtinConfig = config;
- configPath = strdup("<builtin configuration>");
- configBuf = malloc (CONFIG_BUF_LEN);
- configRBuf = malloc (CONFIG_BUF_LEN);
- configBuf[0] = '\0'; /* sanity ... */
-
}
void
xf86parseError (char *format,...)
{
va_list ap;
+ char *filename = numFiles ? configFiles[curFileIndex].path :
+ "<builtin configuration>";
ErrorF ("Parse error on line %d of section %s in file %s\n\t",
- configLineNo, configSection, configPath);
+ configLineNo, configSection, filename);
va_start (ap, format);
VErrorF (format, ap);
va_end (ap);
@@ -902,8 +1058,10 @@ void
xf86validationError (char *format,...)
{
va_list ap;
+ char *filename = numFiles ? configFiles[curFileIndex].path :
+ "<builtin configuration>";
- ErrorF ("Data incomplete in file %s\n\t", configPath);
+ ErrorF ("Data incomplete in file %s\n\t", filename);
va_start (ap, format);
VErrorF (format, ap);
va_end (ap);
@@ -1028,3 +1186,33 @@ xf86addComment(char *cur, char *add)
return (cur);
}
+
+Bool
+xf86getBoolValue(Bool *val, const char *str)
+{
+ if (!val || !str)
+ return FALSE;
+ if (*str == '\0') {
+ *val = TRUE;
+ } else {
+ if (strcmp(str, "1") == 0)
+ *val = TRUE;
+ else if (strcmp(str, "on") == 0)
+ *val = TRUE;
+ else if (strcmp(str, "true") == 0)
+ *val = TRUE;
+ else if (strcmp(str, "yes") == 0)
+ *val = TRUE;
+ else if (strcmp(str, "0") == 0)
+ *val = FALSE;
+ else if (strcmp(str, "off") == 0)
+ *val = FALSE;
+ else if (strcmp(str, "false") == 0)
+ *val = FALSE;
+ else if (strcmp(str, "no") == 0)
+ *val = FALSE;
+ else
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/parser/write.c b/xorg-server/hw/xfree86/parser/write.c
index 3b77b9314..083203c05 100644
--- a/xorg-server/hw/xfree86/parser/write.c
+++ b/xorg-server/hw/xfree86/parser/write.c
@@ -117,6 +117,8 @@ doWriteConfigFile (const char *filename, XF86ConfigPtr cptr)
xf86printInputSection (cf, cptr->conf_input_lst);
+ xf86printInputClassSection (cf, cptr->conf_inputclass_lst);
+
xf86printVideoAdaptorSection (cf, cptr->conf_videoadaptor_lst);
xf86printModesSection (cf, cptr->conf_modes_lst);
diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h
index 603080066..5e8351fc4 100644
--- a/xorg-server/hw/xfree86/parser/xf86Parser.h
+++ b/xorg-server/hw/xfree86/parser/xf86Parser.h
@@ -64,6 +64,7 @@
#ifndef _xf86Parser_h_
#define _xf86Parser_h_
+#include <X11/Xdefs.h>
#include "xf86Optrec.h"
#define HAVE_PARSER_DECLS
@@ -330,6 +331,32 @@ typedef struct
}
XF86ConfInputrefRec, *XF86ConfInputrefPtr;
+typedef struct
+{
+ Bool set;
+ Bool val;
+}
+xf86TriState;
+
+typedef struct
+{
+ GenericListRec list;
+ char *identifier;
+ char *driver;
+ char *match_product;
+ char *match_vendor;
+ char *match_device;
+ xf86TriState is_keyboard;
+ xf86TriState is_pointer;
+ xf86TriState is_joystick;
+ xf86TriState is_tablet;
+ xf86TriState is_touchpad;
+ xf86TriState is_touchscreen;
+ XF86OptionPtr option_lst;
+ char *comment;
+}
+XF86ConfInputClassRec, *XF86ConfInputClassPtr;
+
/* Values for adj_where */
#define CONF_ADJ_OBSOLETE -1
#define CONF_ADJ_ABSOLUTE 0
@@ -438,6 +465,7 @@ typedef struct
XF86ConfDevicePtr conf_device_lst;
XF86ConfScreenPtr conf_screen_lst;
XF86ConfInputPtr conf_input_lst;
+ XF86ConfInputClassPtr conf_inputclass_lst;
XF86ConfLayoutPtr conf_layout_lst;
XF86ConfVendorPtr conf_vendor_lst;
XF86ConfDRIPtr conf_dri;
@@ -456,13 +484,16 @@ xf86ConfigSymTabRec, *xf86ConfigSymTabPtr;
/*
* prototypes for public functions
*/
-extern _X_EXPORT const char *xf86openConfigFile (const char *, const char *,
- const char *);
-extern _X_EXPORT void xf86setBuiltinConfig(const char *config[]);
-extern _X_EXPORT XF86ConfigPtr xf86readConfigFile (void);
-extern _X_EXPORT void xf86closeConfigFile (void);
-extern _X_EXPORT void xf86freeConfig (XF86ConfigPtr p);
-extern _X_EXPORT int xf86writeConfigFile (const char *, XF86ConfigPtr);
+extern void xf86initConfigFiles(void);
+extern const char *xf86openConfigFile(const char *path, const char *cmdline,
+ const char *projroot);
+extern const char *xf86openConfigDirFiles(const char *path, const char *cmdline,
+ const char *projroot);
+extern void xf86setBuiltinConfig(const char *config[]);
+extern XF86ConfigPtr xf86readConfigFile(void);
+extern void xf86closeConfigFile(void);
+extern void xf86freeConfig(XF86ConfigPtr p);
+extern int xf86writeConfigFile(const char *, XF86ConfigPtr);
extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p);
extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list);
extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p);
@@ -473,6 +504,7 @@ extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInput
extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p);
extern _X_EXPORT XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident,
XF86ConfVideoAdaptorPtr p);
+extern int xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout);
extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new);
extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2);
@@ -480,5 +512,6 @@ extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr li
extern _X_EXPORT int xf86pathIsAbsolute(const char *path);
extern _X_EXPORT int xf86pathIsSafe(const char *path);
extern _X_EXPORT char *xf86addComment(char *cur, char *add);
+extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str);
#endif /* _xf86Parser_h_ */
diff --git a/xorg-server/hw/xfree86/parser/xf86tokens.h b/xorg-server/hw/xfree86/parser/xf86tokens.h
index 4c1d38c03..e3a9d716b 100644
--- a/xorg-server/hw/xfree86/parser/xf86tokens.h
+++ b/xorg-server/hw/xfree86/parser/xf86tokens.h
@@ -273,7 +273,18 @@ typedef enum {
/* DRI Tokens */
GROUP,
- BUFFERS
+ BUFFERS,
+
+ /* InputClass Tokens */
+ MATCH_PRODUCT,
+ MATCH_VENDOR,
+ MATCH_DEVICE_PATH,
+ MATCH_IS_KEYBOARD,
+ MATCH_IS_POINTER,
+ MATCH_IS_JOYSTICK,
+ MATCH_IS_TABLET,
+ MATCH_IS_TOUCHPAD,
+ MATCH_IS_TOUCHSCREEN
} ParserTokens;
#endif /* _xf86_tokens_h */
diff --git a/xorg-server/hw/xquartz/GL/glcontextmodes.c b/xorg-server/hw/xquartz/GL/glcontextmodes.c
new file mode 100644
index 000000000..326c8b235
--- /dev/null
+++ b/xorg-server/hw/xquartz/GL/glcontextmodes.c
@@ -0,0 +1,550 @@
+/*
+ * (C) Copyright IBM Corporation 2003
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file glcontextmodes.c
+ * Utility routines for working with \c __GLcontextModes structures. At
+ * some point most or all of these functions will be moved to the Mesa
+ * code base.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#if defined(IN_MINI_GLX)
+#include <GL/gl.h>
+#else
+#if defined(HAVE_DIX_CONFIG_H)
+# include <dix-config.h>
+#endif
+#include <X11/X.h>
+#include <GL/glx.h>
+#include "GL/glxint.h"
+#endif
+
+/* Memory macros */
+#if defined(IN_MINI_GLX)
+# include <stdlib.h>
+# include <string.h>
+# define _mesa_malloc(b) malloc(b)
+# define _mesa_free(m) free(m)
+# define _mesa_memset memset
+#else
+# ifdef XFree86Server
+# include <os.h>
+# include <string.h>
+# define _mesa_malloc(b) xalloc(b)
+# define _mesa_free(m) xfree(m)
+# define _mesa_memset memset
+# else
+# include <X11/Xlibint.h>
+# define _mesa_memset memset
+# define _mesa_malloc(b) Xmalloc(b)
+# define _mesa_free(m) Xfree(m)
+# endif /* XFree86Server */
+#endif /* !defined(IN_MINI_GLX) */
+
+#include "glcontextmodes.h"
+
+#if !defined(IN_MINI_GLX)
+#define NUM_VISUAL_TYPES 6
+
+/**
+ * Convert an X visual type to a GLX visual type.
+ *
+ * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.)
+ * to be converted.
+ * \return If \c visualType is a valid X visual type, a GLX visual type will
+ * be returned. Otherwise \c GLX_NONE will be returned.
+ */
+GLint
+_gl_convert_from_x_visual_type( int visualType )
+{
+ static const int glx_visual_types[ NUM_VISUAL_TYPES ] = {
+ GLX_STATIC_GRAY, GLX_GRAY_SCALE,
+ GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
+ GLX_TRUE_COLOR, GLX_DIRECT_COLOR
+ };
+
+ return ( (unsigned) visualType < NUM_VISUAL_TYPES )
+ ? glx_visual_types[ visualType ] : GLX_NONE;
+}
+
+
+/**
+ * Convert a GLX visual type to an X visual type.
+ *
+ * \param visualType GLX visual type (i.e., \c GLX_TRUE_COLOR,
+ * \c GLX_STATIC_GRAY, etc.) to be converted.
+ * \return If \c visualType is a valid GLX visual type, an X visual type will
+ * be returned. Otherwise -1 will be returned.
+ */
+GLint
+_gl_convert_to_x_visual_type( int visualType )
+{
+ static const int x_visual_types[ NUM_VISUAL_TYPES ] = {
+ TrueColor, DirectColor,
+ PseudoColor, StaticColor,
+ GrayScale, StaticGray
+ };
+
+ return ( (unsigned) (visualType - GLX_TRUE_COLOR) < NUM_VISUAL_TYPES )
+ ? x_visual_types[ visualType - GLX_TRUE_COLOR ] : -1;
+}
+
+
+/**
+ * Copy a GLX visual config structure to a GL context mode structure. All
+ * of the fields in \c config are copied to \c mode. Additional fields in
+ * \c mode that can be derrived from the fields of \c config (i.e.,
+ * \c haveDepthBuffer) are also filled in. The remaining fields in \c mode
+ * that cannot be derived are set to default values.
+ *
+ * \param mode Destination GL context mode.
+ * \param config Source GLX visual config.
+ *
+ * \note
+ * The \c fbconfigID and \c visualID fields of the \c __GLcontextModes
+ * structure will be set to the \c vid of the \c __GLXvisualConfig structure.
+ */
+void
+_gl_copy_visual_to_context_mode( __GLcontextModes * mode,
+ const __GLXvisualConfig * config )
+{
+ __GLcontextModes * const next = mode->next;
+
+ (void) _mesa_memset( mode, 0, sizeof( __GLcontextModes ) );
+ mode->next = next;
+
+ mode->visualID = config->vid;
+ mode->visualType = _gl_convert_from_x_visual_type( config->class );
+ mode->xRenderable = GL_TRUE;
+ mode->fbconfigID = config->vid;
+ mode->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
+
+ mode->rgbMode = (config->rgba != 0);
+ mode->renderType = (mode->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+
+ mode->colorIndexMode = !(mode->rgbMode);
+ mode->doubleBufferMode = (config->doubleBuffer != 0);
+ mode->stereoMode = (config->stereo != 0);
+
+ mode->haveAccumBuffer = ((config->accumRedSize +
+ config->accumGreenSize +
+ config->accumBlueSize +
+ config->accumAlphaSize) > 0);
+ mode->haveDepthBuffer = (config->depthSize > 0);
+ mode->haveStencilBuffer = (config->stencilSize > 0);
+
+ mode->redBits = config->redSize;
+ mode->greenBits = config->greenSize;
+ mode->blueBits = config->blueSize;
+ mode->alphaBits = config->alphaSize;
+ mode->redMask = config->redMask;
+ mode->greenMask = config->greenMask;
+ mode->blueMask = config->blueMask;
+ mode->alphaMask = config->alphaMask;
+ mode->rgbBits = mode->rgbMode ? config->bufferSize : 0;
+ mode->indexBits = mode->colorIndexMode ? config->bufferSize : 0;
+
+ mode->accumRedBits = config->accumRedSize;
+ mode->accumGreenBits = config->accumGreenSize;
+ mode->accumBlueBits = config->accumBlueSize;
+ mode->accumAlphaBits = config->accumAlphaSize;
+ mode->depthBits = config->depthSize;
+ mode->stencilBits = config->stencilSize;
+
+ mode->numAuxBuffers = config->auxBuffers;
+ mode->level = config->level;
+
+ mode->visualRating = config->visualRating;
+ mode->transparentPixel = config->transparentPixel;
+ mode->transparentRed = config->transparentRed;
+ mode->transparentGreen = config->transparentGreen;
+ mode->transparentBlue = config->transparentBlue;
+ mode->transparentAlpha = config->transparentAlpha;
+ mode->transparentIndex = config->transparentIndex;
+ mode->samples = config->multiSampleSize;
+ mode->sampleBuffers = config->nMultiSampleBuffers;
+ /* mode->visualSelectGroup = config->visualSelectGroup; ? */
+
+ mode->swapMethod = GLX_SWAP_UNDEFINED_OML;
+
+ mode->bindToTextureRgb = (mode->rgbMode) ? GL_TRUE : GL_FALSE;
+ mode->bindToTextureRgba = (mode->rgbMode && mode->alphaBits) ?
+ GL_TRUE : GL_FALSE;
+ mode->bindToMipmapTexture = mode->rgbMode ? GL_TRUE : GL_FALSE;
+ mode->bindToTextureTargets = mode->rgbMode ?
+ GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT |
+ GLX_TEXTURE_RECTANGLE_BIT_EXT : 0;
+ mode->yInverted = GL_FALSE;
+}
+
+
+/**
+ * Get data from a GL context mode.
+ *
+ * \param mode GL context mode whose data is to be returned.
+ * \param attribute Attribute of \c mode that is to be returned.
+ * \param value_return Location to store the data member of \c mode.
+ * \return If \c attribute is a valid attribute of \c mode, zero is
+ * returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned.
+ */
+int
+_gl_get_context_mode_data(const __GLcontextModes *mode, int attribute,
+ int *value_return)
+{
+ switch (attribute) {
+ case GLX_USE_GL:
+ *value_return = GL_TRUE;
+ return 0;
+ case GLX_BUFFER_SIZE:
+ *value_return = mode->rgbBits;
+ return 0;
+ case GLX_RGBA:
+ *value_return = mode->rgbMode;
+ return 0;
+ case GLX_RED_SIZE:
+ *value_return = mode->redBits;
+ return 0;
+ case GLX_GREEN_SIZE:
+ *value_return = mode->greenBits;
+ return 0;
+ case GLX_BLUE_SIZE:
+ *value_return = mode->blueBits;
+ return 0;
+ case GLX_ALPHA_SIZE:
+ *value_return = mode->alphaBits;
+ return 0;
+ case GLX_DOUBLEBUFFER:
+ *value_return = mode->doubleBufferMode;
+ return 0;
+ case GLX_STEREO:
+ *value_return = mode->stereoMode;
+ return 0;
+ case GLX_AUX_BUFFERS:
+ *value_return = mode->numAuxBuffers;
+ return 0;
+ case GLX_DEPTH_SIZE:
+ *value_return = mode->depthBits;
+ return 0;
+ case GLX_STENCIL_SIZE:
+ *value_return = mode->stencilBits;
+ return 0;
+ case GLX_ACCUM_RED_SIZE:
+ *value_return = mode->accumRedBits;
+ return 0;
+ case GLX_ACCUM_GREEN_SIZE:
+ *value_return = mode->accumGreenBits;
+ return 0;
+ case GLX_ACCUM_BLUE_SIZE:
+ *value_return = mode->accumBlueBits;
+ return 0;
+ case GLX_ACCUM_ALPHA_SIZE:
+ *value_return = mode->accumAlphaBits;
+ return 0;
+ case GLX_LEVEL:
+ *value_return = mode->level;
+ return 0;
+ case GLX_TRANSPARENT_TYPE_EXT:
+ *value_return = mode->transparentPixel;
+ return 0;
+ case GLX_TRANSPARENT_RED_VALUE:
+ *value_return = mode->transparentRed;
+ return 0;
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ *value_return = mode->transparentGreen;
+ return 0;
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ *value_return = mode->transparentBlue;
+ return 0;
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ *value_return = mode->transparentAlpha;
+ return 0;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ *value_return = mode->transparentIndex;
+ return 0;
+ case GLX_X_VISUAL_TYPE:
+ *value_return = mode->visualType;
+ return 0;
+ case GLX_CONFIG_CAVEAT:
+ *value_return = mode->visualRating;
+ return 0;
+ case GLX_VISUAL_ID:
+ *value_return = mode->visualID;
+ return 0;
+ case GLX_DRAWABLE_TYPE:
+ *value_return = mode->drawableType;
+ return 0;
+ case GLX_RENDER_TYPE:
+ *value_return = mode->renderType;
+ return 0;
+ case GLX_X_RENDERABLE:
+ *value_return = mode->xRenderable;
+ return 0;
+ case GLX_FBCONFIG_ID:
+ *value_return = mode->fbconfigID;
+ return 0;
+ case GLX_MAX_PBUFFER_WIDTH:
+ *value_return = mode->maxPbufferWidth;
+ return 0;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ *value_return = mode->maxPbufferHeight;
+ return 0;
+ case GLX_MAX_PBUFFER_PIXELS:
+ *value_return = mode->maxPbufferPixels;
+ return 0;
+ case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
+ *value_return = mode->optimalPbufferWidth;
+ return 0;
+ case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
+ *value_return = mode->optimalPbufferHeight;
+ return 0;
+ case GLX_SWAP_METHOD_OML:
+ *value_return = mode->swapMethod;
+ return 0;
+ case GLX_SAMPLE_BUFFERS_SGIS:
+ *value_return = mode->sampleBuffers;
+ return 0;
+ case GLX_SAMPLES_SGIS:
+ *value_return = mode->samples;
+ return 0;
+ case GLX_BIND_TO_TEXTURE_RGB_EXT:
+ *value_return = mode->bindToTextureRgb;
+ return 0;
+ case GLX_BIND_TO_TEXTURE_RGBA_EXT:
+ *value_return = mode->bindToTextureRgba;
+ return 0;
+ case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
+ *value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE :
+ GL_FALSE;
+ return 0;
+ case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
+ *value_return = mode->bindToTextureTargets;
+ return 0;
+ case GLX_Y_INVERTED_EXT:
+ *value_return = mode->yInverted;
+ return 0;
+
+ /* Applications are NOT allowed to query GLX_VISUAL_SELECT_GROUP_SGIX.
+ * It is ONLY for communication between the GLX client and the GLX
+ * server.
+ */
+ case GLX_VISUAL_SELECT_GROUP_SGIX:
+ default:
+ return GLX_BAD_ATTRIBUTE;
+ }
+}
+#endif /* !defined(IN_MINI_GLX) */
+
+
+/**
+ * Allocate a linked list of \c __GLcontextModes structures. The fields of
+ * each structure will be initialized to "reasonable" default values. In
+ * most cases this is the default value defined by table 3.4 of the GLX
+ * 1.3 specification. This means that most values are either initialized to
+ * zero or \c GLX_DONT_CARE (which is -1). As support for additional
+ * extensions is added, the new values will be initialized to appropriate
+ * values from the extension specification.
+ *
+ * \param count Number of structures to allocate.
+ * \param minimum_size Minimum size of a structure to allocate. This allows
+ * for differences in the version of the
+ * \c __GLcontextModes stucture used in libGL and in a
+ * DRI-based driver.
+ * \returns A pointer to the first element in a linked list of \c count
+ * stuctures on success, or \c NULL on failure.
+ *
+ * \warning Use of \c minimum_size does \b not guarantee binary compatibility.
+ * The fundamental assumption is that if the \c minimum_size
+ * specified by the driver and the size of the \c __GLcontextModes
+ * structure in libGL is the same, then the meaning of each byte in
+ * the structure is the same in both places. \b Be \b careful!
+ * Basically this means that fields have to be added in libGL and
+ * then propagated to drivers. Drivers should \b never arbitrarilly
+ * extend the \c __GLcontextModes data-structure.
+ */
+__GLcontextModes *
+_gl_context_modes_create( unsigned count, size_t minimum_size )
+{
+ const size_t size = (minimum_size > sizeof( __GLcontextModes ))
+ ? minimum_size : sizeof( __GLcontextModes );
+ __GLcontextModes * base = NULL;
+ __GLcontextModes ** next;
+ unsigned i;
+
+ next = & base;
+ for ( i = 0 ; i < count ; i++ ) {
+ *next = (__GLcontextModes *) _mesa_malloc( size );
+ if ( *next == NULL ) {
+ _gl_context_modes_destroy( base );
+ base = NULL;
+ break;
+ }
+
+ (void) _mesa_memset( *next, 0, size );
+ (*next)->visualID = GLX_DONT_CARE;
+ (*next)->visualType = GLX_DONT_CARE;
+ (*next)->visualRating = GLX_NONE;
+ (*next)->transparentPixel = GLX_NONE;
+ (*next)->transparentRed = GLX_DONT_CARE;
+ (*next)->transparentGreen = GLX_DONT_CARE;
+ (*next)->transparentBlue = GLX_DONT_CARE;
+ (*next)->transparentAlpha = GLX_DONT_CARE;
+ (*next)->transparentIndex = GLX_DONT_CARE;
+ (*next)->xRenderable = GLX_DONT_CARE;
+ (*next)->fbconfigID = GLX_DONT_CARE;
+ (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML;
+ (*next)->bindToTextureRgb = GLX_DONT_CARE;
+ (*next)->bindToTextureRgba = GLX_DONT_CARE;
+ (*next)->bindToMipmapTexture = GLX_DONT_CARE;
+ (*next)->bindToTextureTargets = GLX_DONT_CARE;
+ (*next)->yInverted = GLX_DONT_CARE;
+
+ next = & ((*next)->next);
+ }
+
+ return base;
+}
+
+
+/**
+ * Destroy a linked list of \c __GLcontextModes structures created by
+ * \c _gl_context_modes_create.
+ *
+ * \param modes Linked list of structures to be destroyed. All structres
+ * in the list will be freed.
+ */
+void
+_gl_context_modes_destroy( __GLcontextModes * modes )
+{
+ while ( modes != NULL ) {
+ __GLcontextModes * const next = modes->next;
+
+ _mesa_free( modes );
+ modes = next;
+ }
+}
+
+
+/**
+ * Find a context mode matching a Visual ID.
+ *
+ * \param modes List list of context-mode structures to be searched.
+ * \param vid Visual ID to be found.
+ * \returns A pointer to a context-mode in \c modes if \c vid was found in
+ * the list, or \c NULL if it was not.
+ */
+
+__GLcontextModes *
+_gl_context_modes_find_visual(__GLcontextModes *modes, int vid)
+{
+ __GLcontextModes *m;
+
+ for (m = modes; m != NULL; m = m->next)
+ if (m->visualID == vid)
+ return m;
+
+ return NULL;
+}
+
+__GLcontextModes *
+_gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid)
+{
+ __GLcontextModes *m;
+
+ for (m = modes; m != NULL; m = m->next)
+ if (m->fbconfigID == fbid)
+ return m;
+
+ return NULL;
+}
+
+/**
+ * Determine if two context-modes are the same. This is intended to be used
+ * by libGL implementations to compare to sets of driver generated FBconfigs.
+ *
+ * \param a Context-mode to be compared.
+ * \param b Context-mode to be compared.
+ * \returns \c GL_TRUE if the two context-modes are the same. \c GL_FALSE is
+ * returned otherwise.
+ */
+GLboolean
+_gl_context_modes_are_same( const __GLcontextModes * a,
+ const __GLcontextModes * b )
+{
+ return( (a->rgbMode == b->rgbMode) &&
+ (a->floatMode == b->floatMode) &&
+ (a->colorIndexMode == b->colorIndexMode) &&
+ (a->doubleBufferMode == b->doubleBufferMode) &&
+ (a->stereoMode == b->stereoMode) &&
+ (a->redBits == b->redBits) &&
+ (a->greenBits == b->greenBits) &&
+ (a->blueBits == b->blueBits) &&
+ (a->alphaBits == b->alphaBits) &&
+#if 0 /* For some reason these don't get set on the client-side in libGL. */
+ (a->redMask == b->redMask) &&
+ (a->greenMask == b->greenMask) &&
+ (a->blueMask == b->blueMask) &&
+ (a->alphaMask == b->alphaMask) &&
+#endif
+ (a->rgbBits == b->rgbBits) &&
+ (a->indexBits == b->indexBits) &&
+ (a->accumRedBits == b->accumRedBits) &&
+ (a->accumGreenBits == b->accumGreenBits) &&
+ (a->accumBlueBits == b->accumBlueBits) &&
+ (a->accumAlphaBits == b->accumAlphaBits) &&
+ (a->depthBits == b->depthBits) &&
+ (a->stencilBits == b->stencilBits) &&
+ (a->numAuxBuffers == b->numAuxBuffers) &&
+ (a->level == b->level) &&
+ (a->pixmapMode == b->pixmapMode) &&
+ (a->visualRating == b->visualRating) &&
+
+ (a->transparentPixel == b->transparentPixel) &&
+
+ ((a->transparentPixel != GLX_TRANSPARENT_RGB) ||
+ ((a->transparentRed == b->transparentRed) &&
+ (a->transparentGreen == b->transparentGreen) &&
+ (a->transparentBlue == b->transparentBlue) &&
+ (a->transparentAlpha == b->transparentAlpha))) &&
+
+ ((a->transparentPixel != GLX_TRANSPARENT_INDEX) ||
+ (a->transparentIndex == b->transparentIndex)) &&
+
+ (a->sampleBuffers == b->sampleBuffers) &&
+ (a->samples == b->samples) &&
+ ((a->drawableType & b->drawableType) != 0) &&
+ (a->renderType == b->renderType) &&
+ (a->maxPbufferWidth == b->maxPbufferWidth) &&
+ (a->maxPbufferHeight == b->maxPbufferHeight) &&
+ (a->maxPbufferPixels == b->maxPbufferPixels) &&
+ (a->optimalPbufferWidth == b->optimalPbufferWidth) &&
+ (a->optimalPbufferHeight == b->optimalPbufferHeight) &&
+ (a->swapMethod == b->swapMethod) &&
+ (a->bindToTextureRgb == b->bindToTextureRgb) &&
+ (a->bindToTextureRgba == b->bindToTextureRgba) &&
+ (a->bindToMipmapTexture == b->bindToMipmapTexture) &&
+ (a->bindToTextureTargets == b->bindToTextureTargets) &&
+ (a->yInverted == b->yInverted) );
+}
diff --git a/xorg-server/hw/xquartz/GL/glcontextmodes.h b/xorg-server/hw/xquartz/GL/glcontextmodes.h
new file mode 100644
index 000000000..afd09cd7f
--- /dev/null
+++ b/xorg-server/hw/xquartz/GL/glcontextmodes.h
@@ -0,0 +1,54 @@
+/*
+ * (C) Copyright IBM Corporation 2003
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file glcontextmodes.h
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#ifndef GLCONTEXTMODES_H
+#define GLCONTEXTMODES_H
+
+#include "GL/internal/glcore.h"
+
+#if !defined(IN_MINI_GLX)
+extern GLint _gl_convert_from_x_visual_type( int visualType );
+extern GLint _gl_convert_to_x_visual_type( int visualType );
+extern void _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
+ const __GLXvisualConfig * config );
+extern int _gl_get_context_mode_data( const __GLcontextModes *mode,
+ int attribute, int *value_return );
+#endif /* !defined(IN_MINI_GLX) */
+
+extern __GLcontextModes * _gl_context_modes_create( unsigned count,
+ size_t minimum_size );
+extern void _gl_context_modes_destroy( __GLcontextModes * modes );
+extern __GLcontextModes *
+ _gl_context_modes_find_visual(__GLcontextModes *modes, int vid);
+extern __GLcontextModes *
+ _gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid);
+extern GLboolean _gl_context_modes_are_same( const __GLcontextModes * a,
+ const __GLcontextModes * b );
+
+#endif /* GLCONTEXTMODES_H */
diff --git a/xorg-server/hw/xquartz/darwinXinput.c b/xorg-server/hw/xquartz/darwinXinput.c
index 8af9fc740..43aea6140 100644
--- a/xorg-server/hw/xquartz/darwinXinput.c
+++ b/xorg-server/hw/xquartz/darwinXinput.c
@@ -230,7 +230,8 @@ ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
*
*/
int
-NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
+NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
+ DeviceIntPtr *pdev)
{
DEBUG_LOG("NewInputDeviceRequest(%p, %p)\n", options, pdev);
return BadValue;
diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c
index 6e7c73461..ecd7a9bc9 100644
--- a/xorg-server/hw/xwin/InitOutput.c
+++ b/xorg-server/hw/xwin/InitOutput.c
@@ -869,6 +869,9 @@ winUseMsg (void)
ErrorF ("-config\n"
"\tSpecify a configuration file.\n");
+ ErrorF ("-configdir\n"
+ "\tSpecify a configuration directory.\n");
+
ErrorF ("-keyboard\n"
"\tSpecify a keyboard device from the configuration file.\n");
#endif
diff --git a/xorg-server/hw/xwin/winconfig.c b/xorg-server/hw/xwin/winconfig.c
index 0350e968b..022176f62 100644
--- a/xorg-server/hw/xwin/winconfig.c
+++ b/xorg-server/hw/xwin/winconfig.c
@@ -1,1021 +1,1051 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Alexander Gottwald
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "winconfig.h"
-#include "winmsg.h"
-#include "globals.h"
-
-#include "xkbsrv.h"
-
-#ifdef XWIN_XF86CONFIG
-#ifndef CONFIGPATH
-#define CONFIGPATH "%A," "%R," \
- "/etc/X11/%R," "%P/etc/X11/%R," \
- "%E," "%F," \
- "/etc/X11/%F," "%P/etc/X11/%F," \
- "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
- "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
- "%P/etc/X11/%X," \
- "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
- "%P/lib/X11/%X"
-#endif
-
-XF86ConfigPtr g_xf86configptr = NULL;
-#endif
-
-WinCmdlineRec g_cmdline = {
-#ifdef XWIN_XF86CONFIG
- NULL, /* configFile */
-#endif
- NULL, /* fontPath */
-#ifdef XWIN_XF86CONFIG
- NULL, /* keyboard */
-#endif
- NULL, /* xkbRules */
- NULL, /* xkbModel */
- NULL, /* xkbLayout */
- NULL, /* xkbVariant */
- NULL, /* xkbOptions */
- NULL, /* screenname */
- NULL, /* mousename */
- FALSE, /* emulate3Buttons */
- 0 /* emulate3Timeout */
-};
-
-winInfoRec g_winInfo = {
- { /* keyboard */
- 0, /* leds */
- 500, /* delay */
- 30 /* rate */
- }
- ,
- { /* xkb */
- NULL, /* rules */
- NULL, /* model */
- NULL, /* layout */
- NULL, /* variant */
- NULL, /* options */
- }
- ,
- {
- FALSE,
- 50}
-};
-
-#define NULL_IF_EMPTY(x) (winNameCompare(x,"")?x:NULL)
-
-#ifdef XWIN_XF86CONFIG
-serverLayoutRec g_winConfigLayout;
-
-static Bool ParseOptionValue (int scrnIndex, pointer options,
- OptionInfoPtr p);
-static Bool configLayout (serverLayoutPtr, XF86ConfLayoutPtr, char *);
-static Bool configImpliedLayout (serverLayoutPtr, XF86ConfScreenPtr);
-static Bool GetBoolValue (OptionInfoPtr p, const char *s);
-
-
-Bool
-winReadConfigfile ()
-{
- Bool retval = TRUE;
- const char *filename;
- MessageType from = X_DEFAULT;
- char *xf86ConfigFile = NULL;
-
- if (g_cmdline.configFile)
- {
- from = X_CMDLINE;
- xf86ConfigFile = g_cmdline.configFile;
- }
-
- /* Parse config file into data structure */
-
- filename = xf86openConfigFile (CONFIGPATH, xf86ConfigFile, PROJECTROOT);
-
- /* Hack for backward compatibility */
- if (!filename && from == X_DEFAULT)
- filename = xf86openConfigFile (CONFIGPATH, "XF86Config", PROJECTROOT);
-
- if (filename)
- {
- winDebug ("Using config file: \"%s\"\n", filename);
- }
- else
- {
- ErrorF ("Unable to locate/open config file");
- if (xf86ConfigFile)
- ErrorF (": \"%s\"", xf86ConfigFile);
- ErrorF ("\n");
- return FALSE;
- }
- if ((g_xf86configptr = xf86readConfigFile ()) == NULL)
- {
- ErrorF ("Problem parsing the config file\n");
- return FALSE;
- }
- xf86closeConfigFile ();
-
- LogPrintMarkers();
-
- /* set options from data structure */
-
- if (g_xf86configptr->conf_layout_lst == NULL || g_cmdline.screenname != NULL)
- {
- if (g_cmdline.screenname == NULL)
- {
- winDebug ("No Layout section. Using the first Screen section.\n");
- }
- if (!configImpliedLayout (&g_winConfigLayout,
- g_xf86configptr->conf_screen_lst))
- {
- ErrorF ("Unable to determine the screen layout\n");
- return FALSE;
- }
- }
- else
- {
- /* Check if layout is given in the config file */
- if (g_xf86configptr->conf_flags != NULL)
- {
- char *dfltlayout = NULL;
- pointer optlist = g_xf86configptr->conf_flags->flg_option_lst;
-
- if (optlist && winFindOption (optlist, "defaultserverlayout"))
- dfltlayout =
- winSetStrOption (optlist, "defaultserverlayout", NULL);
-
- if (!configLayout (&g_winConfigLayout,
- g_xf86configptr->conf_layout_lst,
- dfltlayout))
- {
- ErrorF ("Unable to determine the screen layout\n");
- return FALSE;
- }
- }
- else
- {
- if (!configLayout (&g_winConfigLayout,
- g_xf86configptr->conf_layout_lst,
- NULL))
- {
- ErrorF ("Unable to determine the screen layout\n");
- return FALSE;
- }
- }
- }
-
- /* setup special config files */
- winConfigFiles ();
- return retval;
-}
-#endif
-
-/* load layout definitions */
-#include "winlayouts.h"
-
-/* Set the keyboard configuration */
-Bool
-winConfigKeyboard (DeviceIntPtr pDevice)
-{
- char layoutName[KL_NAMELENGTH];
- static unsigned int layoutNum = 0;
- int keyboardType;
-#ifdef XWIN_XF86CONFIG
- XF86ConfInputPtr kbd = NULL;
- XF86ConfInputPtr input_list = NULL;
- MessageType kbdfrom = X_CONFIG;
-#endif
- MessageType from = X_DEFAULT;
- char *s = NULL;
-
- /* Setup defaults */
- XkbGetRulesDflts(&g_winInfo.xkb);
-
- /*
- * Query the windows autorepeat settings and change the xserver defaults.
- */
- {
- int kbd_delay;
- DWORD kbd_speed;
- if (SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &kbd_delay, 0) &&
- SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &kbd_speed, 0))
- {
- switch (kbd_delay)
- {
- case 0: g_winInfo.keyboard.delay = 250; break;
- case 1: g_winInfo.keyboard.delay = 500; break;
- case 2: g_winInfo.keyboard.delay = 750; break;
- default:
- case 3: g_winInfo.keyboard.delay = 1000; break;
- }
- g_winInfo.keyboard.rate = (kbd_speed>0)?kbd_speed:1;
- winDebug("Setting autorepeat to delay=%d, rate=%d\n",
- g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
- }
- }
-
-
- keyboardType = GetKeyboardType (0);
- if (keyboardType > 0 && GetKeyboardLayoutName (layoutName))
- {
- WinKBLayoutPtr pLayout;
- Bool bfound = FALSE;
-
- if (! layoutNum)
- layoutNum = strtoul (layoutName, (char **)NULL, 16);
- if ((layoutNum & 0xffff) == 0x411) {
- /* The japanese layouts know a lot of different IMEs which all have
- different layout numbers set. Map them to a single entry.
- Same might apply for chinese, korean and other symbol languages
- too */
- layoutNum = (layoutNum & 0xffff);
- if (keyboardType == 7)
- {
- /* Japanese layouts have problems with key event messages
- such as the lack of WM_KEYUP for Caps Lock key.
- Loading US layout fixes this problem. */
- if (LoadKeyboardLayout("00000409", KLF_ACTIVATE) != NULL)
- winDebug("Loading US keyboard layout.\n");
- else
- ErrorF ("LoadKeyboardLaout failed.\n");
- }
- }
- winDebug ("winConfigKeyboard - Layout: \"%s\" (%08x) \n",
- layoutName, layoutNum);
-
- for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++)
- {
- if (pLayout->winlayout != layoutNum)
- continue;
- if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType)
- continue;
-
- bfound = TRUE;
- winDebug ("Using preset keyboard for \"%s\" (%x), type \"%d\"\n",
- pLayout->layoutname, pLayout->winlayout, keyboardType);
-
- g_winInfo.xkb.model = pLayout->xkbmodel;
- g_winInfo.xkb.layout = pLayout->xkblayout;
- g_winInfo.xkb.variant = pLayout->xkbvariant;
- g_winInfo.xkb.options = pLayout->xkboptions;
- break;
- }
-
- if (!bfound)
- {
- HKEY regkey = NULL;
- const char regtempl[] =
- "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\";
- char *regpath;
- char lname[256];
- DWORD namesize = sizeof(lname);
-
- regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1);
- strcpy(regpath, regtempl);
- strcat(regpath, layoutName);
-
- if (!RegOpenKey(HKEY_LOCAL_MACHINE, regpath, &regkey) &&
- !RegQueryValueEx(regkey, "Layout Text", 0, NULL, lname, &namesize))
- {
- ErrorF ("Keyboardlayout \"%s\" (%s) is unknown\n", lname, layoutName);
- }
-
- /* Close registry key */
- if (regkey)
- RegCloseKey (regkey);
- free(regpath);
- }
- }
-
- /* parse the configuration */
-#ifdef XWIN_XF86CONFIG
- if (g_cmdline.keyboard)
- kbdfrom = X_CMDLINE;
-
- /*
- * Until the layout code is finished, I search for the keyboard
- * device and configure the server with it.
- */
-
- if (g_xf86configptr != NULL)
- input_list = g_xf86configptr->conf_input_lst;
-
- while (input_list != NULL)
- {
- if (winNameCompare (input_list->inp_driver, "keyboard") == 0)
- {
- /* Check if device name matches requested name */
- if (g_cmdline.keyboard && winNameCompare (input_list->inp_identifier,
- g_cmdline.keyboard))
- continue;
- kbd = input_list;
- }
- input_list = input_list->list.next;
- }
-
- if (kbd != NULL)
- {
-
- if (kbd->inp_identifier)
- winDebug ("Using keyboard \"%s\" as primary keyboard\n",
- kbd->inp_identifier);
-
- if ((s = winSetStrOption(kbd->inp_option_lst, "AutoRepeat", NULL)))
- {
- if ((sscanf(s, "%ld %ld", &g_winInfo.keyboard.delay,
- &g_winInfo.keyboard.rate) != 2) ||
- (g_winInfo.keyboard.delay < 1) ||
- (g_winInfo.keyboard.rate == 0) ||
- (1000 / g_winInfo.keyboard.rate) < 1)
- {
- ErrorF ("\"%s\" is not a valid AutoRepeat value", s);
- xfree(s);
- return FALSE;
- }
- xfree(s);
- winDebug ("AutoRepeat: %ld %ld\n",
- g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
- }
-#endif
-
- s = NULL;
- if (g_cmdline.xkbRules)
- {
- s = g_cmdline.xkbRules;
- from = X_CMDLINE;
- }
-#ifdef XWIN_XF86CONFIG
- else
- {
- s = winSetStrOption (kbd->inp_option_lst, "XkbRules", NULL);
- from = X_CONFIG;
- }
-#endif
- if (s)
- {
- g_winInfo.xkb.rules = NULL_IF_EMPTY (s);
- winDebug ("XKB: rules: \"%s\"\n", s);
- }
-
- s = NULL;
- if (g_cmdline.xkbModel)
- {
- s = g_cmdline.xkbModel;
- from = X_CMDLINE;
- }
-#ifdef XWIN_XF86CONFIG
- else
- {
- s = winSetStrOption (kbd->inp_option_lst, "XkbModel", NULL);
- from = X_CONFIG;
- }
-#endif
- if (s)
- {
- g_winInfo.xkb.model = NULL_IF_EMPTY (s);
- winDebug ("XKB: model: \"%s\"\n", s);
- }
-
- s = NULL;
- if (g_cmdline.xkbLayout)
- {
- s = g_cmdline.xkbLayout;
- from = X_CMDLINE;
- }
-#ifdef XWIN_XF86CONFIG
- else
- {
- s = winSetStrOption (kbd->inp_option_lst, "XkbLayout", NULL);
- from = X_CONFIG;
- }
-#endif
- if (s)
- {
- g_winInfo.xkb.layout = NULL_IF_EMPTY (s);
- winDebug ("XKB: layout: \"%s\"\n", s);
- }
-
- s = NULL;
- if (g_cmdline.xkbVariant)
- {
- s = g_cmdline.xkbVariant;
- from = X_CMDLINE;
- }
-#ifdef XWIN_XF86CONFIG
- else
- {
- s = winSetStrOption (kbd->inp_option_lst, "XkbVariant", NULL);
- from = X_CONFIG;
- }
-#endif
- if (s)
- {
- g_winInfo.xkb.variant = NULL_IF_EMPTY (s);
- winDebug ("XKB: variant: \"%s\"\n", s);
- }
-
- s = NULL;
- if (g_cmdline.xkbOptions)
- {
- s = g_cmdline.xkbOptions;
- from = X_CMDLINE;
- }
-#ifdef XWIN_XF86CONFIG
- else
- {
- s = winSetStrOption (kbd->inp_option_lst, "XkbOptions", NULL);
- from = X_CONFIG;
- }
-#endif
- if (s)
- {
- g_winInfo.xkb.options = NULL_IF_EMPTY (s);
- winDebug ("XKB: options: \"%s\"\n", s);
- }
-
-#ifdef XWIN_XF86CONFIG
- }
-#endif
-
- return TRUE;
-}
-
-
-#ifdef XWIN_XF86CONFIG
-Bool
-winConfigMouse (DeviceIntPtr pDevice)
-{
- MessageType mousefrom = X_CONFIG;
-
- XF86ConfInputPtr mouse = NULL;
- XF86ConfInputPtr input_list = NULL;
-
- if (g_cmdline.mouse)
- mousefrom = X_CMDLINE;
-
- if (g_xf86configptr != NULL)
- input_list = g_xf86configptr->conf_input_lst;
-
- while (input_list != NULL)
- {
- if (winNameCompare (input_list->inp_driver, "mouse") == 0)
- {
- /* Check if device name matches requested name */
- if (g_cmdline.mouse && winNameCompare (input_list->inp_identifier,
- g_cmdline.mouse))
- continue;
- mouse = input_list;
- }
- input_list = input_list->list.next;
- }
-
- if (mouse != NULL)
- {
- if (mouse->inp_identifier)
- winDebug ("Using pointer \"%s\" as primary pointer\n",
- mouse->inp_identifier);
-
- g_winInfo.pointer.emulate3Buttons =
- winSetBoolOption (mouse->inp_option_lst, "Emulate3Buttons", FALSE);
- if (g_cmdline.emulate3buttons)
- g_winInfo.pointer.emulate3Buttons = g_cmdline.emulate3buttons;
-
- g_winInfo.pointer.emulate3Timeout =
- winSetIntOption (mouse->inp_option_lst, "Emulate3Timeout", 50);
- if (g_cmdline.emulate3timeout)
- g_winInfo.pointer.emulate3Timeout = g_cmdline.emulate3timeout;
- }
- else
- {
- winDebug ("No primary pointer configured\n");
- winDebug ("Using compiletime defaults for pointer\n");
- }
-
- return TRUE;
-}
-
-
-Bool
-winConfigFiles ()
-{
- MessageType from;
- XF86ConfFilesPtr filesptr = NULL;
-
- /* set some shortcuts */
- if (g_xf86configptr != NULL)
- {
- filesptr = g_xf86configptr->conf_files;
- }
-
-
- /* Fontpath */
- from = X_DEFAULT;
-
- if (g_cmdline.fontPath)
- {
- from = X_CMDLINE;
- defaultFontPath = g_cmdline.fontPath;
- }
- else if (filesptr != NULL && filesptr->file_fontpath)
- {
- from = X_CONFIG;
- defaultFontPath = xstrdup (filesptr->file_fontpath);
- }
- winDebug ("FontPath set to \"%s\"\n", defaultFontPath);
-
- return TRUE;
-}
-#else
-Bool
-winConfigFiles (void)
-{
- /* Fontpath */
- if (g_cmdline.fontPath)
- {
- defaultFontPath = g_cmdline.fontPath;
- winDebug("FontPath set to \"%s\"\n", defaultFontPath);
- }
-
- return TRUE;
-}
-#endif
-
-
-Bool
-winConfigOptions (void)
-{
- return TRUE;
-}
-
-
-Bool
-winConfigScreens (void)
-{
- return TRUE;
-}
-
-
-#ifdef XWIN_XF86CONFIG
-char *
-winSetStrOption (pointer optlist, const char *name, char *deflt)
-{
- OptionInfoRec o;
-
- o.name = name;
- o.type = OPTV_STRING;
- if (ParseOptionValue (-1, optlist, &o))
- deflt = o.value.str;
- if (deflt)
- return xstrdup (deflt);
- else
- return NULL;
-}
-
-
-int
-winSetBoolOption (pointer optlist, const char *name, int deflt)
-{
- OptionInfoRec o;
-
- o.name = name;
- o.type = OPTV_BOOLEAN;
- if (ParseOptionValue (-1, optlist, &o))
- deflt = o.value.bool;
- return deflt;
-}
-
-
-int
-winSetIntOption (pointer optlist, const char *name, int deflt)
-{
- OptionInfoRec o;
-
- o.name = name;
- o.type = OPTV_INTEGER;
- if (ParseOptionValue (-1, optlist, &o))
- deflt = o.value.num;
- return deflt;
-}
-
-
-double
-winSetRealOption (pointer optlist, const char *name, double deflt)
-{
- OptionInfoRec o;
-
- o.name = name;
- o.type = OPTV_REAL;
- if (ParseOptionValue (-1, optlist, &o))
- deflt = o.value.realnum;
- return deflt;
-}
-#endif
-
-
-/*
- * Compare two strings for equality. This is caseinsensitive and
- * The characters '_', ' ' (space) and '\t' (tab) are treated as
- * not existing.
- */
-
-int
-winNameCompare (const char *s1, const char *s2)
-{
- char c1, c2;
-
- if (!s1 || *s1 == 0)
- {
- if (!s2 || *s2 == 0)
- return 0;
- else
- return 1;
- }
-
- while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
- s1++;
- while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
- s2++;
-
- c1 = (isupper (*s1) ? tolower (*s1) : *s1);
- c2 = (isupper (*s2) ? tolower (*s2) : *s2);
-
- while (c1 == c2)
- {
- if (c1 == 0)
- return 0;
- s1++;
- s2++;
-
- while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
- s1++;
- while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
- s2++;
-
- c1 = (isupper (*s1) ? tolower (*s1) : *s1);
- c2 = (isupper (*s2) ? tolower (*s2) : *s2);
- }
- return (c1 - c2);
-}
-
-
-#ifdef XWIN_XF86CONFIG
-/*
- * Find the named option in the list.
- * @return the pointer to the option record, or NULL if not found.
- */
-
-XF86OptionPtr
-winFindOption (XF86OptionPtr list, const char *name)
-{
- while (list)
- {
- if (winNameCompare (list->opt_name, name) == 0)
- return list;
- list = list->list.next;
- }
- return NULL;
-}
-
-
-/*
- * Find the Value of an named option.
- * @return The option value or NULL if not found.
- */
-
-char *
-winFindOptionValue (XF86OptionPtr list, const char *name)
-{
- list = winFindOption (list, name);
- if (list)
- {
- if (list->opt_val)
- return (list->opt_val);
- else
- return "";
- }
- return (NULL);
-}
-
-
-/*
- * Parse the option.
- */
-
-static Bool
-ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
-{
- char *s, *end;
-
- if ((s = winFindOptionValue (options, p->name)) != NULL)
- {
- switch (p->type)
- {
- case OPTV_INTEGER:
- if (*s == '\0')
- {
- winDebug ( "Option \"%s\" requires an integer value\n",
- p->name);
- p->found = FALSE;
- }
- else
- {
- p->value.num = strtoul (s, &end, 0);
- if (*end == '\0')
- {
- p->found = TRUE;
- }
- else
- {
- winDebug ( "Option \"%s\" requires an integer value\n",
- p->name);
- p->found = FALSE;
- }
- }
- break;
- case OPTV_STRING:
- if (*s == '\0')
- {
- winDebug ( "Option \"%s\" requires an string value\n", p->name);
- p->found = FALSE;
- }
- else
- {
- p->value.str = s;
- p->found = TRUE;
- }
- break;
- case OPTV_ANYSTR:
- p->value.str = s;
- p->found = TRUE;
- break;
- case OPTV_REAL:
- if (*s == '\0')
- {
- winDebug ( "Option \"%s\" requires a floating point value\n",
- p->name);
- p->found = FALSE;
- }
- else
- {
- p->value.realnum = strtod (s, &end);
- if (*end == '\0')
- {
- p->found = TRUE;
- }
- else
- {
- winDebug ( "Option \"%s\" requires a floating point value\n",
- p->name);
- p->found = FALSE;
- }
- }
- break;
- case OPTV_BOOLEAN:
- if (GetBoolValue (p, s))
- {
- p->found = TRUE;
- }
- else
- {
- winDebug ( "Option \"%s\" requires a boolean value\n", p->name);
- p->found = FALSE;
- }
- break;
- case OPTV_FREQ:
- if (*s == '\0')
- {
- winDebug ( "Option \"%s\" requires a frequency value\n",
- p->name);
- p->found = FALSE;
- }
- else
- {
- double freq = strtod (s, &end);
- int units = 0;
-
- if (end != s)
- {
- p->found = TRUE;
- if (!winNameCompare (end, "Hz"))
- units = 1;
- else if (!winNameCompare (end, "kHz") ||
- !winNameCompare (end, "k"))
- units = 1000;
- else if (!winNameCompare (end, "MHz") ||
- !winNameCompare (end, "M"))
- units = 1000000;
- else
- {
- winDebug ( "Option \"%s\" requires a frequency value\n",
- p->name);
- p->found = FALSE;
- }
- if (p->found)
- freq *= (double) units;
- }
- else
- {
- winDebug ( "Option \"%s\" requires a frequency value\n",
- p->name);
- p->found = FALSE;
- }
- if (p->found)
- {
- p->value.freq.freq = freq;
- p->value.freq.units = units;
- }
- }
- break;
- case OPTV_NONE:
- /* Should never get here */
- p->found = FALSE;
- break;
- }
- if (p->found)
- {
- winDebug ("Option \"%s\"", p->name);
- if (!(p->type == OPTV_BOOLEAN && *s == 0))
- {
- winDebug (" \"%s\"", s);
- }
- winDebug ("\n");
- }
- }
- else if (p->type == OPTV_BOOLEAN)
- {
- /* Look for matches with options with or without a "No" prefix. */
- char *n, *newn;
- OptionInfoRec opt;
-
- n = winNormalizeName (p->name);
- if (!n)
- {
- p->found = FALSE;
- return FALSE;
- }
- if (strncmp (n, "no", 2) == 0)
- {
- newn = n + 2;
- }
- else
- {
- free (n);
- n = malloc (strlen (p->name) + 2 + 1);
- if (!n)
- {
- p->found = FALSE;
- return FALSE;
- }
- strcpy (n, "No");
- strcat (n, p->name);
- newn = n;
- }
- if ((s = winFindOptionValue (options, newn)) != NULL)
- {
- if (GetBoolValue (&opt, s))
- {
- p->value.bool = !opt.value.bool;
- p->found = TRUE;
- }
- else
- {
- winDebug ( "Option \"%s\" requires a boolean value\n", newn);
- p->found = FALSE;
- }
- }
- else
- {
- p->found = FALSE;
- }
- if (p->found)
- {
- winDebug ("Option \"%s\"", newn);
- if (*s != 0)
- {
- winDebug (" \"%s\"", s);
- }
- winDebug ("\n");
- }
- free (n);
- }
- else
- {
- p->found = FALSE;
- }
- return p->found;
-}
-
-
-static Bool
-configLayout (serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
- char *default_layout)
-{
-#if 0
-#pragma warn UNIMPLEMENTED
-#endif
- return TRUE;
-}
-
-
-static Bool
-configImpliedLayout (serverLayoutPtr servlayoutp,
- XF86ConfScreenPtr conf_screen)
-{
-#if 0
-#pragma warn UNIMPLEMENTED
-#endif
- return TRUE;
-}
-
-
-static Bool
-GetBoolValue (OptionInfoPtr p, const char *s)
-{
- if (*s == 0)
- {
- p->value.bool = TRUE;
- }
- else
- {
- if (winNameCompare (s, "1") == 0)
- p->value.bool = TRUE;
- else if (winNameCompare (s, "on") == 0)
- p->value.bool = TRUE;
- else if (winNameCompare (s, "true") == 0)
- p->value.bool = TRUE;
- else if (winNameCompare (s, "yes") == 0)
- p->value.bool = TRUE;
- else if (winNameCompare (s, "0") == 0)
- p->value.bool = FALSE;
- else if (winNameCompare (s, "off") == 0)
- p->value.bool = FALSE;
- else if (winNameCompare (s, "false") == 0)
- p->value.bool = FALSE;
- else if (winNameCompare (s, "no") == 0)
- p->value.bool = FALSE;
- }
- return TRUE;
-}
-#endif
-
-
-char *
-winNormalizeName (const char *s)
-{
- char *ret, *q;
- const char *p;
-
- if (s == NULL)
- return NULL;
-
- ret = malloc (strlen (s) + 1);
- for (p = s, q = ret; *p != 0; p++)
- {
- switch (*p)
- {
- case '_':
- case ' ':
- case '\t':
- continue;
- default:
- if (isupper (*p))
- *q++ = tolower (*p);
- else
- *q++ = *p;
- }
- }
- *q = '\0';
- return ret;
-}
-
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Alexander Gottwald
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winconfig.h"
+#include "winmsg.h"
+#include "globals.h"
+
+#include "xkbsrv.h"
+
+#ifdef XWIN_XF86CONFIG
+#ifndef CONFIGPATH
+#define CONFIGPATH "%A," "%R," \
+ "/etc/X11/%R," "%P/etc/X11/%R," \
+ "%E," "%F," \
+ "/etc/X11/%F," "%P/etc/X11/%F," \
+ "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+#ifndef CONFIGDIRPATH
+#define CONFIGDIRPATH "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+
+XF86ConfigPtr g_xf86configptr = NULL;
+#endif
+
+WinCmdlineRec g_cmdline = {
+#ifdef XWIN_XF86CONFIG
+ NULL, /* configFile */
+ NULL, /* configDir */
+#endif
+ NULL, /* fontPath */
+#ifdef XWIN_XF86CONFIG
+ NULL, /* keyboard */
+#endif
+ NULL, /* xkbRules */
+ NULL, /* xkbModel */
+ NULL, /* xkbLayout */
+ NULL, /* xkbVariant */
+ NULL, /* xkbOptions */
+ NULL, /* screenname */
+ NULL, /* mousename */
+ FALSE, /* emulate3Buttons */
+ 0 /* emulate3Timeout */
+};
+
+winInfoRec g_winInfo = {
+ { /* keyboard */
+ 0, /* leds */
+ 500, /* delay */
+ 30 /* rate */
+ }
+ ,
+ { /* xkb */
+ NULL, /* rules */
+ NULL, /* model */
+ NULL, /* layout */
+ NULL, /* variant */
+ NULL, /* options */
+ }
+ ,
+ {
+ FALSE,
+ 50}
+};
+
+#define NULL_IF_EMPTY(x) (winNameCompare(x,"")?x:NULL)
+
+#ifdef XWIN_XF86CONFIG
+serverLayoutRec g_winConfigLayout;
+
+static Bool ParseOptionValue (int scrnIndex, pointer options,
+ OptionInfoPtr p);
+static Bool configLayout (serverLayoutPtr, XF86ConfLayoutPtr, char *);
+static Bool configImpliedLayout (serverLayoutPtr, XF86ConfScreenPtr);
+static Bool GetBoolValue (OptionInfoPtr p, const char *s);
+
+
+Bool
+winReadConfigfile ()
+{
+ Bool retval = TRUE;
+ const char *filename, *dirname;
+ MessageType filefrom = X_DEFAULT;
+ MessageType dirfrom = X_DEFAULT;
+ char *xf86ConfigFile = NULL;
+ char *xf86ConfigDir = NULL;
+
+ if (g_cmdline.configFile)
+ {
+ filefrom = X_CMDLINE;
+ xf86ConfigFile = g_cmdline.configFile;
+ }
+ if (g_cmdline.configDir)
+ {
+ dirfrom = X_CMDLINE;
+ xf86ConfigDir = g_cmdline.configDir;
+ }
+
+ /* Parse config file into data structure */
+ xf86initConfigFiles();
+ filename = xf86openConfigFile (CONFIGPATH, xf86ConfigFile, PROJECTROOT);
+ dirname = xf86openConfigDirFiles (CONFIGDIRPATH, xf86ConfigDir, PROJECTROOT);
+
+ /* Hack for backward compatibility */
+ if (!filename && from == X_DEFAULT)
+ filename = xf86openConfigFile (CONFIGPATH, "XF86Config", PROJECTROOT);
+
+ if (filename)
+ {
+ winDebug ("Using config file: \"%s\"\n", filename);
+ }
+ else
+ {
+ ErrorF ("Unable to locate/open config file");
+ if (xf86ConfigFile)
+ ErrorF (": \"%s\"", xf86ConfigFile);
+ ErrorF ("\n");
+ }
+ if (dirname)
+ {
+ winMsg (from, "Using config directory: \"%s\"\n", dirname);
+ }
+ else
+ {
+ winMsg (X_ERROR, "Unable to locate/open config directory");
+ if (xf86ConfigDir)
+ ErrorF (": \"%s\"", xf86ConfigDir);
+ ErrorF ("\n");
+ }
+ if (!filename && !dirname)
+ {
+ return FALSE;
+ }
+ if ((g_xf86configptr = xf86readConfigFile ()) == NULL)
+ {
+ ErrorF ("Problem parsing the config file\n");
+ return FALSE;
+ }
+ xf86closeConfigFile ();
+
+ LogPrintMarkers();
+
+ /* set options from data structure */
+
+ if (g_xf86configptr->conf_layout_lst == NULL || g_cmdline.screenname != NULL)
+ {
+ if (g_cmdline.screenname == NULL)
+ {
+ winDebug ("No Layout section. Using the first Screen section.\n");
+ }
+ if (!configImpliedLayout (&g_winConfigLayout,
+ g_xf86configptr->conf_screen_lst))
+ {
+ ErrorF ("Unable to determine the screen layout\n");
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* Check if layout is given in the config file */
+ if (g_xf86configptr->conf_flags != NULL)
+ {
+ char *dfltlayout = NULL;
+ pointer optlist = g_xf86configptr->conf_flags->flg_option_lst;
+
+ if (optlist && winFindOption (optlist, "defaultserverlayout"))
+ dfltlayout =
+ winSetStrOption (optlist, "defaultserverlayout", NULL);
+
+ if (!configLayout (&g_winConfigLayout,
+ g_xf86configptr->conf_layout_lst,
+ dfltlayout))
+ {
+ ErrorF ("Unable to determine the screen layout\n");
+ return FALSE;
+ }
+ }
+ else
+ {
+ if (!configLayout (&g_winConfigLayout,
+ g_xf86configptr->conf_layout_lst,
+ NULL))
+ {
+ ErrorF ("Unable to determine the screen layout\n");
+ return FALSE;
+ }
+ }
+ }
+
+ /* setup special config files */
+ winConfigFiles ();
+ return retval;
+}
+#endif
+
+/* load layout definitions */
+#include "winlayouts.h"
+
+/* Set the keyboard configuration */
+Bool
+winConfigKeyboard (DeviceIntPtr pDevice)
+{
+ char layoutName[KL_NAMELENGTH];
+ static unsigned int layoutNum = 0;
+ int keyboardType;
+#ifdef XWIN_XF86CONFIG
+ XF86ConfInputPtr kbd = NULL;
+ XF86ConfInputPtr input_list = NULL;
+ MessageType kbdfrom = X_CONFIG;
+#endif
+ MessageType from = X_DEFAULT;
+ char *s = NULL;
+
+ /* Setup defaults */
+ XkbGetRulesDflts(&g_winInfo.xkb);
+
+ /*
+ * Query the windows autorepeat settings and change the xserver defaults.
+ */
+ {
+ int kbd_delay;
+ DWORD kbd_speed;
+ if (SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &kbd_delay, 0) &&
+ SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &kbd_speed, 0))
+ {
+ switch (kbd_delay)
+ {
+ case 0: g_winInfo.keyboard.delay = 250; break;
+ case 1: g_winInfo.keyboard.delay = 500; break;
+ case 2: g_winInfo.keyboard.delay = 750; break;
+ default:
+ case 3: g_winInfo.keyboard.delay = 1000; break;
+ }
+ g_winInfo.keyboard.rate = (kbd_speed>0)?kbd_speed:1;
+ winDebug("Setting autorepeat to delay=%d, rate=%d\n",
+ g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
+ }
+ }
+
+
+ keyboardType = GetKeyboardType (0);
+ if (keyboardType > 0 && GetKeyboardLayoutName (layoutName))
+ {
+ WinKBLayoutPtr pLayout;
+ Bool bfound = FALSE;
+
+ if (! layoutNum)
+ layoutNum = strtoul (layoutName, (char **)NULL, 16);
+ if ((layoutNum & 0xffff) == 0x411) {
+ /* The japanese layouts know a lot of different IMEs which all have
+ different layout numbers set. Map them to a single entry.
+ Same might apply for chinese, korean and other symbol languages
+ too */
+ layoutNum = (layoutNum & 0xffff);
+ if (keyboardType == 7)
+ {
+ /* Japanese layouts have problems with key event messages
+ such as the lack of WM_KEYUP for Caps Lock key.
+ Loading US layout fixes this problem. */
+ if (LoadKeyboardLayout("00000409", KLF_ACTIVATE) != NULL)
+ winDebug("Loading US keyboard layout.\n");
+ else
+ ErrorF ("LoadKeyboardLaout failed.\n");
+ }
+ }
+ winDebug ("winConfigKeyboard - Layout: \"%s\" (%08x) \n",
+ layoutName, layoutNum);
+
+ for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++)
+ {
+ if (pLayout->winlayout != layoutNum)
+ continue;
+ if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType)
+ continue;
+
+ bfound = TRUE;
+ winDebug ("Using preset keyboard for \"%s\" (%x), type \"%d\"\n",
+ pLayout->layoutname, pLayout->winlayout, keyboardType);
+
+ g_winInfo.xkb.model = pLayout->xkbmodel;
+ g_winInfo.xkb.layout = pLayout->xkblayout;
+ g_winInfo.xkb.variant = pLayout->xkbvariant;
+ g_winInfo.xkb.options = pLayout->xkboptions;
+ break;
+ }
+
+ if (!bfound)
+ {
+ HKEY regkey = NULL;
+ const char regtempl[] =
+ "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\";
+ char *regpath;
+ char lname[256];
+ DWORD namesize = sizeof(lname);
+
+ regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1);
+ strcpy(regpath, regtempl);
+ strcat(regpath, layoutName);
+
+ if (!RegOpenKey(HKEY_LOCAL_MACHINE, regpath, &regkey) &&
+ !RegQueryValueEx(regkey, "Layout Text", 0, NULL, lname, &namesize))
+ {
+ ErrorF ("Keyboardlayout \"%s\" (%s) is unknown\n", lname, layoutName);
+ }
+
+ /* Close registry key */
+ if (regkey)
+ RegCloseKey (regkey);
+ free(regpath);
+ }
+ }
+
+ /* parse the configuration */
+#ifdef XWIN_XF86CONFIG
+ if (g_cmdline.keyboard)
+ kbdfrom = X_CMDLINE;
+
+ /*
+ * Until the layout code is finished, I search for the keyboard
+ * device and configure the server with it.
+ */
+
+ if (g_xf86configptr != NULL)
+ input_list = g_xf86configptr->conf_input_lst;
+
+ while (input_list != NULL)
+ {
+ if (winNameCompare (input_list->inp_driver, "keyboard") == 0)
+ {
+ /* Check if device name matches requested name */
+ if (g_cmdline.keyboard && winNameCompare (input_list->inp_identifier,
+ g_cmdline.keyboard))
+ continue;
+ kbd = input_list;
+ }
+ input_list = input_list->list.next;
+ }
+
+ if (kbd != NULL)
+ {
+
+ if (kbd->inp_identifier)
+ winDebug ("Using keyboard \"%s\" as primary keyboard\n",
+ kbd->inp_identifier);
+
+ if ((s = winSetStrOption(kbd->inp_option_lst, "AutoRepeat", NULL)))
+ {
+ if ((sscanf(s, "%ld %ld", &g_winInfo.keyboard.delay,
+ &g_winInfo.keyboard.rate) != 2) ||
+ (g_winInfo.keyboard.delay < 1) ||
+ (g_winInfo.keyboard.rate == 0) ||
+ (1000 / g_winInfo.keyboard.rate) < 1)
+ {
+ ErrorF ("\"%s\" is not a valid AutoRepeat value", s);
+ xfree(s);
+ return FALSE;
+ }
+ xfree(s);
+ winDebug ("AutoRepeat: %ld %ld\n",
+ g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
+ }
+#endif
+
+ s = NULL;
+ if (g_cmdline.xkbRules)
+ {
+ s = g_cmdline.xkbRules;
+ from = X_CMDLINE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else
+ {
+ s = winSetStrOption (kbd->inp_option_lst, "XkbRules", NULL);
+ from = X_CONFIG;
+ }
+#endif
+ if (s)
+ {
+ g_winInfo.xkb.rules = NULL_IF_EMPTY (s);
+ winDebug ("XKB: rules: \"%s\"\n", s);
+ }
+
+ s = NULL;
+ if (g_cmdline.xkbModel)
+ {
+ s = g_cmdline.xkbModel;
+ from = X_CMDLINE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else
+ {
+ s = winSetStrOption (kbd->inp_option_lst, "XkbModel", NULL);
+ from = X_CONFIG;
+ }
+#endif
+ if (s)
+ {
+ g_winInfo.xkb.model = NULL_IF_EMPTY (s);
+ winDebug ("XKB: model: \"%s\"\n", s);
+ }
+
+ s = NULL;
+ if (g_cmdline.xkbLayout)
+ {
+ s = g_cmdline.xkbLayout;
+ from = X_CMDLINE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else
+ {
+ s = winSetStrOption (kbd->inp_option_lst, "XkbLayout", NULL);
+ from = X_CONFIG;
+ }
+#endif
+ if (s)
+ {
+ g_winInfo.xkb.layout = NULL_IF_EMPTY (s);
+ winDebug ("XKB: layout: \"%s\"\n", s);
+ }
+
+ s = NULL;
+ if (g_cmdline.xkbVariant)
+ {
+ s = g_cmdline.xkbVariant;
+ from = X_CMDLINE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else
+ {
+ s = winSetStrOption (kbd->inp_option_lst, "XkbVariant", NULL);
+ from = X_CONFIG;
+ }
+#endif
+ if (s)
+ {
+ g_winInfo.xkb.variant = NULL_IF_EMPTY (s);
+ winDebug ("XKB: variant: \"%s\"\n", s);
+ }
+
+ s = NULL;
+ if (g_cmdline.xkbOptions)
+ {
+ s = g_cmdline.xkbOptions;
+ from = X_CMDLINE;
+ }
+#ifdef XWIN_XF86CONFIG
+ else
+ {
+ s = winSetStrOption (kbd->inp_option_lst, "XkbOptions", NULL);
+ from = X_CONFIG;
+ }
+#endif
+ if (s)
+ {
+ g_winInfo.xkb.options = NULL_IF_EMPTY (s);
+ winDebug ("XKB: options: \"%s\"\n", s);
+ }
+
+#ifdef XWIN_XF86CONFIG
+ }
+#endif
+
+ return TRUE;
+}
+
+
+#ifdef XWIN_XF86CONFIG
+Bool
+winConfigMouse (DeviceIntPtr pDevice)
+{
+ MessageType mousefrom = X_CONFIG;
+
+ XF86ConfInputPtr mouse = NULL;
+ XF86ConfInputPtr input_list = NULL;
+
+ if (g_cmdline.mouse)
+ mousefrom = X_CMDLINE;
+
+ if (g_xf86configptr != NULL)
+ input_list = g_xf86configptr->conf_input_lst;
+
+ while (input_list != NULL)
+ {
+ if (winNameCompare (input_list->inp_driver, "mouse") == 0)
+ {
+ /* Check if device name matches requested name */
+ if (g_cmdline.mouse && winNameCompare (input_list->inp_identifier,
+ g_cmdline.mouse))
+ continue;
+ mouse = input_list;
+ }
+ input_list = input_list->list.next;
+ }
+
+ if (mouse != NULL)
+ {
+ if (mouse->inp_identifier)
+ winDebug ("Using pointer \"%s\" as primary pointer\n",
+ mouse->inp_identifier);
+
+ g_winInfo.pointer.emulate3Buttons =
+ winSetBoolOption (mouse->inp_option_lst, "Emulate3Buttons", FALSE);
+ if (g_cmdline.emulate3buttons)
+ g_winInfo.pointer.emulate3Buttons = g_cmdline.emulate3buttons;
+
+ g_winInfo.pointer.emulate3Timeout =
+ winSetIntOption (mouse->inp_option_lst, "Emulate3Timeout", 50);
+ if (g_cmdline.emulate3timeout)
+ g_winInfo.pointer.emulate3Timeout = g_cmdline.emulate3timeout;
+ }
+ else
+ {
+ winDebug ("No primary pointer configured\n");
+ winDebug ("Using compiletime defaults for pointer\n");
+ }
+
+ return TRUE;
+}
+
+
+Bool
+winConfigFiles ()
+{
+ MessageType from;
+ XF86ConfFilesPtr filesptr = NULL;
+
+ /* set some shortcuts */
+ if (g_xf86configptr != NULL)
+ {
+ filesptr = g_xf86configptr->conf_files;
+ }
+
+
+ /* Fontpath */
+ from = X_DEFAULT;
+
+ if (g_cmdline.fontPath)
+ {
+ from = X_CMDLINE;
+ defaultFontPath = g_cmdline.fontPath;
+ }
+ else if (filesptr != NULL && filesptr->file_fontpath)
+ {
+ from = X_CONFIG;
+ defaultFontPath = xstrdup (filesptr->file_fontpath);
+ }
+ winDebug ("FontPath set to \"%s\"\n", defaultFontPath);
+
+ return TRUE;
+}
+#else
+Bool
+winConfigFiles (void)
+{
+ /* Fontpath */
+ if (g_cmdline.fontPath)
+ {
+ defaultFontPath = g_cmdline.fontPath;
+ winDebug("FontPath set to \"%s\"\n", defaultFontPath);
+ }
+
+ return TRUE;
+}
+#endif
+
+
+Bool
+winConfigOptions (void)
+{
+ return TRUE;
+}
+
+
+Bool
+winConfigScreens (void)
+{
+ return TRUE;
+}
+
+
+#ifdef XWIN_XF86CONFIG
+char *
+winSetStrOption (pointer optlist, const char *name, char *deflt)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_STRING;
+ if (ParseOptionValue (-1, optlist, &o))
+ deflt = o.value.str;
+ if (deflt)
+ return xstrdup (deflt);
+ else
+ return NULL;
+}
+
+
+int
+winSetBoolOption (pointer optlist, const char *name, int deflt)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_BOOLEAN;
+ if (ParseOptionValue (-1, optlist, &o))
+ deflt = o.value.bool;
+ return deflt;
+}
+
+
+int
+winSetIntOption (pointer optlist, const char *name, int deflt)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_INTEGER;
+ if (ParseOptionValue (-1, optlist, &o))
+ deflt = o.value.num;
+ return deflt;
+}
+
+
+double
+winSetRealOption (pointer optlist, const char *name, double deflt)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_REAL;
+ if (ParseOptionValue (-1, optlist, &o))
+ deflt = o.value.realnum;
+ return deflt;
+}
+#endif
+
+
+/*
+ * Compare two strings for equality. This is caseinsensitive and
+ * The characters '_', ' ' (space) and '\t' (tab) are treated as
+ * not existing.
+ */
+
+int
+winNameCompare (const char *s1, const char *s2)
+{
+ char c1, c2;
+
+ if (!s1 || *s1 == 0)
+ {
+ if (!s2 || *s2 == 0)
+ return 0;
+ else
+ return 1;
+ }
+
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+
+ while (c1 == c2)
+ {
+ if (c1 == 0)
+ return 0;
+ s1++;
+ s2++;
+
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ }
+ return (c1 - c2);
+}
+
+
+#ifdef XWIN_XF86CONFIG
+/*
+ * Find the named option in the list.
+ * @return the pointer to the option record, or NULL if not found.
+ */
+
+XF86OptionPtr
+winFindOption (XF86OptionPtr list, const char *name)
+{
+ while (list)
+ {
+ if (winNameCompare (list->opt_name, name) == 0)
+ return list;
+ list = list->list.next;
+ }
+ return NULL;
+}
+
+
+/*
+ * Find the Value of an named option.
+ * @return The option value or NULL if not found.
+ */
+
+char *
+winFindOptionValue (XF86OptionPtr list, const char *name)
+{
+ list = winFindOption (list, name);
+ if (list)
+ {
+ if (list->opt_val)
+ return (list->opt_val);
+ else
+ return "";
+ }
+ return (NULL);
+}
+
+
+/*
+ * Parse the option.
+ */
+
+static Bool
+ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
+{
+ char *s, *end;
+
+ if ((s = winFindOptionValue (options, p->name)) != NULL)
+ {
+ switch (p->type)
+ {
+ case OPTV_INTEGER:
+ if (*s == '\0')
+ {
+ winDebug ( "Option \"%s\" requires an integer value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ else
+ {
+ p->value.num = strtoul (s, &end, 0);
+ if (*end == '\0')
+ {
+ p->found = TRUE;
+ }
+ else
+ {
+ winDebug ( "Option \"%s\" requires an integer value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_STRING:
+ if (*s == '\0')
+ {
+ winDebug ( "Option \"%s\" requires an string value\n", p->name);
+ p->found = FALSE;
+ }
+ else
+ {
+ p->value.str = s;
+ p->found = TRUE;
+ }
+ break;
+ case OPTV_ANYSTR:
+ p->value.str = s;
+ p->found = TRUE;
+ break;
+ case OPTV_REAL:
+ if (*s == '\0')
+ {
+ winDebug ( "Option \"%s\" requires a floating point value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ else
+ {
+ p->value.realnum = strtod (s, &end);
+ if (*end == '\0')
+ {
+ p->found = TRUE;
+ }
+ else
+ {
+ winDebug ( "Option \"%s\" requires a floating point value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_BOOLEAN:
+ if (GetBoolValue (p, s))
+ {
+ p->found = TRUE;
+ }
+ else
+ {
+ winDebug ( "Option \"%s\" requires a boolean value\n", p->name);
+ p->found = FALSE;
+ }
+ break;
+ case OPTV_FREQ:
+ if (*s == '\0')
+ {
+ winDebug ( "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ else
+ {
+ double freq = strtod (s, &end);
+ int units = 0;
+
+ if (end != s)
+ {
+ p->found = TRUE;
+ if (!winNameCompare (end, "Hz"))
+ units = 1;
+ else if (!winNameCompare (end, "kHz") ||
+ !winNameCompare (end, "k"))
+ units = 1000;
+ else if (!winNameCompare (end, "MHz") ||
+ !winNameCompare (end, "M"))
+ units = 1000000;
+ else
+ {
+ winDebug ( "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ if (p->found)
+ freq *= (double) units;
+ }
+ else
+ {
+ winDebug ( "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ if (p->found)
+ {
+ p->value.freq.freq = freq;
+ p->value.freq.units = units;
+ }
+ }
+ break;
+ case OPTV_NONE:
+ /* Should never get here */
+ p->found = FALSE;
+ break;
+ }
+ if (p->found)
+ {
+ winDebug ("Option \"%s\"", p->name);
+ if (!(p->type == OPTV_BOOLEAN && *s == 0))
+ {
+ winDebug (" \"%s\"", s);
+ }
+ winDebug ("\n");
+ }
+ }
+ else if (p->type == OPTV_BOOLEAN)
+ {
+ /* Look for matches with options with or without a "No" prefix. */
+ char *n, *newn;
+ OptionInfoRec opt;
+
+ n = winNormalizeName (p->name);
+ if (!n)
+ {
+ p->found = FALSE;
+ return FALSE;
+ }
+ if (strncmp (n, "no", 2) == 0)
+ {
+ newn = n + 2;
+ }
+ else
+ {
+ free (n);
+ n = malloc (strlen (p->name) + 2 + 1);
+ if (!n)
+ {
+ p->found = FALSE;
+ return FALSE;
+ }
+ strcpy (n, "No");
+ strcat (n, p->name);
+ newn = n;
+ }
+ if ((s = winFindOptionValue (options, newn)) != NULL)
+ {
+ if (GetBoolValue (&opt, s))
+ {
+ p->value.bool = !opt.value.bool;
+ p->found = TRUE;
+ }
+ else
+ {
+ winDebug ( "Option \"%s\" requires a boolean value\n", newn);
+ p->found = FALSE;
+ }
+ }
+ else
+ {
+ p->found = FALSE;
+ }
+ if (p->found)
+ {
+ winDebug ("Option \"%s\"", newn);
+ if (*s != 0)
+ {
+ winDebug (" \"%s\"", s);
+ }
+ winDebug ("\n");
+ }
+ free (n);
+ }
+ else
+ {
+ p->found = FALSE;
+ }
+ return p->found;
+}
+
+
+static Bool
+configLayout (serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
+ char *default_layout)
+{
+#if 0
+#pragma warn UNIMPLEMENTED
+#endif
+ return TRUE;
+}
+
+
+static Bool
+configImpliedLayout (serverLayoutPtr servlayoutp,
+ XF86ConfScreenPtr conf_screen)
+{
+#if 0
+#pragma warn UNIMPLEMENTED
+#endif
+ return TRUE;
+}
+
+
+static Bool
+GetBoolValue (OptionInfoPtr p, const char *s)
+{
+ if (*s == 0)
+ {
+ p->value.bool = TRUE;
+ }
+ else
+ {
+ if (winNameCompare (s, "1") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare (s, "on") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare (s, "true") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare (s, "yes") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare (s, "0") == 0)
+ p->value.bool = FALSE;
+ else if (winNameCompare (s, "off") == 0)
+ p->value.bool = FALSE;
+ else if (winNameCompare (s, "false") == 0)
+ p->value.bool = FALSE;
+ else if (winNameCompare (s, "no") == 0)
+ p->value.bool = FALSE;
+ }
+ return TRUE;
+}
+#endif
+
+
+char *
+winNormalizeName (const char *s)
+{
+ char *ret, *q;
+ const char *p;
+
+ if (s == NULL)
+ return NULL;
+
+ ret = malloc (strlen (s) + 1);
+ for (p = s, q = ret; *p != 0; p++)
+ {
+ switch (*p)
+ {
+ case '_':
+ case ' ':
+ case '\t':
+ continue;
+ default:
+ if (isupper (*p))
+ *q++ = tolower (*p);
+ else
+ *q++ = *p;
+ }
+ }
+ *q = '\0';
+ return ret;
+}
+
diff --git a/xorg-server/hw/xwin/winconfig.h b/xorg-server/hw/xwin/winconfig.h
index 63d621112..058884abc 100644
--- a/xorg-server/hw/xwin/winconfig.h
+++ b/xorg-server/hw/xwin/winconfig.h
@@ -188,6 +188,7 @@ typedef struct
/* Files */
#ifdef XWIN_XF86CONFIG
char *configFile;
+ char *configDir;
#endif
char *fontPath;
/* input devices - keyboard */
diff --git a/xorg-server/hw/xwin/winprocarg.c b/xorg-server/hw/xwin/winprocarg.c
index 6db6ad4a3..0cd9320b9 100644
--- a/xorg-server/hw/xwin/winprocarg.c
+++ b/xorg-server/hw/xwin/winprocarg.c
@@ -1317,6 +1317,24 @@ ddxProcessArgument (int argc, char *argv[], int i)
}
/*
+ * Look for the '-configdir' argument
+ */
+ if (IS_OPTION ("-configdir"))
+ {
+ CHECK_ARGS (1);
+#ifdef XWIN_XF86CONFIG
+ g_cmdline.configDir = argv[++i];
+#else
+ winMessageBoxF ("The %s option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION,
+ argv[i]);
+#endif
+ return 2;
+ }
+
+ /*
* Look for the '-keyboard' argument
*/
if (IS_OPTION ("-keyboard"))
diff --git a/xorg-server/hw/xwin/xlaunch/config.h b/xorg-server/hw/xwin/xlaunch/config.h
index 8448c54a4..8017ffb55 100644
--- a/xorg-server/hw/xwin/xlaunch/config.h
+++ b/xorg-server/hw/xwin/xlaunch/config.h
@@ -64,8 +64,13 @@ struct CConfig
std::string font_server;
std::string extra_params;
std::string extra_ssh;
+#ifdef _DEBUG
+ CConfig() : window(MultiWindow), client(NoClient), clientstart(NoXClient), display("1"),
+#else
CConfig() : window(MultiWindow), client(NoClient), clientstart(NoXClient), display("0"),
- protocol_path(""), program("xeyes"), progs(PROG_NUMBER), compress(false), host(""), user(""),
+#endif
+ local(false), protocol(""),
+ protocol_path(""), program("xeyes"), progs(PROG_NUMBER), compress(false), host(""), user("ago"),
password(""), password_save(false), password_start(false), broadcast(false),
indirect(false), xdmcp_host(""), xhosts(HOST_NUMBER), clipboard(true), no_access_control(false),
font_server(), extra_params(), extra_ssh() {};
diff --git a/xorg-server/hw/xwin/xlaunch/main.cc b/xorg-server/hw/xwin/xlaunch/main.cc
index d20b788d7..ad84f6a10 100644
--- a/xorg-server/hw/xwin/xlaunch/main.cc
+++ b/xorg-server/hw/xwin/xlaunch/main.cc
@@ -23,10 +23,6 @@
* holders shall not be used in advertising or otherwise to promote the sale,
* use or other dealings in this Software without prior written authorization.
*/
-
-#define printf _not_used_ /* Make sure that we do not use the standard printf definition because
- we are going to reimplement it in this file */
-
#include "window/util.h"
#include "window/wizard.h"
#include "resources/resources.h"
@@ -41,65 +37,6 @@
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
-#include <fcntl.h>
-#include <io.h>
-#undef printf
-
-#if defined(_MSC_VER) && defined(_DLL)
-#define _CRTEXP __declspec(dllexport)
-#else
-#define _CRTEXP
-#endif
-
-_Check_return_opt_ _CRTEXP int __cdecl printf(_In_z_ _Printf_format_string_ const char * pFmt, ...)
-{
- static int ConsoleCreated=0;
- va_list arglist;
- if (!ConsoleCreated)
- {
- int hConHandle;
- long lStdHandle;
- CONSOLE_SCREEN_BUFFER_INFO coninfo;
-
- FILE *fp;
- const unsigned int MAX_CONSOLE_LINES = 500;
- ConsoleCreated=1;
- if (!AttachConsole(ATTACH_PARENT_PROCESS))
- AllocConsole();
-
- // set the screen buffer to be big enough to let us scroll text
- GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
- coninfo.dwSize.Y = MAX_CONSOLE_LINES;
- SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
-
- // redirect unbuffered STDOUT to the console
- lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
- hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
- fp = _fdopen( hConHandle, "w" );
- *stdout = *fp;
- setvbuf( stdout, NULL, _IONBF, 0 );
-
- // redirect unbuffered STDIN to the console
- lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
- hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
- fp = _fdopen( hConHandle, "r" );
- *stdin = *fp;
- setvbuf( stdin, NULL, _IONBF, 0 );
-
- // redirect unbuffered STDERR to the console
- lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
- hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
- fp = _fdopen( hConHandle, "w" );
- *stderr = *fp;
- setvbuf( stderr, NULL, _IONBF, 0 );
-
- }
-
- va_start(arglist, pFmt );
- return vfprintf(stderr, pFmt, arglist);
-}
-
-
/// @brief Send WM_ENDSESSION to all program windows.
/// This will shutdown the started xserver
BOOL CALLBACK KillWindowsProc(HWND hwnd, LPARAM lParam)
@@ -135,7 +72,9 @@ class CMyWizard : public CWizard
config.Load(filename);
} catch (std::runtime_error &e)
{
- printf("Fehler: %s\n", e.what());
+ char Message[255];
+ sprintf(Message,"Failure: %s\n", e.what());
+ MessageBox(NULL,Message,"Exception",MB_OK);
}
}
@@ -423,7 +362,9 @@ class CMyWizard : public CWizard
config.Save(ofn.lpstrFile);
} catch (std::runtime_error &e)
{
- printf("Fehler: %s\n", e.what());
+ char Message[255];
+ sprintf(Message,"Failure: %s\n", e.what());
+ MessageBox(NULL,Message,"Exception",MB_OK);
}
}
}
@@ -568,11 +509,6 @@ class CMyWizard : public CWizard
std::string display_id = ":" + config.display;
std::string display = "localhost" + display_id + ":0";
-#ifdef _DEBUG
- // Debug only: Switch to VCXsrv installation directory
- SetCurrentDirectory("C:\\Programme\\vcxsrv");
-#endif
-
// Build Xsrv commandline
buffer = "vcxsrv " + display_id + " ";
switch (config.window)
@@ -759,7 +695,13 @@ int main(int argc, char **argv)
return 0;
} catch (std::runtime_error &e)
{
- printf("Fehler: %s\n", e.what());
+ char Message[255];
+ sprintf(Message,"Failure: %s\n", e.what());
+ MessageBox(NULL,Message,"Exception",MB_OK);
return -1;
}
}
+
+
+
+
diff --git a/xorg-server/include/dix-config.h.in b/xorg-server/include/dix-config.h.in
index 109637115..84c78db54 100644
--- a/xorg-server/include/dix-config.h.in
+++ b/xorg-server/include/dix-config.h.in
@@ -231,6 +231,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Define to 1 if you have the <fnmatch.h> header file. */
+#undef HAVE_FNMATCH_H
+
/* Have /dev/urandom */
#undef HAVE_URANDOM
@@ -396,6 +399,9 @@
/* Support D-Bus */
#undef HAVE_DBUS
+/* Use libudev for input hotplug */
+#undef CONFIG_UDEV
+
/* Use D-Bus for input hotplug */
#undef CONFIG_NEED_DBUS
diff --git a/xorg-server/include/input.h b/xorg-server/include/input.h
index cab91c8f5..0e4d89177 100644
--- a/xorg-server/include/input.h
+++ b/xorg-server/include/input.h
@@ -52,6 +52,7 @@ SOFTWARE.
#include "screenint.h"
#include <X11/Xmd.h>
#include <X11/Xproto.h>
+#include <stdint.h>
#include "window.h" /* for WindowPtr */
#include "xkbrules.h"
#include "events.h"
@@ -210,6 +211,20 @@ typedef struct _InputOption {
struct _InputOption *next;
} InputOption;
+typedef struct _InputAttributes {
+ char *product;
+ char *vendor;
+ char *device;
+ uint32_t flags;
+} InputAttributes;
+
+#define ATTR_KEYBOARD (1<<0)
+#define ATTR_POINTER (1<<1)
+#define ATTR_JOYSTICK (1<<2)
+#define ATTR_TABLET (1<<3)
+#define ATTR_TOUCHPAD (1<<4)
+#define ATTR_TOUCHSCREEN (1<<5)
+
/* Key has been run through all input processing and events sent to clients. */
#define KEY_PROCESSED 1
/* Key has not been fully processed, no events have been sent. */
@@ -516,6 +531,7 @@ void FixUpEventFromWindow(DeviceIntPtr pDev,
/* Implemented by the DDX. */
extern _X_EXPORT int NewInputDeviceRequest(
InputOption *options,
+ InputAttributes *attrs,
DeviceIntPtr *dev);
extern _X_EXPORT void DeleteInputDeviceRequest(
DeviceIntPtr dev);
diff --git a/xorg-server/include/ptrveloc.h b/xorg-server/include/ptrveloc.h
index 2a4b40b19..676c46419 100644
--- a/xorg-server/include/ptrveloc.h
+++ b/xorg-server/include/ptrveloc.h
@@ -37,7 +37,8 @@
#define AccelProfileSimple 4
#define AccelProfilePower 5
#define AccelProfileLinear 6
-#define AccelProfileLAST AccelProfileLinear
+#define AccelProfileSmoothLimited 7
+#define AccelProfileLAST AccelProfileSmoothLimited
/* fwd */
struct _DeviceVelocityRec;
diff --git a/xorg-server/include/xorg-config.h.in b/xorg-server/include/xorg-config.h.in
index 9fe7cdef5..8946a6538 100644
--- a/xorg-server/include/xorg-config.h.in
+++ b/xorg-server/include/xorg-config.h.in
@@ -36,6 +36,9 @@
/* Path to configuration file. */
#undef __XCONFIGFILE__
+/* Name of configuration directory. */
+#undef __XCONFIGDIR__
+
/* Path to loadable modules. */
#undef DEFAULT_MODULE_PATH
diff --git a/xorg-server/test/xi2/protocol-eventconvert.c b/xorg-server/test/xi2/protocol-eventconvert.c
index 65ddec507..f20a10a57 100644
--- a/xorg-server/test/xi2/protocol-eventconvert.c
+++ b/xorg-server/test/xi2/protocol-eventconvert.c
@@ -736,6 +736,9 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
}
break;
+ default:
+ g_error("Invalid class type.\n");
+ break;
}
ptr += any->length * 4;
@@ -834,7 +837,7 @@ static void test_convert_XIDeviceChangedEvent(void)
in.keys.max_keycode = 1 << 8;
test_XIDeviceChangedEvent(&in);
- in.keys.max_keycode = 0xFFFD; /* highest range, above that the length
+ in.keys.max_keycode = 0xFFFC; /* highest range, above that the length
field gives up */
test_XIDeviceChangedEvent(&in);