GNOME Bugzilla – Bug 765421
Overscaled GtkImage in Wayland
Last modified: 2016-04-22 12:38:02 UTC
In lollypop, I set GtkImage using a GdkPixbuf. I do this: - Load pixbuf at size * scale_factor - Put pixbuf in a cairo surface - Set GtkImage from surface In Xorg, with GDK_SCALE=1 or GDK_SCALE=2, it works as expected. In wayland, it seems GtkImage is resized to Pixbuf size https://github.com/gnumdk/lollypop/issues/582
You put the GdkPixbuf in a cairo surface of what scale factor?
Cairo surface knows screen scale factor, no?
Here code example: import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk, GdkPixbuf, Gdk image = Gtk.Image() pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("/usr/share/icons/Adwaita/256x256/apps/web-browser.png", 100*image.get_scale_factor(), 100*image.get_scale_factor()) surface = Gdk.cairo_surface_create_from_pixbuf(pixbuf, 0, None) image.set_from_surface(surface) win = Gtk.Window() win.connect("delete-event", Gtk.main_quit) win.add(image) win.show_all() Gtk.main()
But you're not passing a GdkWindow to Gdk.cairo_surface_create_from_pixbuf, it doesn't know what scale factor to use for 0. Try passing a window as last argument or your image.get_scale_factor() as second to last.
Why does it work on Xorg? Will try but can't test as GDK_SCALE doesn't work here on Fedora + Gnome 3.18 and ArchLinux + Gnome 3.20, any idea?
Passing the GdkWindow doesn't change the issue. Here what is happening with previous example. Xorg: - GDK_SCALE=1 => image is 100px - GDK_SCALE=2 => image is 200px Wayland: - GDK_SCALE=1 => image is 100px - GDK_SCALE=2 => image is 400px
Passing the scale factor works...