[FancyZones] Restore size of zoned windows (#4463)

* Started work

* I can't debug anything, cleaning

* Added settings, [[Not Tested]]

Not even compiled

* Tested, the most basic features work

* Refactor, add RestoreSize

* Added DPI awareness

* Fixed a potential issue with resizing zoned windows

* Fixup: Potentially unsafe memory-layout of std::pair replaced with std::array

* Fixup: Use .data() instead of a pointer

* Further refactoring

* Integrated Win+Arrow keys with the Restore size feature

* Fixed an issue where window's on-screen position is not restored properly

* Fixed a bug pointed out by Enrico
This commit is contained in:
Ivan Stošić
2020-07-01 15:36:05 +02:00
committed by GitHub
parent 16528888df
commit 4c08b591f1
21 changed files with 235 additions and 25 deletions

View File

@@ -309,7 +309,8 @@ namespace PowerToysTests
Assert.AreNotEqual(toggleValues[3], GetPropertyValue<bool>(savedProps, "fancyzones_moveWindowAcrossMonitors"));
Assert.AreNotEqual(toggleValues[4], GetPropertyValue<bool>(savedProps, "fancyzones_displayChange_moveWindows"));
Assert.AreNotEqual(toggleValues[5], GetPropertyValue<bool>(savedProps, "fancyzones_zoneSetChange_moveWindows"));
Assert.AreNotEqual(toggleValues[7], GetPropertyValue<bool>(savedProps, "fancyzones_appLastZone_moveWindows"));
Assert.AreNotEqual(toggleValues[6], GetPropertyValue<bool>(savedProps, "fancyzones_appLastZone_moveWindows"));
Assert.AreNotEqual(toggleValues[7], GetPropertyValue<bool>(savedProps, "fancyzones_restoreSize"));
Assert.AreNotEqual(toggleValues[8], GetPropertyValue<bool>(savedProps, "use_cursorpos_editor_startupscreen"));
Assert.AreNotEqual(toggleValues[9], GetPropertyValue<bool>(savedProps, "fancyzones_show_on_all_monitors"));
Assert.AreNotEqual(toggleValues[10], GetPropertyValue<bool>(savedProps, "fancyzones_makeDraggedWindowTransparent"));
@@ -348,7 +349,8 @@ namespace PowerToysTests
Assert.AreEqual(toggleValues[3], GetPropertyValue<bool>(savedProps, "fancyzones_moveWindowAcrossMonitors"));
Assert.AreEqual(toggleValues[4], GetPropertyValue<bool>(savedProps, "fancyzones_displayChange_moveWindows"));
Assert.AreEqual(toggleValues[5], GetPropertyValue<bool>(savedProps, "fancyzones_zoneSetChange_moveWindows"));
Assert.AreEqual(toggleValues[7], GetPropertyValue<bool>(savedProps, "fancyzones_appLastZone_moveWindows"));
Assert.AreEqual(toggleValues[6], GetPropertyValue<bool>(savedProps, "fancyzones_appLastZone_moveWindows"));
Assert.AreEqual(toggleValues[7], GetPropertyValue<bool>(savedProps, "fancyzones_restoreSize"));
Assert.AreEqual(toggleValues[8], GetPropertyValue<bool>(savedProps, "use_cursorpos_editor_startupscreen"));
Assert.AreEqual(toggleValues[9], GetPropertyValue<bool>(savedProps, "fancyzones_show_on_all_monitors"));
Assert.AreEqual(toggleValues[10], GetPropertyValue<bool>(savedProps, "fancyzones_makeDraggedWindowTransparent"));

View File

@@ -14,13 +14,13 @@ namespace PowerToysTests
{
protected const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
protected const string AppPath = "C:\\Program Files\\PowerToys\\PowerToys.exe";
protected static WindowsDriver<WindowsElement> session;
protected static bool isPowerToysLaunched = false;
protected static WindowsElement trayButton;
protected static string _settingsFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\PowerToys\\FancyZones");
protected static string _settingsPath = _settingsFolderPath + "\\settings.json";
protected static string _settingsPath = _settingsFolderPath + "\\settings.json";
protected static string _zoneSettingsPath = _settingsFolderPath + "\\zones-settings.json";
protected static string _appHistoryPath = _settingsFolderPath + "\\app-zone-history.json";
@@ -30,7 +30,7 @@ namespace PowerToysTests
protected const string _defaultSettings = "{\"version\":\"1.0\",\"name\":\"FancyZones\",\"properties\":{\"fancyzones_shiftDrag\":{\"value\":true},\"fancyzones_mouseSwitch\":{\"value\":false},\"fancyzones_overrideSnapHotkeys\":{\"value\":false},\"fancyzones_moveWindowAcrossMonitors\":{\"value\":false},\"fancyzones_zoneSetChange_flashZones\":{\"value\":false},\"fancyzones_displayChange_moveWindows\":{\"value\":false},\"fancyzones_zoneSetChange_moveWindows\":{\"value\":false},\"fancyzones_appLastZone_moveWindows\":{\"value\":false},\"use_cursorpos_editor_startupscreen\":{\"value\":true},\"fancyzones_zoneHighlightColor\":{\"value\":\"#0078D7\"},\"fancyzones_highlight_opacity\":{\"value\":90},\"fancyzones_editor_hotkey\":{\"value\":{\"win\":true,\"ctrl\":false,\"alt\":false,\"shift\":false,\"code\":192,\"key\":\"`\"}},\"fancyzones_excluded_apps\":{\"value\":\"\"}}}";
protected const string _defaultZoneSettings = "{\"app-zone-history\":[],\"devices\":[],\"custom-zone-sets\":[]}";
public static void Setup(TestContext context, bool isLaunchRequired = true)
{
@@ -52,7 +52,7 @@ namespace PowerToysTests
{
LaunchPowerToys();
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
@@ -176,7 +176,7 @@ namespace PowerToysTests
}
}
private static bool CheckPowerToysLaunched()
private static bool CheckPowerToysLaunched()
{
bool isLaunched = false;
try
@@ -190,7 +190,7 @@ namespace PowerToysTests
{
//PowerToys not found
}
return isLaunched;
}