From 75c3f0ffbad1b9606b31ac073c10c9c0e75e7c91 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 31 Oct 2016 17:36:50 +0100 Subject: [PATCH] clutter/evdev: Emit ClutterDeviceManager::tool-changed We do so whenever a tool enters or leaves proximity. We now also ensure that last_tool is NULL after it leaves proximity, although the CLUTTER_PROXIMITY_OUT event itself should still contain tool information. https://bugzilla.gnome.org/show_bug.cgi?id=773779 --- clutter/clutter/evdev/clutter-device-manager-evdev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/clutter/clutter/evdev/clutter-device-manager-evdev.c b/clutter/clutter/evdev/clutter-device-manager-evdev.c index b8679a318..eeddc22f4 100644 --- a/clutter/clutter/evdev/clutter-device-manager-evdev.c +++ b/clutter/clutter/evdev/clutter-device-manager-evdev.c @@ -1210,7 +1210,12 @@ input_device_update_tool (ClutterInputDevice *input_device, } } - evdev_device->last_tool = tool; + if (evdev_device->last_tool != tool) + { + evdev_device->last_tool = tool; + g_signal_emit_by_name (clutter_device_manager_get_default (), + "tool-changed", input_device, tool); + } } static gdouble * @@ -1753,8 +1758,11 @@ process_device_event (ClutterDeviceManagerEvdev *manager_evdev, libinput_tool = libinput_event_tablet_tool_get_tool (tablet_event); - input_device_update_tool (device, libinput_tool); + if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN) + input_device_update_tool (device, libinput_tool); notify_proximity (device, time, state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN); + if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) + input_device_update_tool (device, NULL); break; } case LIBINPUT_EVENT_TABLET_TOOL_BUTTON: