From 00b58d1f0fb63860cb956b8963ebe957740d1e5d Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sat, 8 Jan 2022 18:06:13 +0100 Subject: [PATCH] Print available displays and mouse position before creating window to debug issues like "dhewm3 chose wrong fullscreen resolution" or "dhewm3 started on wrong display" --- neo/sys/glimp.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/neo/sys/glimp.cpp b/neo/sys/glimp.cpp index 322ac21a..662c871e 100644 --- a/neo/sys/glimp.cpp +++ b/neo/sys/glimp.cpp @@ -253,17 +253,23 @@ bool GLimp_Init(glimpParms_t parms) { SDL_GetGlobalMouseState(&x, &y); int numDisplays = SDL_GetNumVideoDisplays(); + common->Printf("SDL detected %d displays: \n", numDisplays); + bool found = false; for ( int j=0; j= rect.x && x < rect.x + rect.w + common->Printf(" %d: %dx%d at (%d, %d) to (%d, %d)\n", j, rect.w, rect.h, + rect.x, rect.y, rect.x+rect.w, rect.y+rect.h); + if ( !found && x >= rect.x && x < rect.x + rect.w && y >= rect.y && y < rect.y + rect.h ) { displayIndex = j; - break; + found = true; } } } + common->Printf("Will use display %d because mouse cursor is at (%d, %d).\n", + displayIndex, x, y); } #endif @@ -296,6 +302,10 @@ bool GLimp_Init(glimpParms_t parms) { { common->Warning("Current display mode isn't requested display mode\n"); common->Warning("Likely SDL bug #4700, trying to work around it..\n"); + int dIdx = SDL_GetWindowDisplayIndex(window); + if(dIdx != displayIndex) { + common->Warning("Window's display index is %d, but we wanted %d!\n", dIdx, displayIndex); + } /* Mkay, try to hack around that. */ SDL_DisplayMode wanted_mode = {};