From 9eb68bf05299090dcc6ff1b50c408f304f83abee Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 6 Mar 2024 07:39:36 +0100 Subject: [PATCH] only do things here when theres more than one display --- src/sdl/i_video.c | 50 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 6997fc638..a167d806b 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -871,8 +871,6 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) if (windowmoved) { - currentDisplayIndex = SDL_GetWindowDisplayIndex(window); - if (!displayinit) // dont need to recheck for new displays i think noone adds a display while playing kart lmkao { numDisplays = SDL_GetNumVideoDisplays(); @@ -880,37 +878,41 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) displayinit = true; } - if (currentDisplayIndex != previousDisplayIndex) + if (numDisplays > 1) { - //CONS_Printf("Window has changed displays.\n"); - for (int i = 0; i < numDisplays; ++i) + currentDisplayIndex = SDL_GetWindowDisplayIndex(window); + if (currentDisplayIndex != previousDisplayIndex) { - if (currentDisplayIndex == i) + //CONS_Printf("Window has changed displays.\n"); + for (int i = 0; i < numDisplays; ++i) { - SDL_DisplayMode curmode; - if (SDL_GetCurrentDisplayMode(i, &curmode) == 0) + if (currentDisplayIndex == i) { - //CONS_Printf("Current Display Info:\n"); - //CONS_Printf(" Resolution: %dx%d\n", curmode.w, curmode.h); - //CONS_Printf(" Refresh rate: %d Hz\n", curmode.refresh_rate); - - if (cv_grframebuffer.value && ((vid.width > curmode.w) || (vid.height > curmode.h))) //framebuffer downsampler thinge + SDL_DisplayMode curmode; + if (SDL_GetCurrentDisplayMode(i, &curmode) == 0) { - downsample = true; - RefreshSDLSurface(); - } + //CONS_Printf("Current Display Info:\n"); + //CONS_Printf(" Resolution: %dx%d\n", curmode.w, curmode.h); + //CONS_Printf(" Refresh rate: %d Hz\n", curmode.refresh_rate); - if (cv_fullscreen.value == 2) //exclusive - SDLSetMode(curmode.w, curmode.h, true); - else if (cv_fullscreen.value == 1) //borderless sdl thing - SDLSetMode(vid.width, vid.height, true); - else //windowed mode - SDLSetMode(vid.width, vid.height, false); + if (cv_grframebuffer.value && ((vid.width > curmode.w) || (vid.height > curmode.h))) //framebuffer downsampler thinge + { + downsample = true; + RefreshSDLSurface(); + } + + if (cv_fullscreen.value == 2) //exclusive + SDLSetMode(curmode.w, curmode.h, true); + else if (cv_fullscreen.value == 1) //borderless sdl thing + SDLSetMode(vid.width, vid.height, true); + else //windowed mode + SDLSetMode(vid.width, vid.height, false); + } + break; // found our current display break outta here } - break; // found our current display break outta here } + previousDisplayIndex = currentDisplayIndex; } - previousDisplayIndex = currentDisplayIndex; } } }