View Single Post
Old 06 October 2021, 20:32   #179
8bitbubsy
Registered User
 
8bitbubsy's Avatar
 
Join Date: Sep 2009
Location: Norway
Posts: 1,711
Quote:
Originally Posted by paraj View Post
As it's your software/time at stake and I might be missing crucial details, so fell free to disregard the below.

I think it's because toggleFullScreen in pt2_visuals.c does this in line 2307

Code:
SDL_SetWindowPosition(video.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
SDL_WINDOWPOS_CENTERED will center the window on the first monitor (https://stackoverflow.com/a/41746429/786653)

I think if you use SDL_GetWindowPosition to save the old position before switching to fullscreen and then use the values returned there instead when calling SDL_SetWindowPosition the window should return to its old position (even on another monitor).

Again there might be good reasons you wouldn't want to do this (and it gets more complicated if you always want to center the window when returning from fullscreen), so take it FWIW.
Seems like you are right, so it's simple indeed. I just assumed it wasn't because multi-monitor + SDL = the horror, I've had so much bad experiences with it. I might remove the centering of the window itself, it's not hugely important.
8bitbubsy is offline  
 
Page generated in 0.07882 seconds with 11 queries