From dc022a67b0e9d498e80616590e555fa2531439dc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 13 Jul 2020 13:32:48 +0200 Subject: [PATCH] backends: Add ::device property to MetaCursorRenderer A cursor renderer is made to invariably follow a pointer device, make it a construct-time property, and update all creators of cursor renderers to specify it. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403 --- src/backends/meta-cursor-renderer.c | 29 ++++++++++++++++++- src/backends/meta-cursor-renderer.h | 4 ++- .../native/meta-cursor-renderer-native.c | 4 ++- .../native/meta-cursor-renderer-native.h | 3 +- src/backends/native/meta-seat-native.c | 5 ++-- src/backends/x11/cm/meta-backend-x11-cm.c | 1 + .../x11/nested/meta-backend-x11-nested.c | 1 + 7 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c index 9d19497e8..54b01e04e 100644 --- a/src/backends/meta-cursor-renderer.c +++ b/src/backends/meta-cursor-renderer.c @@ -46,6 +46,7 @@ enum PROP_0, PROP_BACKEND, + PROP_DEVICE, N_PROPS }; @@ -59,6 +60,7 @@ struct _MetaCursorRendererPrivate float current_x; float current_y; + ClutterInputDevice *device; MetaCursorSprite *displayed_cursor; MetaCursorSprite *overlay_cursor; @@ -205,6 +207,9 @@ meta_cursor_renderer_get_property (GObject *object, case PROP_BACKEND: g_value_set_object (value, priv->backend); break; + case PROP_DEVICE: + g_value_set_object (value, priv->device); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -226,6 +231,9 @@ meta_cursor_renderer_set_property (GObject *object, case PROP_BACKEND: priv->backend = g_value_get_object (value); break; + case PROP_DEVICE: + priv->device = g_value_get_object (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -286,6 +294,14 @@ meta_cursor_renderer_class_init (MetaCursorRendererClass *klass) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + obj_props[PROP_DEVICE] = + g_param_spec_object ("device", + "device", + "Input device", + CLUTTER_TYPE_INPUT_DEVICE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); g_object_class_install_properties (object_class, N_PROPS, obj_props); signals[CURSOR_PAINTED] = g_signal_new ("cursor-painted", @@ -396,10 +412,12 @@ meta_cursor_renderer_update_cursor (MetaCursorRenderer *renderer, } MetaCursorRenderer * -meta_cursor_renderer_new (MetaBackend *backend) +meta_cursor_renderer_new (MetaBackend *backend, + ClutterInputDevice *device) { return g_object_new (META_TYPE_CURSOR_RENDERER, "backend", backend, + "device", device, NULL); } @@ -511,3 +529,12 @@ meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer, return FALSE; } + +ClutterInputDevice * +meta_cursor_renderer_get_input_device (MetaCursorRenderer *renderer) +{ + MetaCursorRendererPrivate *priv = + meta_cursor_renderer_get_instance_private (renderer); + + return priv->device; +} diff --git a/src/backends/meta-cursor-renderer.h b/src/backends/meta-cursor-renderer.h index 7d89af487..38621027c 100644 --- a/src/backends/meta-cursor-renderer.h +++ b/src/backends/meta-cursor-renderer.h @@ -54,7 +54,8 @@ struct _MetaCursorRendererClass MetaCursorSprite *cursor_sprite); }; -MetaCursorRenderer * meta_cursor_renderer_new (MetaBackend *backend); +MetaCursorRenderer * meta_cursor_renderer_new (MetaBackend *backend, + ClutterInputDevice *device); void meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer, MetaCursorSprite *cursor_sprite); @@ -83,6 +84,7 @@ graphene_rect_t meta_cursor_renderer_calculate_rect (MetaCursorRenderer *rendere void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer, MetaCursorSprite *cursor_sprite); +ClutterInputDevice * meta_cursor_renderer_get_input_device (MetaCursorRenderer *renderer); void meta_cursor_renderer_update_stage_overlay (MetaCursorRenderer *renderer, MetaCursorSprite *cursor_sprite); diff --git a/src/backends/native/meta-cursor-renderer-native.c b/src/backends/native/meta-cursor-renderer-native.c index 02bb2aaf0..84aa32bce 100644 --- a/src/backends/native/meta-cursor-renderer-native.c +++ b/src/backends/native/meta-cursor-renderer-native.c @@ -1724,7 +1724,8 @@ init_hw_cursor_support (MetaCursorRendererNative *cursor_renderer_native) } MetaCursorRendererNative * -meta_cursor_renderer_native_new (MetaBackend *backend) +meta_cursor_renderer_native_new (MetaBackend *backend, + ClutterInputDevice *device) { MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend); @@ -1733,6 +1734,7 @@ meta_cursor_renderer_native_new (MetaBackend *backend) cursor_renderer_native = g_object_new (META_TYPE_CURSOR_RENDERER_NATIVE, "backend", backend, + "device", device, NULL); priv = meta_cursor_renderer_native_get_instance_private (cursor_renderer_native); diff --git a/src/backends/native/meta-cursor-renderer-native.h b/src/backends/native/meta-cursor-renderer-native.h index d3560e48f..26c698cda 100644 --- a/src/backends/native/meta-cursor-renderer-native.h +++ b/src/backends/native/meta-cursor-renderer-native.h @@ -33,6 +33,7 @@ G_DECLARE_FINAL_TYPE (MetaCursorRendererNative, meta_cursor_renderer_native, META, CURSOR_RENDERER_NATIVE, MetaCursorRenderer) -MetaCursorRendererNative * meta_cursor_renderer_native_new (MetaBackend *backend); +MetaCursorRendererNative * meta_cursor_renderer_native_new (MetaBackend *backend, + ClutterInputDevice *device); #endif /* META_CURSOR_RENDERER_NATIVE_H */ diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c index b6f68acf2..233c5aa0a 100644 --- a/src/backends/native/meta-seat-native.c +++ b/src/backends/native/meta-seat-native.c @@ -1836,7 +1836,7 @@ update_tablet_cursor_state (MetaSeatNative *seat, g_object_unref); } - renderer = meta_cursor_renderer_new (meta_get_backend ()); + renderer = meta_cursor_renderer_new (meta_get_backend (), device); g_hash_table_insert (seat->tablet_cursors, device, renderer); } else @@ -3301,7 +3301,8 @@ meta_seat_native_get_cursor_renderer (MetaSeatNative *seat, MetaCursorRendererNative *renderer_native; renderer_native = - meta_cursor_renderer_native_new (meta_get_backend ()); + meta_cursor_renderer_native_new (meta_get_backend (), + seat->core_pointer); seat->cursor_renderer = META_CURSOR_RENDERER (renderer_native); } diff --git a/src/backends/x11/cm/meta-backend-x11-cm.c b/src/backends/x11/cm/meta-backend-x11-cm.c index b00f1ca06..35e1acf9f 100644 --- a/src/backends/x11/cm/meta-backend-x11-cm.c +++ b/src/backends/x11/cm/meta-backend-x11-cm.c @@ -127,6 +127,7 @@ meta_backend_x11_cm_get_cursor_renderer (MetaBackend *backend, x11_cm->cursor_renderer = g_object_new (META_TYPE_CURSOR_RENDERER_X11, "backend", backend, + "device", device, NULL); } diff --git a/src/backends/x11/nested/meta-backend-x11-nested.c b/src/backends/x11/nested/meta-backend-x11-nested.c index 27143ce14..041f4b87a 100644 --- a/src/backends/x11/nested/meta-backend-x11-nested.c +++ b/src/backends/x11/nested/meta-backend-x11-nested.c @@ -76,6 +76,7 @@ meta_backend_x11_nested_get_cursor_renderer (MetaBackend *backend, priv->cursor_renderer = g_object_new (META_TYPE_CURSOR_RENDERER_X11_NESTED, "backend", backend, + "device", device, NULL); }