xserver: Branch 'master' - 7 commits

Keith Packard keithp at kemper.freedesktop.org
Tue Mar 11 22:07:49 PDT 2014


 config/config.c                |    3 -
 config/hal.c                   |   16 +++++-
 config/udev.c                  |   15 ++++--
 dix/devices.c                  |    3 +
 hw/xfree86/common/xf86Xinput.c |   22 ++++++++
 include/xkbsrv.h               |    4 +
 xkb/xkbActions.c               |  102 ++++++++++++++++++++++++++++-------------
 7 files changed, 123 insertions(+), 42 deletions(-)

New commits:
commit 81a4952d3dcab9ca3a1ee399c773f5ac352036c4
Merge: 96a28e9 7950664
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Mar 11 22:04:36 2014 -0700

    Merge remote-tracking branch 'whot/for-keith'

commit 795066477ee81b5b82e490eac8bed6b656d01f17
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Feb 26 07:54:56 2014 +1000

    config: search for PnPID on all parents (#75513)
    
    The PnPID for a device may not be on the immediate parent, so search up the
    device tree until we find one.
    
    X.Org Bug 75513 <http://bugs.freedesktop.org/show_bug.cgi?id=75513>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Tested-by: Benjamin Tissoires <benjamin.tissoires at gmail.com>

diff --git a/config/hal.c b/config/hal.c
index 94cb6e7..ea574ca 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -185,8 +185,7 @@ device_added(LibHalContext * hal_ctx, const char *udi)
     parent = get_prop_string(hal_ctx, udi, "info.parent");
     if (parent) {
         int usb_vendor, usb_product;
-
-        attrs.pnp_id = get_prop_string(hal_ctx, parent, "pnp.id");
+        char *old_parent;
 
         /* construct USB ID in lowercase - "0000:ffff" */
         usb_vendor = libhal_device_get_property_int(hal_ctx, parent,
@@ -204,7 +203,18 @@ device_added(LibHalContext * hal_ctx, const char *udi)
                 == -1)
                 attrs.usb_id = NULL;
 
-        free(parent);
+        attrs.pnp_id = get_prop_string(hal_ctx, parent, "pnp.id");
+        old_parent = parent;
+
+        while (!attrs.pnp_id &&
+               (parent = get_prop_string(hal_ctx, parent, "info.parent"))) {
+            attrs.pnp_id = get_prop_string(hal_ctx, parent, "pnp.id");
+
+            free(old_parent);
+            old_parent = parent;
+        }
+
+        free(old_parent);
     }
 
     input_options = input_option_new(NULL, "_source", "server/hal");
diff --git a/config/udev.c b/config/udev.c
index d70eeb4..d88abaa 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -149,10 +149,6 @@ device_added(struct udev_device *udev_device)
             LOG_PROPERTY(ppath, "NAME", name);
         }
 
-        if (pnp_id)
-            attrs.pnp_id = strdup(pnp_id);
-        LOG_SYSATTR(ppath, "id", pnp_id);
-
         /* construct USB ID in lowercase hex - "0000:ffff" */
         if (product &&
             sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) {
@@ -164,6 +160,17 @@ device_added(struct udev_device *udev_device)
                 LOG_PROPERTY(ppath, "PRODUCT", product);
             attrs.usb_id = usb_id;
         }
+
+        while (!pnp_id && (parent = udev_device_get_parent(parent))) {
+            pnp_id = udev_device_get_sysattr_value(parent, "id");
+            if (!pnp_id)
+                continue;
+
+            attrs.pnp_id = strdup(pnp_id);
+            ppath = udev_device_get_devnode(parent);
+            LOG_SYSATTR(ppath, "id", pnp_id);
+        }
+
     }
     if (!name)
         name = "(unnamed)";
commit 45fb3a934dc0db51584aba37c2f9d73deff9191d
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Feb 26 16:20:08 2014 +1000

    xkb: push locked modifier state down to attached slave devices
    
    Whenever the master changes, push the locked modifier state to the attached
    slave devices, then update the indicators. This way, when NumLock or CapsLock
    are hit on any device, the LED will light up on all devices. Likewise, a new
    keyboard attached to a master device will light up with the correct
    indicators.
    
    The indicators are handled per-keyboard, depending on the layout, i.e. if one
    keyboard has grp_led:num set, the NumLock LED won't light up on that keyboard.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/devices.c b/dix/devices.c
index 1c86d52..ab923d5 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -416,6 +416,8 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent)
         XISendDeviceHierarchyEvent(flags);
     }
 
+    if (!IsMaster(dev))
+        XkbPushLockedStateToSlaves(GetMaster(dev, MASTER_KEYBOARD), 0, 0);
     RecalculateMasterButtons(dev);
 
     /* initialise an idle timer for this device*/
