Magnifier: Incorrect screen region shown when typing in native Wayland application/Incorrect client region reported for window
Affected version
- Fedora Rawhide up-to-date as of 2024-04-03
- GNOME Shell 46.0
Bug summary
When using GNOME Magnifier in a GNOME Wayland session, the screen area shown when typing in a text widget of a native Wayland application is incorrect. This is particularly visible with large scale factors, in which case it can happen that the text being typed is not visible at all as another screen area is shown.
Steps to reproduce
-
log into GNOME Wayland session
-
run the attached sample application gtk4-sample.py as a native Wayland application:
./gtk4-sample.py
-
Move the sample application to the bottom of the screen (i.e. so that the bottom edge of the application window aligns with the bottom edge of the screen/desktop)
-
In GNOME accessibility settings, enable "Desktop Zoom" and set a magnification factor of 10.00.
-
Switch to the sample app using Alt+Tab
-
start typing
What happened
The focus automatically switches due to the typing, but the GtkEntry where the text is typed is not shown.
What did you expect to happen
The zoomed into area should include the widget that is being typed into.
Relevant logs, screenshots, screencasts etc.
Further information:
a. The same scenario works just fine when running the sample application on XWayland instead, by starting it like this in step 2 instead:
GDK_BACKEND=x11 ./gtk4-sample.py
b. Related LibreOffice bug report: https://bugs.documentfoundation.org/show_bug.cgi?id=159369
c. From what I can see, the problem is that the client size as retrieved from the Meta.Window
is incorrect. I also ran into the same issue when working on support for retrieving window coordinates from GNOME Shell/Mutter for Accerciser on Wayland (related issue: accerciser#41 ).
Likely relevant code: https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/8afc735f9daf770516faef77049d2e38eae01adb/js/ui/magnifier.js#L863-865
Another scenario used for analysis:
-
extract the attached sample extension sample_example.org.tar.gz into
~/.local/share/gnome-shell/extensions/
-
log out and in again (so the extension becomes available)
-
start the attached sample app as a native Wayland app:
./gtk4-sample.py
-
let another instance of the sample app run on XWayland:
GDK_BACKEND=x11 ./gtk4-sample.py
-
move both of the windows of the sample app to the top edge of the screen (i.e. so that the top edge of the frame touches the top edge of the screen)
-
enable extension (which also causes it to print current window information)
gnome-extensions enable sample@example.org
-
check the extension's output in systemd journal:
sudo journalctl -e
Sample output:
Apr 03 13:17:03 fedora gnome-shell[23153]: title: Wayland to X Recording bridge — Xwayland Video Bridge, bufferRect: (-99, 0, 100, 100), , frameRect: (0, 99, 1, 1), , clientRect: (-99, 0, 100, 100)
Apr 03 13:17:03 fedora gnome-shell[23153]: title: sample-app, bufferRect: (2301, -12, 354, 100), , frameRect: (2315, 0, 326, 71), , clientRect: (2301, -12, 354, 100)
Apr 03 13:17:03 fedora gnome-shell[23153]: title: sample-app, bufferRect: (2782, -12, 196, 100), , frameRect: (2796, 0, 168, 71), , clientRect: (2796, 37, 168, 34)
Apr 03 13:17:03 fedora gnome-shell[23153]: title: user@fedora:~/development/git/accerciser/2024-04-03_files_for_gnome-shell_bug_report_incorrect_wayland_client_geometry — gnome-extensions enable sample@example.org, bufferRect: (0, 29, 1920, 1051), , frameRect: (0, 29, 1920, 1051), , clientRect: (0, 29, 1920, 1051)
Actual result:
- Client rect for the app running on XWayland is correct:
clientRect: (2796, 37, 168, 34)
- Client rect for the sample app running as native Wayland app is wrong: clientRect:
(2301, -12, 354, 100)
The y coordinate has to be > 0, as the window is top-aligned to the top edge of the screen (y=0) and the window has an extra frame.