commit c1981b6476c94224a6068825a17bc1733735618e
parent 87bd407c04f0f78563e9ba171651c6b046ab5851
Author: stransky <stransky@redhat.com>
Date: Mon, 5 Jan 2026 12:45:43 +0000
Bug 2005847 [Wayland] Substract toplevel margin to check child popup boundaries r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D276604
Diffstat:
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp
@@ -2251,15 +2251,21 @@ bool nsWindow::WaylandPopupFitsToplevelWindow() {
int parentWidth = gdk_window_get_width(toplevelGdkWindow);
int parentHeight = gdk_window_get_height(toplevelGdkWindow);
- LOG(" parent size %d x %d", parentWidth, parentHeight);
-
- GdkRectangle requestedRect{mLastMoveRequest.x, mLastMoveRequest.y,
- mLastSizeRequest.width, mLastSizeRequest.height};
- LOG(" popup topleft %d, %d size %d x %d", requestedRect.x, requestedRect.y,
- requestedRect.width, requestedRect.height);
- bool fits = requestedRect.x >= 0 && requestedRect.y >= 0 &&
- requestedRect.x + requestedRect.width <= parentWidth &&
- requestedRect.y + requestedRect.height <= parentHeight;
+ DesktopIntRect parentWidgetRect(0, 0, parentWidth, parentHeight);
+
+ nsWindow* parentWindow = get_window_for_gtk_widget(GTK_WIDGET(parent));
+ if (!parentWindow) {
+ return false;
+ }
+
+ LOG(" parent size %d x %d", parentWindow->mClientArea.width,
+ parentWindow->mClientArea.height);
+
+ DesktopIntRect popupRect(mLastMoveRequest, mLastSizeRequest);
+ LOG(" popup topleft %d, %d size %d x %d", popupRect.x, popupRect.y,
+ popupRect.width, popupRect.height);
+
+ bool fits = parentWindow->mClientArea.Contains(popupRect);
LOG(" fits %d", fits);
return fits;
}