Skip to content

Commit b0cdb71

Browse files
committed
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.
1 parent 88cbe85 commit b0cdb71

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/video/wayland/SDL_waylandwindow.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,32 +215,32 @@ static void EnsurePopupPositionIsValid(SDL_Window *window, int *x, int *y)
215215
int adj_count = 0;
216216

217217
/* Per the xdg-positioner spec, child popup windows must intersect or at
218-
* least be partially adjacent to the parent window.
218+
* least be partially adjoining the parent window.
219219
*
220220
* Failure to ensure this on a compositor that enforces this restriction
221221
* can result in behavior ranging from the window being spuriously closed
222222
* to a protocol violation.
223223
*/
224-
if (*x + window->w < 0) {
224+
if (*x + window->w <= 0) {
225225
*x = -window->w;
226226
++adj_count;
227227
}
228-
if (*y + window->h < 0) {
228+
if (*y + window->h <= 0) {
229229
*y = -window->h;
230230
++adj_count;
231231
}
232-
if (*x > window->parent->w) {
232+
if (*x >= window->parent->w) {
233233
*x = window->parent->w;
234234
++adj_count;
235235
}
236-
if (*y > window->parent->h) {
236+
if (*y >= window->parent->h) {
237237
*y = window->parent->h;
238238
++adj_count;
239239
}
240240

241241
/* If adjustment was required on the x and y axes, the popup is aligned with
242-
* the parent corner-to-corner and is neither overlapping nor adjacent, so it
243-
* must be nudged by 1 to be considered adjacent.
242+
* the parent corner-to-corner and is neither overlapping nor adjoining, so it
243+
* must be nudged by 1 to be considered adjoining.
244244
*/
245245
if (adj_count > 1) {
246246
*x += *x < 0 ? 1 : -1;

0 commit comments

Comments
 (0)