Switch to ClutterActors resource-scale-changed signal

Instead of using the "notify::resource-scale" signal and StWidgets
"resource-scale-changed" signal, use the new "resource-scale-changed"
signal of ClutterActor, which replaces its "resource-scale" property.

Since we'd now have two "resource-scale-changed" signals, one on
ClutterActor and one on StWidget, remove the StWidget one in favour of
the new one.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1287
This commit is contained in:
Jonas Dreßler 2020-05-28 14:43:26 +02:00 committed by Jonas Ådahl
parent cb9842e4a4
commit 1524abc947
6 changed files with 45 additions and 54 deletions

View File

@ -508,9 +508,7 @@ recorder_update_size (ShellRecorder *recorder)
}
static void
recorder_on_stage_notify_size (GObject *object,
GParamSpec *pspec,
ShellRecorder *recorder)
recorder_on_stage_notify_size (ShellRecorder *recorder)
{
recorder_update_size (recorder);
@ -614,12 +612,15 @@ recorder_connect_stage_callbacks (ShellRecorder *recorder)
G_CALLBACK (recorder_on_stage_destroy), recorder);
g_signal_connect_after (recorder->stage, "paint",
G_CALLBACK (recorder_on_stage_paint), recorder);
g_signal_connect (recorder->stage, "notify::width",
G_CALLBACK (recorder_on_stage_notify_size), recorder);
g_signal_connect (recorder->stage, "notify::height",
G_CALLBACK (recorder_on_stage_notify_size), recorder);
g_signal_connect (recorder->stage, "notify::resource-scale",
G_CALLBACK (recorder_on_stage_notify_size), recorder);
g_signal_connect_swapped (recorder->stage, "notify::width",
G_CALLBACK (recorder_on_stage_notify_size),
recorder);
g_signal_connect_swapped (recorder->stage, "notify::height",
G_CALLBACK (recorder_on_stage_notify_size),
recorder);
g_signal_connect_swapped (recorder->stage, "resource-scale-changed",
G_CALLBACK (recorder_on_stage_notify_size),
recorder);
}
static void

View File

