Browse Source

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.
Sam Lantinga 2 years ago
parent
commit
17bdea7a91
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/video/x11/SDL_x11window.c

+ 4 - 3
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);
     }