GNOME Bugzilla – Bug 765327
GtkPlug scaled to half the expected size on HiDPI screens
Last modified: 2018-04-15 00:22:46 UTC
Created attachment 326422 [details] Screen shot of sample GtkSocket (black) with embedded GtkPlug (blue) With org.gnome.desktop.interface.scaling-factor set to 2, GtkPlug appears to be scaled twice and becomes half the size of the GtkSocket in x and y direction. Depending on the size of the socket and the complexity of the layout this effect may disappear and reappear. It consistently happens with Onboard in unity-greeter and gnome-screensaver and makes the keyboard nearly unusable there. See attached screen shot. Blue is a GtkPlug, black is a GtkSocket. Source code below. What I expect to happen is that the GtkPlug has the same size as the GtkSocket. What actually happens is that GtkPlug only covers a quarter of the area of the GtkSocket. Steps to reproduce: - build plug and socket samples from below - set display scaling factor to 2 System Settings -> Display -> Scale for menu and title bars = 2 - run ./socket $(head -1 <(./plug)) -> blue GtkPlug is too small, it should cover all the black - resize the window -> at smaller sizes the scaling suddenly corrects itself, at larger ones it's wrong again Ubuntu bug reports: https://bugs.launchpad.net/ubuntu/+source/gtk+3.0/+bug/1572331 https://bugs.launchpad.net/ubuntu/+source/onboard/+bug/1562734
Created attachment 326423 [details] GtkPlug sample
Created attachment 326424 [details] GtkSocket sample
Build sample code with: gcc -o plug plug.c `pkg-config --cflags --libs gtk+-3.0` gcc -o socket socket.c `pkg-config --cflags --libs gtk+-3.0` and run as: ./socket $(head -1 <(./plug))
Created attachment 326644 [details] [review] Patch that unscales plug size before XSendEvent The patch fixes the issue for the sample code and unity-greeter. Gnome-screensaver does better too, but still cuts off the lower ~25% of the keyboard. This has been happening before the patch, so it might be a different problem.
Can we get a review of the patch, please? It's just 3 lines. The rational for the change is that the widget scaling factor is a Gtk construct and the X server doesn't know about it, hence X events ought to be in unscaled space. When Gtk sends XConfigureEvent it should be using unscaled coordinates too.
Review of attachment 326644 [details] [review]: Could you please attach a patch generated using `git format-patch` or, even better, via git-bz? That would simplify the review process and the attribution. ::: gtk/gtksocket.c @@ +591,2 @@ gtk_widget_get_allocation (GTK_WIDGET(socket), &allocation); + gint scale = gtk_widget_get_scale_factor (GTK_WIDGET(socket)); GTK+ does not allow C99-style declarations after statements. You should declare `scale` at the top.
Created attachment 329637 [details] [review] Unscale plug size before sending XConfigureEvent (Bug 765327).
Thank you. I've tested the latest patch with gtk+3.0-3.18.9 of Ubuntu Xenial (sample code, unity-greeter, gnome-scrensaver) and git master (sample code). Fixes this bug for me.
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla. If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab: https://gitlab.gnome.org/GNOME/gtk/issues/new