From be70d9a9c783d2afb27d8b8a677846ed7d8358e6 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Thu, 16 Mar 2023 13:35:06 -0400
Subject: [PATCH] wayland: Clarify the popup position restriction purpose
Child popups don't necessarily need to be within, but must intersect or be partially adjacent to the parent, per the xdg-positioner spec.
---
src/video/wayland/SDL_waylandwindow.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index 70ef278b43b9..1d71a2808671 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -242,12 +242,14 @@ static void ConfigureWindowGeometry(SDL_Window *window)
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED, data->drawable_width, data->drawable_height);
}
-static void EnsurePopupIsWithinParent(SDL_Window *window)
+static void EnsurePopupPositionIsValid(SDL_Window *window)
{
- /* Per the spec, popup windows *must* overlap the parent window.
- * Failure to do so on a compositor that enforces this restriction
- * will result in the window being spuriously closed at best, and
- * a protocol violation at worst.
+ /* Per the xdg-positioner spec, child popup windows must intersect or at
+ * least be partially adjacent to the parent window.
+ *
+ * Failure to ensure this on a compositor that enforces this restriction
+ * can result in behavior ranging from the window being spuriously closed
+ * to a protocol violation.
*/
if (window->x + window->w < 0) {
window->x = -window->w;
@@ -1950,7 +1952,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
}
if (SDL_WINDOW_IS_POPUP(window)) {
- EnsurePopupIsWithinParent(window);
+ EnsurePopupPositionIsValid(window);
}
data->waylandData = c;
@@ -2088,7 +2090,7 @@ void Wayland_SetWindowPosition(_THIS, SDL_Window *window)
xdg_popup_get_version(wind->shell_surface.xdg.roleobj.popup.popup) >= XDG_POPUP_REPOSITION_SINCE_VERSION) {
int x, y;
- EnsurePopupIsWithinParent(window);
+ EnsurePopupPositionIsValid(window);
GetPopupPosition(window, window->x, window->y, &x, &y);
xdg_positioner_set_offset(wind->shell_surface.xdg.roleobj.popup.positioner, x, y);
xdg_popup_reposition(wind->shell_surface.xdg.roleobj.popup.popup,