fheroes2 icon indicating copy to clipboard operation
fheroes2 copied to clipboard

feat: remember position of game window

Open usidedown opened this issue 6 months ago • 1 comments

Solves #1228

Saves the position of the window in fheroes2.conf. The position is captured every time the window is moved, and saved to settings when the game exits. It's possible to capture only when the game exits, but then we might not save the correct position if the user swaps to Fullscreen mode before quitting.

usidedown avatar May 28 '25 13:05 usidedown

We will merge this pull request after the upcoming release.

ihhub avatar Jun 07 '25 15:06 ihhub

Hi @ihhub, could you take a look at this PR when you have the time? Is there more work to be done here?

usidedown avatar Jun 21 '25 08:06 usidedown

@usidedown , many thanks for this feature!

ihhub avatar Jun 22 '25 02:06 ihhub

Hi guys. Just a generic warning. In the past, I already had different cases with such functionality. The end user can mistakenly change the window position to a very pity one (e.g. far corner). Don't ask why, mainly it just happens. Generic user expectation that on the next run - the window will be restored properly.

Let's go through a very generic case

  • End user works with multiple windows. By mistake fheroes2 window is moved to be bottom corner and the window title is barely visible
  • The end user cannot find fheroes2 windows, so the game is forcefully closed
  • On the next run the window is restored to the same position (e.g. not playable)

Typically it's handled by counting window size and in case endpoints (X/Y) have higher values than screen size - restore to the default screen and centered

Another typical case. An end user has 2 monitors (e.g. connected TV). On the next run, the TV (or any other second monitor) is disconnected. What will happen then? Was that test scenario checked?

Killbrum avatar Jun 23 '25 18:06 Killbrum

Hi @Killbrum, thanks for your input!

We ended up with the following:

  • The window is only saved on a proper exit.
  • The game checks that the window is fully contained in the display, otherwise the default position is used
  • If we failed to get the display information, the default position is used.

I believe the behavior is correct in the scenarios you outlined.

usidedown avatar Jun 23 '25 19:06 usidedown