[mutter/wip/carlosg/there-can-be-only-one: 151/151] backends: Keep cursor hidden on tablet input on Wayland
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/there-can-be-only-one: 151/151] backends: Keep cursor hidden on tablet input on Wayland
- Date: Sat, 5 Feb 2022 12:17:05 +0000 (UTC)
commit bd2ecfedcfb67ea99d57142d5041a7fbf749ac29
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jan 13 14:22:16 2022 +0100
backends: Keep cursor hidden on tablet input on Wayland
Tablets have their own cursor, in order to avoid confusions just
hide the regular pointer like we do on touchscreens, so there's
the illusion that there is a single cursor.
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/75
src/backends/meta-backend.c | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 72a22bd17b..fa247504c5 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -120,6 +120,8 @@ static MetaBackend *_backend;
static gboolean stage_views_disabled = FALSE;
+#define HIDDEN_POINTER_TIMEOUT 300 /* ms */
+
/**
* meta_get_backend:
*
@@ -186,6 +188,8 @@ struct _MetaBackendPrivate
guint sleep_signal_id;
GCancellable *cancellable;
GDBusConnection *system_bus;
+
+ uint32_t last_pointer_motion;
};
typedef struct _MetaBackendPrivate MetaBackendPrivate;
@@ -394,7 +398,7 @@ check_pointer_visibility (ClutterSeat *seat)
{
g_autoptr (GList) devices = NULL;
const GList *l;
- gboolean has_touchscreen = FALSE, has_pointer = FALSE;
+ gboolean has_touchscreen = FALSE, has_pointer = FALSE, has_tablet = FALSE;
devices = clutter_seat_list_devices (seat);
@@ -410,9 +414,13 @@ check_pointer_visibility (ClutterSeat *seat)
if (device_type == CLUTTER_POINTER_DEVICE ||
device_type == CLUTTER_TOUCHPAD_DEVICE)
has_pointer = TRUE;
+ if (device_type == CLUTTER_TABLET_DEVICE ||
+ device_type == CLUTTER_PEN_DEVICE ||
+ device_type == CLUTTER_ERASER_DEVICE)
+ has_tablet = TRUE;
}
- return has_pointer && !has_touchscreen;
+ return has_pointer && !has_touchscreen && !has_tablet;
}
static void
@@ -1006,23 +1014,39 @@ update_pointer_visibility_from_event (MetaBackend *backend,
MetaCursorTracker *cursor_tracker = priv->cursor_tracker;
ClutterInputDevice *device;
ClutterInputDeviceType device_type;
+ uint32_t time_ms;
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);
+ time_ms = clutter_event_get_time (event);
switch (device_type)
{
- case CLUTTER_KEYBOARD_DEVICE:
- break;
case CLUTTER_TOUCHSCREEN_DEVICE:
meta_cursor_tracker_set_pointer_visible (cursor_tracker, FALSE);
break;
- default:
+ case CLUTTER_POINTER_DEVICE:
+ case CLUTTER_TOUCHPAD_DEVICE:
+ priv->last_pointer_motion = time_ms;
meta_cursor_tracker_set_pointer_visible (cursor_tracker, TRUE);
break;
+ case CLUTTER_TABLET_DEVICE:
+ case CLUTTER_PEN_DEVICE:
+ case CLUTTER_ERASER_DEVICE:
+ case CLUTTER_CURSOR_DEVICE:
+ if (meta_is_wayland_compositor () &&
+ time_ms > priv->last_pointer_motion + HIDDEN_POINTER_TIMEOUT)
+ meta_cursor_tracker_set_pointer_visible (cursor_tracker, FALSE);
+ break;
+ case CLUTTER_KEYBOARD_DEVICE:
+ case CLUTTER_PAD_DEVICE:
+ case CLUTTER_EXTENSION_DEVICE:
+ case CLUTTER_JOYSTICK_DEVICE:
+ default:
+ break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]