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
This commit is contained in:
Carlos Garnacho 2020-07-13 13:32:48 +02:00
parent 60fa895ae3
commit dc022a67b0
7 changed files with 41 additions and 6 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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 */

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}