tor-browser

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

commit adc5a7fa4ebb6efe9789ecbf0d057cf663b71174
parent da8dbdb93bf7e257ba0b8c6e24dbefba75173eaa
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Wed, 17 Dec 2025 19:38:35 +0000

Bug 2001722 - Clamp system decoration offset if the WM gives us broken rects. r=stransky

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

Diffstat:
Mwidget/gtk/nsWindow.cpp | 18++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp @@ -3362,8 +3362,22 @@ void nsWindow::RecomputeBoundsX11(bool aMayChangeCsdMargin) { LOGVERBOSE(" toplevelBounds %s", ToString(toplevelBounds).c_str()); // Offset from system decoration to gtk decoration. - const auto systemDecorationOffset = - toplevelBounds.TopLeft() - toplevelBoundsWithTitlebar.TopLeft(); + const auto systemDecorationOffset = [&] { + auto offset = + toplevelBounds.TopLeft() - toplevelBoundsWithTitlebar.TopLeft(); + // If the WM sends us broken values, try to clamp to something sensible. + // The offset will never be more than the bounds difference, nor negative. + // See bug 2001722 for an example where this happened. + offset.x = + std::max(std::min(int32_t(offset.x), toplevelBoundsWithTitlebar.width - + toplevelBounds.width), + 0); + offset.y = + std::max(std::min(int32_t(offset.y), toplevelBoundsWithTitlebar.height - + toplevelBounds.height), + 0); + return offset; + }(); // This is relative to our parent window, that is, to topLevelBounds. mClientArea = GetBounds(mGdkWindow);