summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-03-12 12:58:22 +0100
committerHans de Goede <hdegoede@redhat.com>2014-03-13 13:11:50 +0100
commit8d3f63dbe9bfd816beb6475fd0e00df4dbba269f (patch)
tree7b33efda86b9b34b7eb35e3c03de83e5c1246bd3
parent4e3d9690e1868d286dcb766b429f9c99313f2401 (diff)
systemd-logind: Add a systemd_logind_set_input_fd_for_all_devs helper
And use it where appropriate. Setting the fd for all matching InputDevices is necessary when we've multiple InputDevices sharing a single device-node, such as happens with Wacom tablets. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--hw/xfree86/os-support/linux/systemd-logind.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/hw/xfree86/os-support/linux/systemd-logind.c b/hw/xfree86/os-support/linux/systemd-logind.c
index 012a9204e..a2ef7afba 100644
--- a/hw/xfree86/os-support/linux/systemd-logind.c
+++ b/hw/xfree86/os-support/linux/systemd-logind.c
@@ -65,6 +65,23 @@ systemd_logind_find_info_ptr_by_devnum(InputInfoPtr start,
return NULL;
}
+static void
+systemd_logind_set_input_fd_for_all_devs(int major, int minor, int fd,
+ Bool enable)
+{
+ InputInfoPtr pInfo;
+
+ pInfo = systemd_logind_find_info_ptr_by_devnum(xf86InputDevs, major, minor);
+ while (pInfo) {
+ pInfo->fd = fd;
+ pInfo->options = xf86ReplaceIntOption(pInfo->options, "fd", fd);
+ if (enable)
+ xf86EnableInputDeviceForVTSwitch(pInfo);
+
+ pInfo = systemd_logind_find_info_ptr_by_devnum(pInfo->next, major, minor);
+ }
+}
+
int
systemd_logind_take_fd(int _major, int _minor, const char *path,
Bool *paused_ret)
@@ -337,8 +354,7 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data)
pdev->flags |= XF86_PDEV_PAUSED;
else {
close(pInfo->fd);
- pInfo->fd = -1;
- pInfo->options = xf86ReplaceIntOption(pInfo->options, "fd", -1);
+ systemd_logind_set_input_fd_for_all_devs(major, minor, -1, FALSE);
}
if (ack)
systemd_logind_ack_pause(info, major, minor);
@@ -347,15 +363,12 @@ message_filter(DBusConnection * connection, DBusMessage * message, void *data)
/* info->vt_active gets set by systemd_logind_vtenter() */
info->active = TRUE;
- if (pdev) {
+ if (pdev)
pdev->flags &= ~XF86_PDEV_PAUSED;
- }
- else {
- pInfo->fd = fd;
- pInfo->options = xf86ReplaceIntOption(pInfo->options, "fd", fd);
- if (info->vt_active)
- xf86EnableInputDeviceForVTSwitch(pInfo);
- }
+ else
+ systemd_logind_set_input_fd_for_all_devs(major, minor, fd,
+ info->vt_active);
+
/* Always call vtenter(), in case there are only legacy video devs */
systemd_logind_vtenter();
}