mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
[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:
@@ -17,6 +17,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
this.FancyzonesDisplayChangeMoveWindows = new BoolProperty();
|
||||
this.FancyzonesZoneSetChangeMoveWindows = new BoolProperty();
|
||||
this.FancyzonesAppLastZoneMoveWindows = new BoolProperty();
|
||||
this.FancyzonesRestoreSize = new BoolProperty();
|
||||
this.UseCursorposEditorStartupscreen = new BoolProperty(ConfigDefaults.DefaultUseCursorposEditorStartupscreen);
|
||||
this.FancyzonesShowOnAllMonitors = new BoolProperty();
|
||||
this.FancyzonesZoneHighlightColor = new StringProperty(ConfigDefaults.DefaultFancyZonesZoneHighlightColor);
|
||||
@@ -58,6 +59,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
[JsonPropertyName("fancyzones_appLastZone_moveWindows")]
|
||||
public BoolProperty FancyzonesAppLastZoneMoveWindows { get; set; }
|
||||
|
||||
[JsonPropertyName("fancyzones_restoreSize")]
|
||||
public BoolProperty FancyzonesRestoreSize { get; set; }
|
||||
|
||||
[JsonPropertyName("use_cursorpos_editor_startupscreen")]
|
||||
public BoolProperty UseCursorposEditorStartupscreen { get; set; }
|
||||
|
||||
|
||||
@@ -599,4 +599,7 @@
|
||||
<data name="FancyZones_HotkeyEditorControl_TextBox.ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Only shortcuts with the following hotkeys are valid: Win, Ctrl, Alt, Shift.</value>
|
||||
</data>
|
||||
<data name="FancyZones_RestoreSize.Content" xml:space="preserve">
|
||||
<value>Restore the original size of windows when unsnapping</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -44,6 +44,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
this._displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value;
|
||||
this._zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value;
|
||||
this._appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value;
|
||||
this._restoreSize = Settings.Properties.FancyzonesRestoreSize.Value;
|
||||
this._useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value;
|
||||
this._showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value;
|
||||
this._makeDraggedWindowTransparent = Settings.Properties.FancyzonesMakeDraggedWindowTransparent.Value;
|
||||
@@ -82,6 +83,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
private bool _displayChangemoveWindows;
|
||||
private bool _zoneSetChangeMoveWindows;
|
||||
private bool _appLastZoneMoveWindows;
|
||||
private bool _restoreSize;
|
||||
private bool _useCursorPosEditorStartupScreen;
|
||||
private bool _showOnAllMonitors;
|
||||
private bool _makeDraggedWindowTransparent;
|
||||
@@ -241,6 +243,24 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool RestoreSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return _restoreSize;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _restoreSize)
|
||||
{
|
||||
_restoreSize = value;
|
||||
Settings.Properties.FancyzonesRestoreSize.Value = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseCursorPosEditorStartupScreen
|
||||
{
|
||||
get
|
||||
|
||||
@@ -133,6 +133,11 @@
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||
|
||||
<CheckBox x:Uid="FancyZones_RestoreSize"
|
||||
IsChecked="{ Binding Mode=TwoWay, Path=RestoreSize}"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||
|
||||
<CheckBox x:Uid="FancyZones_UseCursorPosEditorStartupScreen"
|
||||
IsChecked="{ Binding Mode=TwoWay, Path=UseCursorPosEditorStartupScreen}"
|
||||
Margin="{StaticResource SmallTopMargin}"
|
||||
|
||||
@@ -194,6 +194,24 @@ namespace ViewModelTests
|
||||
viewModel.AppLastZoneMoveWindows = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RestoreSize_ShouldSetValue2True_WhenSuccessful()
|
||||
{
|
||||
// arrange
|
||||
FancyZonesViewModel viewModel = new FancyZonesViewModel();
|
||||
Assert.IsFalse(viewModel.RestoreSize); // check if value was initialized to false.
|
||||
|
||||
// Assert
|
||||
ShellPage.DefaultSndMSGCallback = msg =>
|
||||
{
|
||||
FancyZonesSettingsIPCMessage snd = JsonSerializer.Deserialize<FancyZonesSettingsIPCMessage>(msg);
|
||||
Assert.IsTrue(snd.Powertoys.FancyZones.Properties.FancyzonesRestoreSize.Value);
|
||||
};
|
||||
|
||||
// act
|
||||
viewModel.RestoreSize = true;
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void UseCursorPosEditorStartupScreen_ShouldSetValue2False_WhenSuccessful()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user