From a85f5c15d3567ada21eb1eb40aa843b1d04178f5 Mon Sep 17 00:00:00 2001 From: Michael Schienbein Date: Mon, 9 Nov 2026 15:36:43 -0600 Subject: [PATCH] Report where a Wayland fullscreen window ended up once the compositor placed it. SDL_SyncWindow returns before the compositor moves the fullscreen window to the chosen output, so the check right after it logged the output the window opened on, though the game then ran on the chosen monitor. On Wayland the report now waits until SDL sees the window on the chosen monitor, which it learns from a display, scale or mode change (Hyprland 0.56 sends only the latter two). Co-Authored-By: Claude Opus 5.5 --- runtime/gfx_window_sdl.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/runtime/gfx_window_sdl.c b/runtime/gfx_window_sdl.c index 8a1ef5dc..3b244869 100644 --- a/runtime/gfx_window_sdl.c +++ b/runtime/gfx_window_sdl.c @@ -136,6 +136,17 @@ static void density_update(void) { } // ---- the window thread +// NX2NAVI_MONITOR's display while a Wayland compositor has yet to place the fullscreen window (open_window): SDL learns +// the output a Wayland window is on later, with a display, scale or mode change (Hyprland sends only the latter two). +static SDL_DisplayID g_place_pending; + +static void report_placement(SDL_DisplayID want) { + SDL_DisplayID at = SDL_GetDisplayForWindow(g_win); + const char *name = SDL_GetDisplayName(at); + if (at == want) rt_log("gfx: the window is on the chosen monitor \"%s\"", name ? name : "an unknown monitor"); + else rt_log("gfx: the window is not on the chosen monitor; it is on \"%s\"", name ? name : "an unknown monitor"); +} + static void handle(const SDL_Event *e) { if (e->type == g_ev_base + EV_RUN) { RunReq *r = e->user.data1; @@ -172,6 +183,10 @@ static void handle(const SDL_Event *e) { density_update(); refresh_rate_update(); gfx_window_mark_dirty(); + if (g_place_pending && SDL_GetDisplayForWindow(g_win) == g_place_pending) { + report_placement(g_place_pending); + g_place_pending = 0; + } break; case SDL_EVENT_WINDOW_FOCUS_GAINED: case SDL_EVENT_WINDOW_FOCUS_LOST: @@ -462,10 +477,11 @@ static void open_window(void *arg) { "where the game opens in fullscreen"); if (gfx_cfg_fullscreen()) SDL_SetWindowFullscreen(g_win, true); SDL_SyncWindow(g_win); - SDL_DisplayID at = SDL_GetDisplayForWindow(g_win); - if (on_mon && (gfx_cfg_fullscreen() || !wayland) && at != mon.id) { - const char *name = SDL_GetDisplayName(at); - rt_log("gfx: the window is not on the chosen monitor; it is on \"%s\"", name ? name : "an unknown monitor"); + // A Wayland compositor places the fullscreen window after SDL_SyncWindow returns; handle reports it once the window + // is on the chosen monitor. + if (on_mon && (gfx_cfg_fullscreen() || !wayland)) { + if (wayland && SDL_GetDisplayForWindow(g_win) != mon.id) g_place_pending = mon.id; + else report_placement(mon.id); } input_sdl_window(g_win); open_ok = 1;