tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 9ea357021925d50a7d3c203011a0c75d54cbad04
parent 198098e9253e65e98ecf5c16f34d0aa29b0a01c7
Author: Martin Stransky <stransky@redhat.com>
Date:   Mon, 15 Dec 2025 08:47:36 +0000

Bug 2004350 [KDE] Don't use stable subsurface rounding on KDE r=emilio

'Stable' Wayland subsurface rounding algorithm is used by all compositors except KDE.
See https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/143#note_1343171 for details.

Differential Revision: https://phabricator.services.mozilla.com/D275962

Diffstat:
Mwidget/gtk/WaylandSurface.cpp | 5++++-
Mwidget/gtk/nsWindow.cpp | 9++++++++-
Mwidget/gtk/nsWindow.h | 8++++++++
3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/widget/gtk/WaylandSurface.cpp b/widget/gtk/WaylandSurface.cpp @@ -941,9 +941,12 @@ bool WaylandSurface::RemoveOpaqueSurfaceHandlerLocked( LayoutDeviceIntSize WaylandSurface::GetScaledSize( const DesktopIntSize& aSize) const { - DesktopIntRect rect(mSubsurfacePosition, aSize); + DesktopIntRect rect( + gUseStableRounding ? mSubsurfacePosition : DesktopIntPoint(), aSize); + auto scaledRect = LayoutDeviceIntRect::Round(rect * DesktopToLayoutDeviceScale(GetScale())); + LOGVERBOSE( "WaylandSurface::GetScaledSize() pos [%d, %d] size [%d x %d] scale %f " "scaled [%d x %d]", diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp @@ -357,6 +357,7 @@ static nsWindow* gFocusWindow = nullptr; static bool gBlockActivateEvent = false; static bool gGlobalsInitialized = false; static bool gUseAspectRatio = true; +bool gUseStableRounding = true; static uint32_t gLastTouchID = 0; // See Bug 1777269 for details. We don't know if the suspected leave notify // event is a correct one when we get it. @@ -592,7 +593,10 @@ void nsWindow::DispatchResized() { return; } - auto clientSize = GetClientSize(); + auto clientSize = gUseStableRounding + ? GetClientSize() + : LayoutDeviceIntSize::Round(mClientArea.Size() * + GetDesktopToDeviceScale()); LOG("nsWindow::DispatchResized() client scaled size [%d, %d]", (int)clientSize.width, (int)clientSize.height); @@ -8804,6 +8808,9 @@ static nsresult initialize_prefs(void) { } else { gUseAspectRatio = IsGnomeDesktopEnvironment() || IsKdeDesktopEnvironment(); } + // 'Stable' Wayland subsurface rounding algorithm is used by all compositors + // except KDE. + gUseStableRounding = !IsKdeDesktopEnvironment() || GdkIsX11Display(); return NS_OK; } diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h @@ -108,6 +108,14 @@ struct _GdkEventTouchpadPinch; typedef struct _GdkEventTouchpadPinch GdkEventTouchpadPinch; #endif +// 'Stable' Wayland subsurface rounding algorithm is used by all compositors +// except KDE. +// See +// https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/143#note_1343171 +// for details. +// We want to replace it by wp-fractional-scale-v2 when it's available. +extern bool gUseStableRounding; + #if !GTK_CHECK_VERSION(3, 22, 0) typedef enum { GDK_ANCHOR_FLIP_X = 1 << 0,