SDL: wayland: Evaluate WINDOWPOS_CENTERED_DISPLAY for move events

From dcfb7fff0083617cee80f325ac585c3a0857f329 Mon Sep 17 00:00:00 2001
From: Ethan Lee <[EMAIL REDACTED]>
Date: Wed, 6 Apr 2022 00:55:32 -0400
Subject: [PATCH] wayland: Evaluate WINDOWPOS_CENTERED_DISPLAY for move events

Partially fixes the mouse cursor in UE5 editor. Imperfect because UE5 uses window position and global mouse state to get position, but of course we don't have global mouse and this is just to get the right display index so this still fails overall. We really need to make global mouse support a feature query...
---
 src/video/wayland/SDL_waylandwindow.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index 036c3a4ab69..aee1b80799c 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -815,9 +815,12 @@ Wayland_move_window(SDL_Window *window,
     int i, numdisplays = SDL_GetNumVideoDisplays();
     for (i = 0; i < numdisplays; i += 1) {
         if (SDL_GetDisplay(i)->driverdata == driverdata) {
+            /* Equivalent of SDL_WINDOWPOS_CENTERED_DISPLAY(i) */
+            SDL_Rect bounds;
+            SDL_GetDisplayBounds(i, &bounds);
             SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED,
-                                SDL_WINDOWPOS_CENTERED_DISPLAY(i),
-                                SDL_WINDOWPOS_CENTERED_DISPLAY(i));
+                                bounds.x + (bounds.w - window->w) / 2,
+                                bounds.y + (bounds.h - window->h) / 2);
             break;
         }
     }