Hi all, Now we have quite a lot of display backends for different use cases. Even in the context of gtk, we have various implementations (e.g., gl=on vs gl=off, X11 vs Wayland). However, behaviors to users are not aligned across the backends, especially in the part of scale handling. This patch set attempts to improve scale handling.
We have to deal with various coordinates due to the existence of scaling in different level. Firstly, in desktop level, we could have a global window scale factor. Secondly, users might set a zooming factor to adjust the size of guest content in scan-out level. Consequently, 1) the buffer from guest, 2) the host window and 3) OpenGl drawing area inside the host window are in distinct coordinates. It's important to define these coordinates and scales unambiguously and use a consistent naming convention for variables representing different concepts. The first patch in this set tries to achieve this goal by adding a document in gtk.c, and the next patch (PATCH 2) attempts to align the code with the document. PATCH 3 - 5 fix bugs in mouse position calculation due to not handling scale properly, for both gtk and sdl. PATCH 6 align scale update logic in gtk-egl with other implementations. PATCH 7 fix an issue that gtk window might keep enlarging/shrinking because ui info propagating to guest not considering scale. PATCH 8 and 9 align fixed-scale mode behavior in gtk-gl-area and gtk-egl with other implementations by adding appropriate padding to the window to preserve the scale. Tested cases: - qemu-kvm -display gtk,gl=on (free scale mode, fixed scale mode, full screen mode) - qemu-kvm -display gtk,gl=off (free scale mode, fixed scale mode, full screen mode) - GDK_BACKEND=x11 qemu-kvm -display gtk,gl=off (free scale mode, fixed scale mode, full screen mode) - qemu-kvm -display sdl,gl=off - qemu-kvm -display sdl,gl=on Cc: Marc-André Lureau <marcandre.lur...@redhat.com> Cc: Gerd Hoffmann <kra...@redhat.com> Cc: Dmitry Osipenko <dmitry.osipe...@collabora.com> Cc: Alex Bennée <alex.ben...@linaro.org> Cc: Vivek Kasireddy <vivek.kasire...@intel.com> Cc: Dongwon Kim <dongwon....@intel.com> Best regards, Weifeng Weifeng Liu (9): ui/gtk: Document scale and coordinate handling ui/gtk: Use consistent naming for variables in different coordinates gtk/ui: Introduce helper gd_update_scale ui/gtk: Update scales in fixed-scale mode when rendering GL area ui/sdl: Consider scaling in mouse event handling ui/gtk: Don't update scale in fixed scale mode in gtk-egl.c ui/gtk: Consider scaling when propagating ui info ui/gtk-gl-area: Render guest content with padding in fixed-scale mode ui/gtk-egl: Render guest content with padding in fixed-scale mode include/ui/egl-helpers.h | 4 +- include/ui/gtk.h | 2 + ui/egl-helpers.c | 10 +- ui/gtk-egl.c | 58 ++++++--- ui/gtk-gl-area.c | 53 +++++++-- ui/gtk.c | 245 +++++++++++++++++++++++++++------------ ui/sdl2-gl.c | 2 +- ui/sdl2.c | 20 +++- 8 files changed, 290 insertions(+), 104 deletions(-) -- 2.49.0