@ -106,13 +106,16 @@ st_drawing_area_style_changed (StWidget *self)
}
static void
st_drawing_area_resource_scale_changed (StWidget *self)
st_drawing_area_resource_scale_changed (ClutterActor *self)
{
float resource_scale;
ClutterContent *content = clutter_actor_get_content (CLUTTER_ACTOR (self));
ClutterContent *content = clutter_actor_get_content (self);
resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (self));
resource_scale = clutter_actor_get_resource_scale (self);
clutter_canvas_set_scale_factor (CLUTTER_CANVAS (content), resource_scale);
if (CLUTTER_ACTOR_CLASS (st_drawing_area_parent_class)->resource_scale_changed)
CLUTTER_ACTOR_CLASS (st_drawing_area_parent_class)->resource_scale_changed (self);
}
static void
@ -123,7 +126,7 @@ st_drawing_area_class_init (StDrawingAreaClass *klass)
actor_class->allocate = st_drawing_area_allocate;
widget_class->style_changed = st_drawing_area_style_changed;
widget_class->resource_scale_changed = st_drawing_area_resource_scale_changed;
actor_class->resource_scale_changed = st_drawing_area_resource_scale_changed;
st_drawing_area_signals[REPAINT] =
g_signal_new ("repaint",

View File

@ -231,9 +231,12 @@ st_icon_style_changed (StWidget *widget)
}
static void
st_icon_resource_scale_changed (StWidget *widget)
st_icon_resource_scale_changed (ClutterActor *actor)
{
st_icon_update (ST_ICON (widget));
st_icon_update (ST_ICON (actor));
if (CLUTTER_ACTOR_CLASS (st_icon_parent_class)->resource_scale_changed)
CLUTTER_ACTOR_CLASS (st_icon_parent_class)->resource_scale_changed (actor);
}
static void
@ -250,7 +253,7 @@ st_icon_class_init (StIconClass *klass)
actor_class->paint = st_icon_paint;
widget_class->style_changed = st_icon_style_changed;
widget_class->resource_scale_changed = st_icon_resource_scale_changed;
actor_class->resource_scale_changed = st_icon_resource_scale_changed;
props[PROP_GICON] =
g_param_spec_object ("gicon",

View File

@ -244,11 +244,14 @@ st_label_paint (ClutterActor *actor,
}
static void
st_label_resource_scale_changed (StWidget *widget)
st_label_resource_scale_changed (ClutterActor *actor)
{
StLabelPrivate *priv = ST_LABEL (widget)->priv;
StLabelPrivate *priv = ST_LABEL (actor)->priv;
g_clear_pointer (&priv->text_shadow_pipeline, cogl_object_unref);
if (CLUTTER_ACTOR_CLASS (st_label_parent_class)->resource_scale_changed)
CLUTTER_ACTOR_CLASS (st_label_parent_class)->resource_scale_changed (actor);
}
static void
@ -266,9 +269,9 @@ st_label_class_init (StLabelClass *klass)
actor_class->allocate = st_label_allocate;
actor_class->get_preferred_width = st_label_get_preferred_width;
actor_class->get_preferred_height = st_label_get_preferred_height;
actor_class->resource_scale_changed = st_label_resource_scale_changed;
widget_class->style_changed = st_label_style_changed;
widget_class->resource_scale_changed = st_label_resource_scale_changed;
widget_class->get_accessible_type = st_label_accessible_get_type;
props[PROP_CLUTTER_TEXT] =

View File

@ -124,7 +124,6 @@ enum
{
STYLE_CHANGED,
POPUP_MENU,
RESOURCE_SCALE_CHANGED,
LAST_SIGNAL
};
@ -819,6 +818,20 @@ st_widget_real_get_focus_chain (StWidget *widget)
return g_list_reverse (visible);
}
static void
st_widget_resource_scale_changed (ClutterActor *actor)
{
StWidget *widget = ST_WIDGET (actor);
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
int i;
for (i = 0; i < G_N_ELEMENTS (priv->paint_states); i++)
st_theme_node_paint_state_invalidate (&priv->paint_states[i]);
if (CLUTTER_ACTOR_CLASS (st_widget_parent_class)->resource_scale_changed)
CLUTTER_ACTOR_CLASS (st_widget_parent_class)->resource_scale_changed (actor);
}
static void
st_widget_class_init (StWidgetClass *klass)
{
@ -848,6 +861,8 @@ st_widget_class_init (StWidgetClass *klass)
actor_class->get_accessible = st_widget_get_accessible;
actor_class->has_accessible = st_widget_has_accessible;
actor_class->resource_scale_changed = st_widget_resource_scale_changed;
klass->style_changed = st_widget_real_style_changed;
klass->navigate_focus = st_widget_real_navigate_focus;
klass->get_accessible_type = st_widget_accessible_get_type;
@ -1001,21 +1016,6 @@ st_widget_class_init (StWidgetClass *klass)
G_STRUCT_OFFSET (StWidgetClass, popup_menu),
NULL, NULL, NULL,
G_TYPE_NONE, 0);
/**
* StWidget::resource-scale-changed:
* @widget: the #StWidget
*
* Emitted when the paint scale that the widget will be painted as
* changed.
*/
signals[RESOURCE_SCALE_CHANGED] =
g_signal_new ("resource-scale-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (StWidgetClass, resource_scale_changed),
NULL, NULL, NULL,
G_TYPE_NONE, 0);
}
static const gchar *
@ -1484,23 +1484,6 @@ st_widget_name_notify (StWidget *widget,
st_widget_style_changed (widget);
}
static void
st_widget_resource_scale_notify (StWidget *widget,
GParamSpec *pspec,
gpointer data)
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
int i;
for (i = 0; i < G_N_ELEMENTS (priv->paint_states); i++)
st_theme_node_paint_state_invalidate (&priv->paint_states[i]);
g_signal_emit (widget, signals[RESOURCE_SCALE_CHANGED], 0);
if (clutter_actor_is_mapped (CLUTTER_ACTOR (widget)))
clutter_actor_queue_redraw (CLUTTER_ACTOR (widget));
}
static void
st_widget_reactive_notify (StWidget *widget,
GParamSpec *pspec,
@ -1652,7 +1635,6 @@ st_widget_init (StWidget *actor)
/* connect style changed */
g_signal_connect (actor, "notify::name", G_CALLBACK (st_widget_name_notify), NULL);
g_signal_connect (actor, "notify::resource-scale", G_CALLBACK (st_widget_resource_scale_notify), NULL);
g_signal_connect (actor, "notify::reactive", G_CALLBACK (st_widget_reactive_notify), NULL);
g_signal_connect (actor, "notify::visible", G_CALLBACK (st_widget_visible_notify), NULL);

View File

@ -63,7 +63,6 @@ struct _StWidgetClass
/* signals */
void (* style_changed) (StWidget *self);
void (* popup_menu) (StWidget *self);
void (* resource_scale_changed) (StWidget *self);
/* vfuncs */