Skip to content

KWin 6: Use client/frame geometry instead of buffer geometry except for GTK 3

For most toolkits, window-relative coordinates reported via AT-SPI are relative to the top-left corner of the window's client geometry if the window has no client side decoration and relative to the frame geometry if the window has client side decoration. So far, Accerciser's implementation to retrieve coordinates via KWin (and the suggested GNOME Shell/Mutter one [1]) was using the buffer geometry. This is fine for the cases where both match, but was resulting in a wrong highlighted area e.g. for gtk4-demo, where the buffer geometry differs from the client/frame geometry (buffer geometry is larger).

For KWin 6, the client geometry is also available via the KWin API, added in KWin commit [2]

    commit 51642177e370f4cf902d15494f700c27a9961b9c
    Author: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
    Date:   Fri Dec 22 14:44:09 2023 +0200

        Add Window.clientGeometry property

And the frame geometry is available as well.

Therefore, use that in general for the window geometry for KWin 6, but keep the info on buffer geometry as well:

  • Add a new buffer_geometry member to the WindowInfo class, default to None.

  • Extend the KWin 6 script to return the client/frame geometry as well. Assume there is a client side decoration when the client rect contains the frame rect, and use the frame rect geometry then, otherwise use the client geometry. For the KWin 5 script, the client geometry is not available yet, so just return the same values as for the buffer geometry (behaviour will remain unchanged there).

  • Set the client or frame size for window geometry in KWinWindowManager and also the info for the buffer size.

When testing, it turned out that GTK 3 applications like Evince and gedit appear to be reporting window-relative coordinates and frame sizes that refer to the buffer geometry rather than the client/frame geometry, though.

Therefore, keep using the buffer geometry for GTK 3 applications for now and use client/frame geometry for everything else.

With this commit in place, the correct area is now highlighted for all tested applications (Qt 6 qtbase standarddialogs example, gedit, evince, gtk4-demo) when using ACCERCISER_WINDOW_MANAGER=kwin in a KDE Plasma Wayland session on Fedora Rawhide when running them as native Wayland applications or on XWayland.

Many thanks to Sebastian Keller for explaining that the frame geometry needs to be used instead of the client geometry when client side decoration is used, see discussion in [3] (issue created for incorrect highlighting I noticed when implementing the GnomeShellWindowManager equivalent for this commit, for the GNOME Shell/Mutter implementation suggested in [1]).

[1] !56 [2] https://invent.kde.org/plasma/kwin/-/commit/51642177e370f4cf902d15494f700c27a9961b9c [3] gnome-shell#7559 (closed)

Edited by Michael Weghorn

Merge request reports