[FancyZones] Move window into last known position on active work area (if possible) (#4218)

* Move window into last known position on active work area (if possible)

* Refactor code to avoid double checks

* Address PR comments

* Perform all HWND checks at one place

* Improve handling of active/primary work area in app zone history

* Address PR comments: naming, arguments checks

* Rename some functions to increase readability

* Implement special handling in 2+ monitor scenario

* Minor naming change

* Simplify

* Improve readability

* Remove blank line

* Don't move away from secondary monitor if there is no app zone history

* Update comment

* FancyZonesEditor should not be zoned

* Preserve width and height (if possible) when opening on active monitor

* Maintain w/h whenever possible

* Remove scaling, add window coordinates on active monitor top-left corner

* If there is no app zone history on secondary screen, fallback to default windows behavior.
This commit is contained in:
vldmr11080
2020-06-17 11:55:14 +02:00
committed by GitHub
parent 7f25e3ba97
commit 698e5ec6ea
2 changed files with 109 additions and 26 deletions

View File

@@ -4,6 +4,12 @@
#include <common/common.h>
#include <common/dpi_aware.h>
namespace
{
const wchar_t POWER_TOYS_APP_POWER_LAUCHER[] = L"POWERLAUNCHER.EXE";
const wchar_t POWER_TOYS_APP_FANCY_ZONES_EDITOR[] = L"FANCYZONESEDITOR.EXE";
}
typedef BOOL(WINAPI* GetDpiForMonitorInternalFunc)(HMONITOR, UINT, UINT*, UINT*);
UINT GetDpiForMonitor(HMONITOR monitor) noexcept
{
@@ -157,7 +163,11 @@ bool IsInterestingWindow(HWND window, const std::vector<std::wstring>& excludedA
{
return false;
}
if (find_app_name_in_path(filtered.process_path, { L"POWERLAUNCHER.EXE" }))
if (find_app_name_in_path(filtered.process_path, { POWER_TOYS_APP_POWER_LAUCHER }))
{
return false;
}
if (find_app_name_in_path(filtered.process_path, { POWER_TOYS_APP_FANCY_ZONES_EDITOR }))
{
return false;
}