[mutter/wip/carlosg/there-can-be-only-one: 4876/4879] backends: Unify cursor visibility checks
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/there-can-be-only-one: 4876/4879] backends: Unify cursor visibility checks
- Date: Wed, 12 Jan 2022 16:40:05 +0000 (UTC)
commit c40b2687f2dd18f9b0291d46488209d532c95c65
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jan 12 12:30:38 2022 +0100
backends: Unify cursor visibility checks
We are adding more to this logic, so make this check be its own
function that checks devices individually.
src/backends/meta-backend.c | 73 ++++++++++++---------------------------------
1 file changed, 19 insertions(+), 54 deletions(-)
---
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 369b03b1ef..a2396af056 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -375,10 +375,11 @@ meta_backend_monitors_changed (MetaBackend *backend)
}
static inline gboolean
-check_has_pointing_device (ClutterSeat *seat)
+check_pointer_visibility (ClutterSeat *seat)
{
- GList *l, *devices;
- gboolean found = FALSE;
+ g_autoptr (GList) devices = NULL;
+ const GList *l;
+ gboolean has_touchscreen = FALSE, has_pointer = FALSE;
devices = clutter_seat_list_devices (seat);
@@ -386,19 +387,13 @@ check_has_pointing_device (ClutterSeat *seat)
{
ClutterInputDevice *device = l->data;
- if (clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_LOGICAL)
- continue;
- if (clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE ||
- clutter_input_device_get_device_type (device) == CLUTTER_KEYBOARD_DEVICE)
- continue;
-
- found = TRUE;
- break;
+ if (clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE)
+ has_touchscreen = TRUE;
+ if (clutter_input_device_get_device_type (device) == CLUTTER_POINTER_DEVICE)
+ has_pointer = TRUE;
}
- g_list_free (devices);
-
- return found;
+ return has_pointer && !has_touchscreen;
}
static void
@@ -416,11 +411,12 @@ on_device_added (ClutterSeat *seat,
device_type = clutter_input_device_get_device_type (device);
- if (device_type == CLUTTER_TOUCHSCREEN_DEVICE)
- meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker, FALSE);
- else if (device_type == CLUTTER_POINTER_DEVICE &&
- !clutter_seat_has_touchscreen (seat))
- meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker, TRUE);
+ if (device_type == CLUTTER_TOUCHSCREEN_DEVICE ||
+ device_type == CLUTTER_POINTER_DEVICE)
+ {
+ meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker,
+ check_pointer_visibility (seat));
+ }
if (device_type == CLUTTER_TOUCHSCREEN_DEVICE ||
device_type == CLUTTER_TABLET_DEVICE ||
@@ -451,27 +447,12 @@ on_device_removed (ClutterSeat *seat,
if (priv->current_device == device)
{
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
- gboolean has_touchscreen, has_pointing_device;
- ClutterInputDeviceType device_type;
g_clear_object (&priv->current_device);
g_clear_handle_id (&priv->device_update_idle_id, g_source_remove);
- device_type = clutter_input_device_get_device_type (device);
- has_touchscreen = clutter_seat_has_touchscreen (seat);
-
- if (device_type == CLUTTER_TOUCHSCREEN_DEVICE && has_touchscreen)
- {
- /* There's more touchscreens left, keep the pointer hidden */
- meta_cursor_tracker_set_pointer_visible (cursor_tracker, FALSE);
- }
- else if (device_type != CLUTTER_KEYBOARD_DEVICE)
- {
- has_pointing_device = check_has_pointing_device (seat);
- meta_cursor_tracker_set_pointer_visible (cursor_tracker,
- has_pointing_device &&
- !has_touchscreen);
- }
+ meta_cursor_tracker_set_pointer_visible (cursor_tracker,
+ check_pointer_visibility (seat));
}
if (priv->current_device == device)
@@ -510,25 +491,9 @@ on_stage_shown_cb (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
ClutterSeat *seat = priv->default_seat;
- g_autoptr (GList) devices = NULL;
- const GList *l;
-
- devices = clutter_seat_list_devices (seat);
- for (l = devices; l; l = l->next)
- {
- ClutterInputDevice *device = l->data;
- if (clutter_input_device_get_device_mode (device) ==
- CLUTTER_INPUT_MODE_LOGICAL)
- continue;
-
- if (clutter_input_device_get_device_type (device) !=
- CLUTTER_POINTER_DEVICE)
- continue;
-
- meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker, TRUE);
- break;
- }
+ meta_cursor_tracker_set_pointer_visible (priv->cursor_tracker,
+ check_pointer_visibility (seat));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]