open-src/xserver/xorg/hotkey.patch
author Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
Mon, 14 Mar 2011 15:37:30 -0700
changeset 1088 1c99106ccbe0
parent 851 d428083dbbdd
child 1124 7bc7e624f965
permissions -rw-r--r--
6983602 Xorg 1.9 integration [PSARC/2011/008]

diff -Nurp -x '*~' -x '*.orig' Xi/exevents.c Xi/exevents.c
diff -Nurp -x '*~' -x '*.orig' Xi/exevents.c Xi/exevents.c
--- Xi/exevents.c	2010-12-23 14:15:10.000000000 -0800
+++ Xi/exevents.c	2011-02-15 15:53:51.551620898 -0800
@@ -194,7 +194,16 @@ CopyKeyClass(DeviceIntPtr device, Device
 {
     KeyClassPtr mk = master->key;
 
+#ifdef SUNSOFT
+    DeviceIntPtr mdev = dixLookupPrivate(&master->devPrivates,
+	HotkeyMapDevicePrivateKey);
+#endif
+
+#ifdef SUNSOFT
+    if ((device == master) || (device == mdev))
+#else
     if (device == master)
+#endif
         return;
 
     mk->sourceid = device->id;
diff -Nurp -x '*~' -x '*.orig' Xi/extinit.c Xi/extinit.c
--- Xi/extinit.c	2010-12-02 12:24:35.000000000 -0800
+++ Xi/extinit.c	2011-02-15 15:53:51.552122593 -0800
@@ -371,6 +371,10 @@ extern XExtensionVersion XIVersion;
 
 Mask PropagateMask[MAXDEVICES];
 
+#ifdef SUNSOFT
+DevPrivateKeyRec HotkeyMapDevicePrivateKeyRec;
+#endif
+
 /*****************************************************************
  *
  * Versioning support
@@ -1255,6 +1259,11 @@ XInputExtensionInit(void)
     if (!dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)))
         FatalError("Cannot request private for XI.\n");
 
+#ifdef SUNSOFT   
+    if (!dixRegisterPrivateKey(&HotkeyMapDevicePrivateKeyRec, PRIVATE_DEVICE, 0))
+        FatalError("Cannot request private for hotkey.\n");
+#endif
+
     if (!AddCallback(&ClientStateCallback, XIClientCallback, 0))
         FatalError("Failed to add callback to XI.\n");
 
diff -Nurp -x '*~' -x '*.orig' config/hal.c config/hal.c
--- config/hal.c	2010-06-27 16:43:05.000000000 -0700
+++ config/hal.c	2011-02-15 15:53:51.552429571 -0800
@@ -125,6 +125,63 @@ get_prop_string_array(LibHalContext *hal
     return ret;
 }
 
+#ifdef SUNSOFT
+static void
+add_extra_device(char *driver)
+{
+    DeviceIntPtr	dev;
+    char		*config_info = NULL;
+    InputOption 	*options = NULL, *tmpo = NULL;
+    InputAttributes	attrs = {0};
+
+    options = xcalloc(sizeof(*options), 1);
+    if (!options){
+	LogMessage(X_ERROR, "config/hal: couldn't allocate space for input options!\n");
+        goto unwind;
+    }
+
+    options->key = xstrdup("_source");
+    options->value = xstrdup("server/hal");
+    if (!options->key || !options->value) {
+	LogMessage(X_ERROR, "config/hal: couldn't allocate first key/value pair\n");
+	goto unwind;
+    }
+
+    add_option(&options, "driver", driver);
+    add_option(&options, "name", driver);
+
+    config_info = xalloc(strlen(driver) + 5); /* "hal:" and NULL */
+    if (!config_info) {
+	LogMessage(X_ERROR, "config/hal: couldn't allocate name\n");
+	goto unwind;
+    }
+    sprintf(config_info, "hal:%s", driver);
+
+    /* Check for duplicate devices */
+    if (device_is_duplicate(config_info))
+	goto unwind;
+
+    LogMessage(X_INFO, "config/hal: Adding input device %s\n", driver);
+    if (NewInputDeviceRequest(options, &attrs, &dev) != Success) {
+	LogMessage(X_ERROR, "config/hal: NewInputDeviceRequest failed\n");
+	dev = NULL;
+	goto unwind;
+    }
+
+    dev->config_info = xstrdup(config_info);
+
+unwind:
+    if (config_info)
+	xfree(config_info);
+    while (!dev && (tmpo = options)) {
+	options = tmpo->next;
+	xfree(tmpo->key);
+	xfree(tmpo->value);
+	xfree(tmpo);
+    }
+}
+#endif
+
 static void
 device_added(LibHalContext *hal_ctx, const char *udi)
 {
@@ -136,6 +193,9 @@ device_added(LibHalContext *hal_ctx, con
     DBusError error;
     struct xkb_options xkb_opts = {0};
     int rc;
+#ifdef SUNSOFT
+    char *mdriver = NULL;
+#endif
 
     LibHalPropertySet *set = NULL;
 	LibHalPropertySetIterator set_iter;
@@ -377,6 +437,16 @@ device_added(LibHalContext *hal_ctx, con
     if (xkb_opts.options)
         add_option(&options, "xkb_options", xkb_opts.options);
 
+#ifdef SUNSOFT
+    for (tmpo = options; tmpo; tmpo = tmpo->next) {
+	if (!strcmp(tmpo->key, "mdriver") && (tmpo->value))
+	    mdriver = tmpo->value;
+    }
+ 
+    if (mdriver)
+	add_extra_device (mdriver);
+#endif
+   
     /* 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, &attrs, &dev)) != Success) {
diff -Nurp -x '*~' -x '*.orig' config/x11-input.fdi config/x11-input.fdi
--- config/x11-input.fdi	2009-09-27 18:56:59.000000000 -0700
+++ config/x11-input.fdi	2011-02-15 15:53:51.552591586 -0800
@@ -76,6 +76,12 @@
       <!-- If we're using Linux, we use evdev by default (falling back to
            kbd otherwise). -->
       <merge key="input.x11_driver" type="string">kbd</merge>
+        <match key="/org/freedesktop/Hal/devices/computer:system.formfactor" string="laptop">
+          <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
+                string="SunOS">
+            <merge key="input.x11_options.mdriver" type="string">hotkey</merge>
+          </match>
+        </match>
       <merge key="input.x11_options.XkbModel" type="string">pc105</merge>
       <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
              string="Linux">
diff -Nurp -x '*~' -x '*.orig' include/inputstr.h include/inputstr.h
--- include/inputstr.h	2010-12-03 21:53:07.000000000 -0800
+++ include/inputstr.h	2011-02-15 15:53:51.552836408 -0800
@@ -57,6 +57,11 @@ SOFTWARE.
 #include "geext.h"
 #include "privates.h"
 
+#ifdef SUNSOFT
+extern _X_EXPORT DevPrivateKeyRec HotkeyMapDevicePrivateKeyRec;
+#define HotkeyMapDevicePrivateKey (&HotkeyMapDevicePrivateKeyRec)
+#endif
+
 #define BitIsOn(ptr, bit) (!!(((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7))))
 #define SetBit(ptr, bit)  (((BYTE *) (ptr))[(bit)>>3] |= (1 << ((bit) & 7)))
 #define ClearBit(ptr, bit) (((BYTE *)(ptr))[(bit)>>3] &= ~(1 << ((bit) & 7)))