I use my computer alongside an external display, so I have two screens to work with. In MacOS, there is a concept of a "main display" which will have your dock + top toolbar, with all other screens being "extended displays". I've noticed that regardless of which screen I open fheroes2, it will always run on my "main" screen. Additionally, if I disable full screen mode, and move the window to my second screen, the window position will not persist to the subsequent boot.
There are two problems here, and thankfully one has a solution. For the second issue (window position is not persisted) - after looking through the SDL code that initializes the game window, I found that there is some functionality that stores_prevWindowPos, although it seems like it's not fully hooked up. #6667 seems to address this, although that PR hasn't had any movement since the end of the last year.
For the first issue (game always launches on "main" screen), this is likely due to SDL defaults. The default position for the window is defined in this line:
The 0 index in that macro is the index of the display, so this will always default to the first display, which, in Mac, will be the "main". This might also affect Windows, although I am not sure if it has the same aspect of a "main display" (I believe it does, but I don't have a Windows machine handy to double check at the moment).
The possible solution here would be to
identify the screen within which the game is launched
use SDL_WINDOWPOS_CENTERED_DISPLAY(<screen index>) when calling SDL_CreateWindow to launch the game in the right place
Not sure if this will affect other platforms where screens might also be emulated (Android or PS Vita?).
Wanted to float this idea, and given that this is a fairly straighforward fix, I'd be happy to make the change if you think it's worth patching!
Preliminary checks
Platform
macOS
Describe the bug
I use my computer alongside an external display, so I have two screens to work with. In MacOS, there is a concept of a "main display" which will have your dock + top toolbar, with all other screens being "extended displays". I've noticed that regardless of which screen I open
fheroes2
, it will always run on my "main" screen. Additionally, if I disable full screen mode, and move the window to my second screen, the window position will not persist to the subsequent boot.There are two problems here, and thankfully one has a solution. For the second issue (window position is not persisted) - after looking through the SDL code that initializes the game window, I found that there is some functionality that stores
_prevWindowPos
, although it seems like it's not fully hooked up. #6667 seems to address this, although that PR hasn't had any movement since the end of the last year.For the first issue (game always launches on "main" screen), this is likely due to SDL defaults. The default position for the window is defined in this line:
which is a macro for (this link is to the current SDL3 implementation, but it's the same in SDL2)
The 0 index in that macro is the index of the display, so this will always default to the first display, which, in Mac, will be the "main". This might also affect Windows, although I am not sure if it has the same aspect of a "main display" (I believe it does, but I don't have a Windows machine handy to double check at the moment).
The possible solution here would be to
SDL_WINDOWPOS_CENTERED_DISPLAY(<screen index>)
when callingSDL_CreateWindow
to launch the game in the right placeNot sure if this will affect other platforms where screens might also be emulated (Android or PS Vita?).
Wanted to float this idea, and given that this is a fairly straighforward fix, I'd be happy to make the change if you think it's worth patching!
Save file
N/A
Additional info
No response