From 17bdea7a9137e835c6b6c0926eab9484afba2677 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 6 Apr 2023 15:12:09 -0700 Subject: [PATCH] Fix pop-up windows changing position for each HideWindow()/ShowWindow() cycle When X11_UpdateWindowPosition() was called and the position didn't update we would fire an SDL_EVENT_WINDOW_MOVED event with the global x,y for the pop-up instead of the relative position for the pop-up. This change ensures we always have a relative position for pop-ups before sending the SDL_EVENT_WINDOW_MOVED event. --- src/video/x11/SDL_x11window.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index eb6ad1d403..5751949cf1 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -929,9 +929,6 @@ void X11_UpdateWindowPosition(SDL_Window *window) if (!caught_x11_error) { if ((x != orig_x) || (y != orig_y)) { - if (SDL_WINDOW_IS_POPUP(window)) { - SDL_GlobalToRelativeForWindow(window, x, y, &x, &y); - } break; /* window moved, time to go. */ } else if ((x == dest_x) && (y == dest_y)) { break; /* we're at the place we wanted to be anyhow, drop out. */ @@ -946,6 +943,10 @@ void X11_UpdateWindowPosition(SDL_Window *window) } if (!caught_x11_error) { + if (SDL_WINDOW_IS_POPUP(window)) { + SDL_GlobalToRelativeForWindow(window, x, y, &x, &y); + } + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, x, y); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, attrs.width, attrs.height); }