Commit 5f2fff3c authored by Peter Hutterer's avatar Peter Hutterer

Ensure parent devices are actual parent devices

The list returned by xf86FirstLocalDevice() includes our own device. If the
parent device is removed before the hotplug callback is invoked, the first
match with the same shared-device ID is our own device (or potentially another
subdevice on the same already-removed parent). Avoid this by making sure the
matched device is actually a parent device.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Tested-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
parent 116cddba
......@@ -214,6 +214,19 @@ btn_xorg2linux(unsigned int b)
return button;
}
static BOOL
xf86libinput_is_subdevice(InputInfoPtr pInfo)
{
char *source;
BOOL is_subdevice;
source = xf86SetStrOption(pInfo->options, "_source", "");
is_subdevice = strcmp(source, "_driver/libinput") == 0;
free(source);
return is_subdevice;
}
static inline InputInfoPtr
xf86libinput_get_parent(InputInfoPtr pInfo)
{
......@@ -228,7 +241,7 @@ xf86libinput_get_parent(InputInfoPtr pInfo)
int id = xf86CheckIntOption(parent->options,
"_libinput/shared-device",
-1);
if (id == parent_id)
if (id == parent_id && !xf86libinput_is_subdevice(parent))
return parent;
}
......@@ -2473,19 +2486,6 @@ xf86libinput_create_subdevice(InputInfoPtr pInfo,
return NULL;
}
static BOOL
xf86libinput_is_subdevice(InputInfoPtr pInfo)
{
char *source;
BOOL is_subdevice;
source = xf86SetStrOption(pInfo->options, "_source", "");
is_subdevice = strcmp(source, "_driver/libinput") == 0;
free(source);
return is_subdevice;
}
static inline uint32_t
caps_from_options(InputInfoPtr pInfo)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment