[mutter/wip/carlosg/input-thread: 34/101] backends/native: Manage tablet cursors in backend
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-thread: 34/101] backends/native: Manage tablet cursors in backend
- Date: Wed, 25 Nov 2020 17:12:06 +0000 (UTC)
commit bb56a71f246c1e78e54e487936ef0ff9f92092e4
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Jul 11 13:47:51 2020 +0200
backends/native: Manage tablet cursors in backend
Instead of letting the wayland bits maintain an always-software
cursor renderer, let the cursor renderer be managed by the backend,
and only hook to it (as we do for pointer cursor) in the wayland
bits.
ATM, make the cursor renderer still always-software, although
ideally we should allow moving the HW cursor management between
renderers.
src/backends/native/meta-seat-native.c | 41 +++++++++++++++++++++++++++++++---
src/backends/native/meta-seat-native.h | 1 +
src/wayland/meta-wayland-tablet-tool.c | 9 +++++++-
3 files changed, 47 insertions(+), 4 deletions(-)
---
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index a4486be516..6b3e37fb51 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -1850,6 +1850,32 @@ process_tablet_axis (MetaSeatNative *seat,
}
}
+static void
+update_tablet_cursor_state (MetaSeatNative *seat_native,
+ ClutterInputDevice *device,
+ gboolean in)
+{
+ if (in)
+ {
+ MetaCursorRenderer *cursor_renderer;
+
+ if (!seat_native->tablet_cursors)
+ {
+ seat_native->tablet_cursors = g_hash_table_new_full (NULL, NULL, NULL,
+ g_object_unref);
+ }
+
+ cursor_renderer = meta_cursor_renderer_new (meta_get_backend ());
+ g_hash_table_insert (seat_native->tablet_cursors,
+ device, cursor_renderer);
+ }
+ else
+ {
+ if (seat_native->tablet_cursors)
+ g_hash_table_remove (seat_native->tablet_cursors, device);
+ }
+}
+
static gboolean
process_device_event (MetaSeatNative *seat,
struct libinput_event *event)
@@ -2257,18 +2283,22 @@ process_device_event (MetaSeatNative *seat,
libinput_event_get_tablet_tool_event (event);
struct libinput_tablet_tool *libinput_tool = NULL;
enum libinput_tablet_tool_proximity_state state;
+ gboolean in;
state = libinput_event_tablet_tool_get_proximity_state (tablet_event);
time = libinput_event_tablet_tool_get_time_usec (tablet_event);
device = libinput_device_get_user_data (libinput_device);
+ in = state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN;
libinput_tool = libinput_event_tablet_tool_get_tool (tablet_event);
- if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN)
+ if (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)
+ notify_proximity (device, time, in);
+ if (!in)
input_device_update_tool (device, NULL);
+
+ update_tablet_cursor_state (seat, device, in);
break;
}
case LIBINPUT_EVENT_TABLET_TOOL_BUTTON:
@@ -2630,6 +2660,7 @@ meta_seat_native_finalize (GObject *object)
g_hash_table_destroy (seat->reserved_virtual_slots);
+ g_clear_pointer (&seat->tablet_cursors, g_hash_table_unref);
g_object_unref (seat->cursor_renderer);
g_object_unref (seat->udev_client);
@@ -3308,5 +3339,9 @@ meta_seat_native_maybe_ensure_cursor_renderer (MetaSeatNative *seat_native,
return seat_native->cursor_renderer;
}
+ if (seat_native->tablet_cursors &&
+ clutter_input_device_get_device_type (device) == CLUTTER_TABLET_DEVICE)
+ return g_hash_table_lookup (seat_native->tablet_cursors, device);
+
return NULL;
}
diff --git a/src/backends/native/meta-seat-native.h b/src/backends/native/meta-seat-native.h
index 9f7f2d3a1e..5fa0964b05 100644
--- a/src/backends/native/meta-seat-native.h
+++ b/src/backends/native/meta-seat-native.h
@@ -87,6 +87,7 @@ struct _MetaSeatNative
MetaKeymapNative *keymap;
MetaCursorRenderer *cursor_renderer;
+ GHashTable *tablet_cursors;
GUdevClient *udev_client;
guint tablet_mode_switch_state : 1;
diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c
index c913d0a55d..589e92ddd4 100644
--- a/src/wayland/meta-wayland-tablet-tool.c
+++ b/src/wayland/meta-wayland-tablet-tool.c
@@ -913,7 +913,14 @@ meta_wayland_tablet_tool_update (MetaWaylandTabletTool *tool,
break;
case CLUTTER_PROXIMITY_IN:
if (!tool->cursor_renderer)
- tool->cursor_renderer = meta_cursor_renderer_new (meta_get_backend ());
+ {
+ MetaCursorRenderer *renderer;
+
+ renderer =
+ meta_backend_get_cursor_renderer_for_device (meta_get_backend (),
+ clutter_event_get_source_device (event));
+ g_set_object (&tool->cursor_renderer, renderer);
+ }
tool->current_tablet =
meta_wayland_tablet_seat_lookup_tablet (tool->seat,
clutter_event_get_source_device (event));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]