HydrogenAudio

Hosted Forums => foobar2000 => Support - (fb2k) => Topic started by: Sakuukuli on 2021-11-02 17:22:35

Title: foobar2000 v1.6.7 does not remember snap window position
Post by: Sakuukuli on 2021-11-02 17:22:35
I have Windows 10 version 21H1. foobar2000 remembers the window position on restart, but when snapped to the corner of the monitor using the multitasking options in Windows, it doesn't restore the position correctly. The window resets to the last position before it was snapped instead of the snapped position where the window was when it was closed. The issue persists in v1.6.8 beta 6.
Title: Re: foobar2000 v1.6.7 does not remember snap window position
Post by: kode54 on 2021-11-02 20:51:12
This is because the snap position is probably being reported and treated as a "maximized" window size, and therefore ignored. I don't even know if it's possible to save that window position and actually snap back the way Windows does itself when you snap it.
Title: Re: foobar2000 v1.6.7 does not remember snap window position
Post by: marc2k3 on 2021-11-04 20:51:40
Even things like notepad and explorer built in to windows behave the same way so I'm not sure how desirable it is to force it??

Having said that, I had a quick google and it seems like using GetWindowRect instead of GetWindowPlacement might "fix" it.

https://stackoverflow.com/questions/5673242/getwindowplacement-gives-the-incorrect-window-position
Title: Re: foobar2000 v1.6.7 does not remember snap window position
Post by: kode54 on 2021-11-05 02:14:48
Unfortunately, the entire window position saving system in foobar2000 and all components that use the SDK mechanism are based on GetWindowPlacement and saving the members of that structure.
Title: Re: foobar2000 v1.6.7 does not remember snap window position
Post by: marc2k3 on 2021-11-05 06:27:29
Seems like you can save directly to the original WINDOWPLACEMENT structure

Code: [Select]
//old code
GetWindowPlacement(&g_config.m_wndpl);

//replaced with
GetWindowRect(&g_config.m_wndpl.rcNormalPosition);

I only tested on a single monitor setup and have no idea if anything would be broken by not updating all values. I'm too lazy to properly check it.

And given the behaviour of windows built-ins I mentioned before, I'd still be hesitant to change it.

edit: support in other apps is a bit more mixed. Edge, Firefox and github desktop remember the snapped positions
Visual Studio 2022 preview, notepad++, media player classic BE, paint.net do not