From b0cdb7143fb423b808e3b2c010368e6d49550054 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Thu, 31 Jul 2025 12:13:07 -0400
Subject: [PATCH] wayland: Adjust popup adjoining check
The previous calculation could result in a window whose original position was positioned exactly corner-to-corner with the parent not being adjusted to be adjoining, and thus subject to spurious closure.
---
src/video/wayland/SDL_waylandwindow.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index 84270567fdfe9..3712484df38f9 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -215,32 +215,32 @@ static void EnsurePopupPositionIsValid(SDL_Window *window, int *x, int *y)
int adj_count = 0;
/* Per the xdg-positioner spec, child popup windows must intersect or at
- * least be partially adjacent to the parent window.
+ * least be partially adjoining 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 (*x + window->w < 0) {
+ if (*x + window->w <= 0) {
*x = -window->w;
++adj_count;
}
- if (*y + window->h < 0) {
+ if (*y + window->h <= 0) {
*y = -window->h;
++adj_count;
}
- if (*x > window->parent->w) {
+ if (*x >= window->parent->w) {
*x = window->parent->w;
++adj_count;
}
- if (*y > window->parent->h) {
+ if (*y >= window->parent->h) {
*y = window->parent->h;
++adj_count;
}
/* If adjustment was required on the x and y axes, the popup is aligned with
- * the parent corner-to-corner and is neither overlapping nor adjacent, so it
- * must be nudged by 1 to be considered adjacent.
+ * the parent corner-to-corner and is neither overlapping nor adjoining, so it
+ * must be nudged by 1 to be considered adjoining.
*/
if (adj_count > 1) {
*x += *x < 0 ? 1 : -1;