PhoshOverview: Make sure the requested thumbnail is scaled according to widget size

The last-minute change before merging !481 introduced a performance regression
due to accidentally disabling compositor-side thumbnail scaling. This change
brings it back, which should noticeably improve performance on the Librem 5.
parent 4cd1847e
Pipeline #56778 passed with stages
in 36 minutes and 9 seconds
......@@ -165,17 +165,25 @@ on_thumbnail_ready_changed (PhoshThumbnail *thumbnail, GParamSpec *pspec, PhoshA
static void
request_thumbnail (PhoshOverview *self, PhoshToplevel *toplevel)
request_thumbnail (PhoshActivity *activity, PhoshToplevel *toplevel)
PhoshToplevelThumbnail *thumbnail;
gint width, height;
PhoshActivity *activity = find_activity_by_toplevel (self, toplevel);
gint scale = gtk_widget_get_scale_factor (GTK_WIDGET (activity));
g_object_get (activity, "win-width", &width, "win-height", &height, NULL);
thumbnail = phosh_toplevel_thumbnail_new_from_toplevel (toplevel, width * scale, height * scale);
GtkAllocation allocation;
gint scale;
g_return_if_fail (PHOSH_IS_ACTIVITY (activity));
g_return_if_fail (PHOSH_IS_TOPLEVEL (toplevel));
scale = gtk_widget_get_scale_factor (GTK_WIDGET (activity));
gtk_widget_get_allocation (GTK_WIDGET (activity), &allocation);
thumbnail = phosh_toplevel_thumbnail_new_from_toplevel (toplevel, allocation.width * scale, allocation.height * scale);
g_signal_connect_object (thumbnail, "notify::ready", G_CALLBACK (on_thumbnail_ready_changed), activity, 0);
static void
on_activity_size_allocated (PhoshActivity *activity, GtkAllocation *alloc, PhoshToplevel *toplevel)
request_thumbnail (activity, toplevel);
static void
add_activity (PhoshOverview *self, PhoshToplevel *toplevel)
......@@ -210,6 +218,8 @@ add_activity (PhoshOverview *self, PhoshToplevel *toplevel)
g_signal_connect_object (toplevel, "notify::activated", G_CALLBACK (on_toplevel_activated_changed), self, 0);
g_object_bind_property (toplevel, "maximized", activity, "maximized", G_BINDING_DEFAULT);
g_signal_connect (activity, "size-allocate", G_CALLBACK (on_activity_size_allocated), toplevel);
phosh_connect_button_feedback (GTK_BUTTON (activity));
if (phosh_toplevel_is_activated (toplevel))
......@@ -262,7 +272,7 @@ toplevel_changed_cb (PhoshOverview *self,
/* TODO: update other properties */
phosh_activity_set_title (activity,
phosh_toplevel_get_title (toplevel));
request_thumbnail (self, toplevel);
request_thumbnail (activity, toplevel);
static void
......@@ -302,7 +312,6 @@ phosh_overview_size_allocate (GtkWidget *widget,
"win-width", alloc->width,
"win-height", alloc->height,
request_thumbnail (self, get_toplevel_from_activity (PHOSH_ACTIVITY (l->data)));
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment