After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 765327 - GtkPlug scaled to half the expected size on HiDPI screens
GtkPlug scaled to half the expected size on HiDPI screens
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Backend: X11
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-04-20 14:32 UTC by marmuta
Modified: 2018-04-15 00:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screen shot of sample GtkSocket (black) with embedded GtkPlug (blue) (9.60 KB, image/jpeg)
2016-04-20 14:32 UTC, marmuta
  Details
GtkPlug sample (1.74 KB, text/x-csrc)
2016-04-20 14:35 UTC, marmuta
  Details
GtkSocket sample (1021 bytes, text/x-csrc)
2016-04-20 14:36 UTC, marmuta
  Details
Patch that unscales plug size before XSendEvent (646 bytes, patch)
2016-04-24 20:47 UTC, marmuta
needs-work Details | Review
Unscale plug size before sending XConfigureEvent (Bug 765327). (1.21 KB, patch)
2016-06-12 13:48 UTC, marmuta
none Details | Review

Description marmuta 2016-04-20 14:32:13 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
Comment 1 marmuta 2016-04-20 14:35:38 UTC
Created attachment 326423 [details]
GtkPlug sample
Comment 2 marmuta 2016-04-20 14:36:04 UTC
Created attachment 326424 [details]
GtkSocket sample
Comment 3 marmuta 2016-04-20 14:37:22 UTC
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))
Comment 4 marmuta 2016-04-24 20:47:39 UTC
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.
Comment 5 marmuta 2016-06-10 13:21:50 UTC
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.
Comment 6 Emmanuele Bassi (:ebassi) 2016-06-10 13:41:40 UTC
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.
Comment 7 marmuta 2016-06-12 13:48:14 UTC
Created attachment 329637 [details] [review]
Unscale plug size before sending XConfigureEvent (Bug 765327).
Comment 8 marmuta 2016-06-12 14:01:25 UTC
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.
Comment 9 Matthias Clasen 2018-02-10 05:04:24 UTC
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.
Comment 10 Matthias Clasen 2018-04-15 00:22:46 UTC
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