From f5c0bcbf9c2ad27133e52a8ead56eee0739c5f42 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 13 Jan 2022 14:15:05 +0100 Subject: [PATCH] backends: Split handling of pointer visibility on events This was done as part of the "last updated device" changes, separate that as we want different checks and policies. Part-of: --- src/backends/meta-backend.c | 45 ++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index f5b54dc23..4541507ad 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -357,27 +357,11 @@ static gboolean update_last_device (MetaBackend *backend) { MetaBackendPrivate *priv = meta_backend_get_instance_private (backend); - MetaCursorTracker *cursor_tracker = priv->cursor_tracker; - ClutterInputDeviceType device_type; priv->device_update_idle_id = 0; - device_type = clutter_input_device_get_device_type (priv->current_device); - g_signal_emit (backend, signals[LAST_DEVICE_CHANGED], 0, priv->current_device); - switch (device_type) - { - case CLUTTER_KEYBOARD_DEVICE: - break; - case CLUTTER_TOUCHSCREEN_DEVICE: - meta_cursor_tracker_set_pointer_visible (cursor_tracker, FALSE); - break; - default: - meta_cursor_tracker_set_pointer_visible (cursor_tracker, TRUE); - break; - } - return G_SOURCE_REMOVE; } @@ -1014,6 +998,34 @@ update_last_device_from_event (MetaBackend *backend, meta_backend_update_last_device (backend, source); } +static void +update_pointer_visibility_from_event (MetaBackend *backend, + ClutterEvent *event) +{ + MetaBackendPrivate *priv = meta_backend_get_instance_private (backend); + MetaCursorTracker *cursor_tracker = priv->cursor_tracker; + ClutterInputDevice *device; + ClutterInputDeviceType device_type; + + device = clutter_event_get_source_device (event); + if (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_PHYSICAL) + return; + + device_type = clutter_input_device_get_device_type (device); + + switch (device_type) + { + case CLUTTER_KEYBOARD_DEVICE: + break; + case CLUTTER_TOUCHSCREEN_DEVICE: + meta_cursor_tracker_set_pointer_visible (cursor_tracker, FALSE); + break; + default: + meta_cursor_tracker_set_pointer_visible (cursor_tracker, TRUE); + break; + } +} + /* Mutter is responsible for pulling events off the X queue, so Clutter * doesn't need (and shouldn't) run its normal event source which polls * the X fd, but we do have to deal with dispatching events that accumulate @@ -1054,6 +1066,7 @@ clutter_source_dispatch (GSource *source, CLUTTER_STAGE (meta_backend_get_stage (backend_source->backend)); clutter_do_event (event); update_last_device_from_event (backend_source->backend, event); + update_pointer_visibility_from_event (backend_source->backend, event); clutter_event_free (event); }