@@ -2649,6 +2651,7 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
         dev->spriteInfo->paired = master;
         dev->spriteInfo->spriteOwner = FALSE;
 
+        XkbPushLockedStateToSlaves(GetMaster(dev, MASTER_KEYBOARD), 0, 0);
         RecalculateMasterButtons(master);
     }
 
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index e799799..f857b22 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -638,6 +638,10 @@ extern _X_EXPORT void XkbHandleActions(DeviceIntPtr /* dev */ ,
                                        DeviceEvent *    /* event */
     );
 
+extern void XkbPushLockedStateToSlaves(DeviceIntPtr /* master */,
+                                       int /* evtype */,
+                                       int /* key */);
+
 extern _X_EXPORT Bool XkbEnableDisableControls(XkbSrvInfoPtr /* xkbi */ ,
                                                unsigned long /* change */ ,
                                                unsigned long /* newValues */ ,
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 7e5512c..c44f44b 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1174,6 +1174,25 @@ _XkbApplyState(DeviceIntPtr dev, Bool genStateNotify, int evtype, int key)
 }
 
 void
+XkbPushLockedStateToSlaves(DeviceIntPtr master, int evtype, int key)
+{
+    DeviceIntPtr dev;
+    Bool genStateNotify;
+
+    nt_list_for_each_entry(dev, inputInfo.devices, next) {
+        if (!dev->key || GetMaster(dev, MASTER_KEYBOARD) != master)
+            continue;
+
+        genStateNotify = _XkbEnsureStateChange(dev->key->xkbInfo);
+
+        dev->key->xkbInfo->state.locked_mods =
+            master->key->xkbInfo->state.locked_mods;
+
+        _XkbApplyState(dev, genStateNotify, evtype, key);
+    }
+}
+
+void
 XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
 {
     int key, bit, i;
@@ -1327,6 +1346,7 @@ XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
     }
 
     _XkbApplyState(dev, genStateNotify, event->type, key);
+    XkbPushLockedStateToSlaves(dev, event->type, key);
 }
 
 int
commit 656841798c99bcd79da47c03ec666a48b855541f
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Feb 26 16:16:10 2014 +1000

    xkb: factor out state update into a function
    
    No functional changes
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 3da57f7..7e5512c 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1143,13 +1143,43 @@ _XkbEnsureStateChange(XkbSrvInfoPtr xkbi)
     return genStateNotify;
 }
 
+static void
+_XkbApplyState(DeviceIntPtr dev, Bool genStateNotify, int evtype, int key)
+{
+    XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+    int changed;
+
+    XkbComputeDerivedState(xkbi);
+
+    changed = XkbStateChangedFlags(&xkbi->prev_state, &xkbi->state);
+    if (genStateNotify) {
+        if (changed) {
+            xkbStateNotify sn;
+
+            sn.keycode = key;
+            sn.eventType = evtype;
+            sn.requestMajor = sn.requestMinor = 0;
+            sn.changed = changed;
+            XkbSendStateNotify(dev, &sn);
+        }
+        xkbi->flags &= ~_XkbStateNotifyInProgress;
+    }
+
+    changed = XkbIndicatorsToUpdate(dev, changed, FALSE);
+    if (changed) {
+        XkbEventCauseRec cause;
+        XkbSetCauseKey(&cause, key, evtype);
+        XkbUpdateIndicators(dev, changed, FALSE, NULL, &cause);
+    }
+}
+
 void
 XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
 {
     int key, bit, i;
     XkbSrvInfoPtr xkbi;
     KeyClassPtr keyc;
-    int changed, sendEvent;
+    int sendEvent;
     Bool genStateNotify;
     XkbAction act;
     XkbFilterPtr filter;
@@ -1296,28 +1326,7 @@ XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
         FixKeyState(event, dev);
     }
 
-    XkbComputeDerivedState(xkbi);
-    changed = XkbStateChangedFlags(&xkbi->prev_state, &xkbi->state);
-    if (genStateNotify) {
-        if (changed) {
-            xkbStateNotify sn;
-
-            sn.keycode = key;
-            sn.eventType = event->type;
-            sn.requestMajor = sn.requestMinor = 0;
-            sn.changed = changed;
-            XkbSendStateNotify(dev, &sn);
-        }
-        xkbi->flags &= ~_XkbStateNotifyInProgress;
-    }
-    changed = XkbIndicatorsToUpdate(dev, changed, FALSE);
-    if (changed) {
-        XkbEventCauseRec cause;
-
-        XkbSetCauseKey(&cause, key, event->type);
-        XkbUpdateIndicators(dev, changed, FALSE, NULL, &cause);
-    }
-    return;
+    _XkbApplyState(dev, genStateNotify, event->type, key);
 }
 
 int
commit dda2468e579762dbd1fed2c75b5587d98f841e9c
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Feb 26 16:03:19 2014 +1000

    xkb: factor out the StateNotify flag check
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 1443498..3da57f7 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1127,6 +1127,22 @@ _XkbApplyFilters(XkbSrvInfoPtr xkbi, unsigned kc, XkbAction *pAction)
     return send;
 }
 
+static int
+_XkbEnsureStateChange(XkbSrvInfoPtr xkbi)
+{
+    Bool genStateNotify = FALSE;
+
+    /* The state may change, so if we're not in the middle of sending a state
+     * notify, prepare for it */
+    if ((xkbi->flags & _XkbStateNotifyInProgress) == 0) {
+        xkbi->prev_state = xkbi->state;
+        xkbi->flags |= _XkbStateNotifyInProgress;
+        genStateNotify = TRUE;
+    }
+
+    return genStateNotify;
+}
+
 void
 XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
 {
@@ -1146,15 +1162,8 @@ XkbHandleActions(DeviceIntPtr dev, DeviceIntPtr kbd, DeviceEvent *event)
     keyc = kbd->key;
     xkbi = keyc->xkbInfo;
     key = event->detail.key;
-    /* The state may change, so if we're not in the middle of sending a state
-     * notify, prepare for it */
-    if ((xkbi->flags & _XkbStateNotifyInProgress) == 0) {
-        xkbi->prev_state = xkbi->state;
-        xkbi->flags |= _XkbStateNotifyInProgress;
-        genStateNotify = TRUE;
-    }
-    else
-        genStateNotify = FALSE;
+
+    genStateNotify = _XkbEnsureStateChange(xkbi);
 
     xkbi->clearMods = xkbi->setMods = 0;
     xkbi->groupChange = 0;
commit fdb4ec86c29d85c1f68418a26e64bcc05b9c14ae
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Mar 11 14:21:27 2014 +1000

    xfree86: handle xorg.conf devices with logind
    
    Only devices from the config backend have their attributes set, devices from
    the xorg.conf only have Option "Device". That option is also set by the
    config backend, so use it.
    
    And since the config backend sets our major/minor but xorg.conf devices don't
    have that set, make sure we try to stat it first where needed.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 7c3e479..36b92a9 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -81,6 +81,7 @@
 
 #include <stdarg.h>
 #include <stdint.h>             /* for int64_t */
+#include <sys/stat.h>
 #include <unistd.h>
 
 #include "mi.h"
@@ -804,6 +805,18 @@ xf86InputDevicePostInit(DeviceIntPtr dev)
     return Success;
 }
 
+static void
+xf86stat(const char *path, int *maj, int *min)
+{
+    struct stat st;
+
+    if (stat(path, &st) == -1)
+        return;
+
+    *maj = major(st.st_rdev);
+    *min = minor(st.st_rdev);
+}
+
 /**
  * Create a new input device, activate and enable it.
  *
@@ -828,6 +841,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
     DeviceIntPtr dev = NULL;
     Bool paused;
     int rval;
+    const char *path;
 
     /* Memory leak for every attached device if we don't
      * test if the module is already loaded first */
@@ -841,9 +855,13 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
         goto unwind;
     }
 
-    if (drv->capabilities & XI86_DRV_CAP_SERVER_FD) {
+    path = xf86CheckStrOption(pInfo->options, "Device", NULL);
+    if (path && pInfo->major == 0 && pInfo->minor == 0)
+        xf86stat(path, &pInfo->major, &pInfo->minor);
+
+    if (path && (drv->capabilities & XI86_DRV_CAP_SERVER_FD)){
         int fd = systemd_logind_take_fd(pInfo->major, pInfo->minor,
-                                        pInfo->attrs->device, &paused);
+                                        path, &paused);
         if (fd != -1) {
             if (paused) {
                 /* Put on new_input_devices list for delayed probe */
commit 4754af9ddbd55c5637b56bd9f37d0d3414c839a8
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Mar 11 14:20:51 2014 +1000

    config: only free odev->attrib_name for string types
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/config/config.c b/config/config.c
index 7971b87..4ad7330 100644
--- a/config/config.c
+++ b/config/config.c
@@ -246,7 +246,8 @@ config_odev_free_attributes(struct OdevAttributes *attribs)
         case ODEV_ATTRIB_FD: fd = iter->attrib_value; break;
         }
         xorg_list_del(&iter->member);
-        free(iter->attrib_name);
+        if (iter->attrib_type == ODEV_ATTRIB_STRING)
+            free(iter->attrib_name);
         free(iter);
     }
 


More information about the xorg-commit mailing list