diff options
author | Lionel Landwerlin <llandwerlin@gmail.com> | 2015-12-01 22:38:01 +0000 |
---|---|---|
committer | Lionel Landwerlin <llandwerlin@gmail.com> | 2015-12-03 21:53:13 +0000 |
commit | 3609c70c3518a83d362e81e37e21c335bff49c1b (patch) | |
tree | d904632c05d7855d47e64c023663361440ae8be7 | |
parent | e63dbfc883ea8762013e3af79bf1a27219431b29 (diff) | |
download | clutter-gtk-3609c70c3518a83d362e81e37e21c335bff49c1b.tar.gz |
actor: propagate scale factor from embedder to embedded
We need to set the scale factor correctly on the embedded Gtk+ widgets to
avoid blurry widgets on hidpi displays.
https://bugzilla.gnome.org/show_bug.cgi?id=758937
-rw-r--r-- | clutter-gtk/gtk-clutter-actor.c | 15 | ||||
-rw-r--r-- | clutter-gtk/gtk-clutter-offscreen.c | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/clutter-gtk/gtk-clutter-actor.c b/clutter-gtk/gtk-clutter-actor.c index 9582154..6b78628 100644 --- a/clutter-gtk/gtk-clutter-actor.c +++ b/clutter-gtk/gtk-clutter-actor.c @@ -199,6 +199,7 @@ gtk_clutter_actor_realize (ClutterActor *actor) else #endif { + GdkWindow *window = gtk_widget_get_window (priv->widget); int width = gtk_widget_get_allocated_width (priv->widget); int height = gtk_widget_get_allocated_height (priv->widget); @@ -206,6 +207,8 @@ gtk_clutter_actor_realize (ClutterActor *actor) clutter_actor_set_size (priv->texture, width, height); + clutter_canvas_set_scale_factor (CLUTTER_CANVAS (priv->canvas), + gdk_window_get_scale_factor (window)); /* clutter_canvas_set_size() will invalidate its contents only * if the size differs, but we want to invalidate the contents * in any case; we cannot call clutter_content_invalidate() @@ -310,6 +313,7 @@ gtk_clutter_actor_allocate (ClutterActor *actor, GtkAllocation child_allocation; GdkWindow *window; ClutterActorBox child_box; + gint dummy; _gtk_clutter_offscreen_set_in_allocation (GTK_CLUTTER_OFFSCREEN (priv->widget), TRUE); @@ -317,6 +321,15 @@ gtk_clutter_actor_allocate (ClutterActor *actor, child_allocation.y = 0; child_allocation.width = clutter_actor_box_get_width (box); child_allocation.height = clutter_actor_box_get_height (box); + + /* Silence the following GTK+ warning: + * + * Gtk-WARNING **: Allocating size to Offscreen Container + * without calling gtk_widget_get_preferred_width/height(). How does the + * code know the size to allocate? + */ + gtk_widget_get_preferred_width (priv->widget, &dummy, NULL); + gtk_widget_size_allocate (priv->widget, &child_allocation); if (CLUTTER_ACTOR_IS_REALIZED (actor)) @@ -352,6 +365,8 @@ gtk_clutter_actor_allocate (ClutterActor *actor, { DEBUG (G_STRLOC ": Using image surface.\n"); + clutter_canvas_set_scale_factor (CLUTTER_CANVAS (priv->canvas), + gdk_window_get_scale_factor (window)); clutter_canvas_set_size (CLUTTER_CANVAS (priv->canvas), gtk_widget_get_allocated_width (priv->widget), gtk_widget_get_allocated_height (priv->widget)); diff --git a/clutter-gtk/gtk-clutter-offscreen.c b/clutter-gtk/gtk-clutter-offscreen.c index c54010d..7243420 100644 --- a/clutter-gtk/gtk-clutter-offscreen.c +++ b/clutter-gtk/gtk-clutter-offscreen.c @@ -144,6 +144,8 @@ gtk_clutter_offscreen_realize (GtkWidget *widget) gtk_widget_set_window (widget, window); gdk_window_set_user_data (window, widget); + gdk_offscreen_window_set_embedder (gtk_widget_get_window (parent), + window); g_signal_connect (window, "to-embedder", G_CALLBACK (offscreen_window_to_parent), widget); |