tor-browser

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

commit 1e9cedee9d66a3c08d2d4a11adf14ff46c6b5235
parent 40abcdfe7abfbe223fea25625cef3f3dc224c5a9
Author: stransky <stransky@redhat.com>
Date:   Tue,  4 Nov 2025 19:13:38 +0000

Bug 1990483 [Wayland] Recalc popup position if it's set at Create() only r=emilio

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

Diffstat:
Mwidget/gtk/nsWindow.cpp | 10++++++++--
Mwidget/gtk/nsWindow.h | 6++++++
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp @@ -437,6 +437,7 @@ nsWindow::nsWindow() mPopupTrackInHierarchy(false), mPopupTrackInHierarchyConfigured(false), mX11HiddenPopupPositioned(false), + mWaylandApplyPopupPositionBeforeShow(true), mHasAlphaVisual(false), mPopupAnchored(false), mPopupContextMenu(false), @@ -2326,6 +2327,9 @@ void nsWindow::NativeMoveResizeWaylandPopup(bool aMove, bool aResize) { return; } + // It's safe to expect the popup position is handled onwards. + mWaylandApplyPopupPositionBeforeShow = false; + // We expect all Wayland popus have zero margin. If not, just position // it as is and throw an error message. if (!mClientMargin.IsAllZero()) { @@ -6455,8 +6459,6 @@ nsresult nsWindow::Create(nsIWidget* aParent, const LayoutDeviceIntRect& aRect, // on Wayland as we place Wayland popup on show. if (GdkIsX11Display()) { NativeMoveResize(/* move */ true, /* resize */ false); - } else if (AreBoundsSane()) { - mPopupPosition = {mClientArea.x, mClientArea.y}; } } else { // must be WindowType::TopLevel mGtkWindowRoleName = "Toplevel"; @@ -6824,6 +6826,7 @@ void nsWindow::NativeMoveResize(bool aMoved, bool aResized) { auto cr = frameRect; // In CSD mode gtk_window_move() / gtk_window_resize() expects coordinates // without CSD frame so remove it. + // Note that popups should have zero margin. cr.Deflate(mClientMargin); // SSD mode expects coordinates with decorations (outer frame) // so put the margin offset back. @@ -6985,6 +6988,9 @@ void nsWindow::NativeShow(bool aAction) { return; } } + if (mWaylandApplyPopupPositionBeforeShow) { + NativeMoveResize(/* move */ true, /* resize */ false); + } } // Set up usertime/startupID metadata for the created window. // On X11 we use gtk_window_set_startup_id() so we need to call it diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h @@ -795,6 +795,12 @@ class nsWindow final : public nsIWidget { */ bool mX11HiddenPopupPositioned : 1; + /* If popup is not positioned explicitly before show on Wayland, + * apply usual popup measurement on Show() to make sure + * it's placed correctly according to initial position set by Create(). + */ + bool mWaylandApplyPopupPositionBeforeShow : 1; + // True when we're on compositing window manager and this // window is using visual with alpha channel. bool mHasAlphaVisual : 1;