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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
Carlos Garnacho 2020-07-13 13:32:48 +02:00 committed by Marge Bot
parent 247613d26d
commit 3ade57e4e9
7 changed files with 41 additions and 6 deletions

View File

@ -46,6 +46,7 @@ enum
PROP_0, PROP_0,
PROP_BACKEND, PROP_BACKEND,
PROP_DEVICE,
N_PROPS N_PROPS
}; };
@ -59,6 +60,7 @@ struct _MetaCursorRendererPrivate
float current_x; float current_x;
float current_y; float current_y;
ClutterInputDevice *device;
MetaCursorSprite *displayed_cursor; MetaCursorSprite *displayed_cursor;
MetaCursorSprite *overlay_cursor; MetaCursorSprite *overlay_cursor;
@ -205,6 +207,9 @@ meta_cursor_renderer_get_property (GObject *object,
case PROP_BACKEND: case PROP_BACKEND:
g_value_set_object (value, priv->backend); g_value_set_object (value, priv->backend);
break; break;
case PROP_DEVICE:
g_value_set_object (value, priv->device);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -226,6 +231,9 @@ meta_cursor_renderer_set_property (GObject *object,
case PROP_BACKEND: case PROP_BACKEND:
priv->backend = g_value_get_object (value); priv->backend = g_value_get_object (value);
break; break;
case PROP_DEVICE:
priv->device = g_value_get_object (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -286,6 +294,14 @@ meta_cursor_renderer_class_init (MetaCursorRendererClass *klass)
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS); 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); g_object_class_install_properties (object_class, N_PROPS, obj_props);
signals[CURSOR_PAINTED] = g_signal_new ("cursor-painted", signals[CURSOR_PAINTED] = g_signal_new ("cursor-painted",
@ -396,10 +412,12 @@ meta_cursor_renderer_update_cursor (MetaCursorRenderer *renderer,
} }
MetaCursorRenderer * MetaCursorRenderer *
meta_cursor_renderer_new (MetaBackend *backend) meta_cursor_renderer_new (MetaBackend *backend,
ClutterInputDevice *device)
{ {
return g_object_new (META_TYPE_CURSOR_RENDERER, return g_object_new (META_TYPE_CURSOR_RENDERER,
"backend", backend, "backend", backend,
"device", device,
NULL); NULL);
} }
@ -511,3 +529,12 @@ meta_cursor_renderer_is_hw_cursors_inhibited (MetaCursorRenderer *renderer,
return FALSE; return FALSE;
} }
ClutterInputDevice *
meta_cursor_renderer_get_input_device (MetaCursorRenderer *renderer)
{
MetaCursorRendererPrivate *priv =
meta_cursor_renderer_get_instance_private (renderer);
return priv->device;
}

View File

@ -54,7 +54,8 @@ struct _MetaCursorRendererClass
MetaCursorSprite *cursor_sprite); 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, void meta_cursor_renderer_set_cursor (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite); 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, void meta_cursor_renderer_emit_painted (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite); MetaCursorSprite *cursor_sprite);
ClutterInputDevice * meta_cursor_renderer_get_input_device (MetaCursorRenderer *renderer);
void meta_cursor_renderer_update_stage_overlay (MetaCursorRenderer *renderer, void meta_cursor_renderer_update_stage_overlay (MetaCursorRenderer *renderer,
MetaCursorSprite *cursor_sprite); MetaCursorSprite *cursor_sprite);

View File

@ -1724,7 +1724,8 @@ init_hw_cursor_support (MetaCursorRendererNative *cursor_renderer_native)
} }
MetaCursorRendererNative * MetaCursorRendererNative *
meta_cursor_renderer_native_new (MetaBackend *backend) meta_cursor_renderer_native_new (MetaBackend *backend,
ClutterInputDevice *device)
{ {
MetaMonitorManager *monitor_manager = MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend); 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, cursor_renderer_native = g_object_new (META_TYPE_CURSOR_RENDERER_NATIVE,
"backend", backend, "backend", backend,
"device", device,
NULL); NULL);
priv = priv =
meta_cursor_renderer_native_get_instance_private (cursor_renderer_native); meta_cursor_renderer_native_get_instance_private (cursor_renderer_native);

View File

@ -33,6 +33,7 @@ G_DECLARE_FINAL_TYPE (MetaCursorRendererNative, meta_cursor_renderer_native,
META, CURSOR_RENDERER_NATIVE, META, CURSOR_RENDERER_NATIVE,
MetaCursorRenderer) 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 */ #endif /* META_CURSOR_RENDERER_NATIVE_H */

View File

@ -1865,7 +1865,7 @@ update_tablet_cursor_state (MetaSeatNative *seat_native,
g_object_unref); g_object_unref);
} }
cursor_renderer = meta_cursor_renderer_new (meta_get_backend ()); cursor_renderer = meta_cursor_renderer_new (meta_get_backend (), device);
g_hash_table_insert (seat_native->tablet_cursors, g_hash_table_insert (seat_native->tablet_cursors,
device, cursor_renderer); device, cursor_renderer);
} }
@ -3332,7 +3332,8 @@ meta_seat_native_maybe_ensure_cursor_renderer (MetaSeatNative *seat_native,
MetaCursorRendererNative *cursor_renderer_native; MetaCursorRendererNative *cursor_renderer_native;
cursor_renderer_native = cursor_renderer_native =
meta_cursor_renderer_native_new (meta_get_backend ()); meta_cursor_renderer_native_new (meta_get_backend (),
seat_native->core_pointer);
seat_native->cursor_renderer = seat_native->cursor_renderer =
META_CURSOR_RENDERER (cursor_renderer_native); META_CURSOR_RENDERER (cursor_renderer_native);
} }

View File

@ -127,6 +127,7 @@ meta_backend_x11_cm_get_cursor_renderer (MetaBackend *backend,
x11_cm->cursor_renderer = x11_cm->cursor_renderer =
g_object_new (META_TYPE_CURSOR_RENDERER_X11, g_object_new (META_TYPE_CURSOR_RENDERER_X11,
"backend", backend, "backend", backend,
"device", device,
NULL); NULL);
} }

View File

@ -76,6 +76,7 @@ meta_backend_x11_nested_get_cursor_renderer (MetaBackend *backend,
priv->cursor_renderer = priv->cursor_renderer =
g_object_new (META_TYPE_CURSOR_RENDERER_X11_NESTED, g_object_new (META_TYPE_CURSOR_RENDERER_X11_NESTED,
"backend", backend, "backend", backend,
"device", device,
NULL); NULL);
} }