Skip to content

Commit

Permalink
Add setting for "Release window to move"
Browse files Browse the repository at this point in the history
Intentionally set to true by default, to let people on the beta version
to test it.
  • Loading branch information
veselink1 committed May 25, 2024
1 parent 03724ff commit 68b387e
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 5 deletions.
2 changes: 2 additions & 0 deletions FancyWM/ITilingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ internal interface ITilingService : IDisposable

int AutoSplitCount { get; set; }

bool DelayReposition { get; set; }

ITilingServiceIntent? PendingIntent { get; set; }

bool CanSplit(bool vertical);
Expand Down
14 changes: 14 additions & 0 deletions FancyWM/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public partial class MainWindow : Window, IDisposable
private bool m_showFocusDuringAction;
private bool m_autoCollapse;
private int m_autoSplitCount;
private bool m_delayReposition;
private bool m_notifyVirtualDesktopServiceIncompatibility;
private LowLevelHotkey[] m_directHks = [];
private DispatcherTimer m_dispatcherTimer;
Expand Down Expand Up @@ -121,6 +122,7 @@ public MainWindow()
.Do(x => m_showFocusDuringAction = x.ShowFocusDuringAction)
.Do(x => m_autoCollapse = x.AutoCollapsePanels)
.Do(x => m_autoSplitCount = x.AutoSplitCount)
.Do(x => m_delayReposition = x.DelayReposition)
.Do(x => m_notifyVirtualDesktopServiceIncompatibility = x.NotifyVirtualDesktopServiceIncompatibility)
.Do(x =>
{
Expand Down Expand Up @@ -187,6 +189,7 @@ await Dispatcher.InvokeAsync(() =>

m_tiling.AutoCollapse = m_autoCollapse;
m_tiling.AutoSplitCount = m_autoSplitCount;
m_tiling.DelayReposition = m_delayReposition;
m_tiling.PlacementFailed += OnTilingFailed;
m_tiling.Start();
}))
Expand Down Expand Up @@ -226,6 +229,16 @@ await Dispatcher.InvokeAsync(() =>
}
}));

var delayRepositionSettings = settings
.DistinctUntilChanged(x => x.DelayReposition)
.Do(async _ => await Dispatcher.InvokeAsync(() =>
{
if (m_tiling != null)
{
m_tiling.DelayReposition = m_delayReposition;
}
}));

m_llkbdHook = App.Current.Services.GetRequiredService<LowLevelKeyboardHook>();

m_subscriptions =
Expand All @@ -237,6 +250,7 @@ await Dispatcher.InvokeAsync(() =>
keybindingsSettings.Subscribe(new NotifyUnhandledObserver<KeybindingDictionary>()),
autoSplitSettings.Subscribe(new NotifyUnhandledObserver<Settings>()),
autoCollapseSettings.Subscribe(new NotifyUnhandledObserver<Settings>()),
delayRepositionSettings.Subscribe(new NotifyUnhandledObserver<Settings>()),
multiMonitorObservable
.Concat(exclusionListSettings)
.Subscribe(new NotifyUnhandledObserver<Unit>()),
Expand Down
4 changes: 4 additions & 0 deletions FancyWM/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

using FancyWM.Utilities;

using Windows.Foundation.Diagnostics;

namespace FancyWM.Models
{
public interface ITilingServiceSettings
Expand Down Expand Up @@ -45,6 +47,8 @@ public Settings()

public int AutoSplitCount { get; set; } = 2;

public bool DelayReposition { get; set; } = true;

public bool AnimateWindowMovement { get; set; } = true;

public bool ModifierMoveWindow { get; set; } = false;
Expand Down
14 changes: 14 additions & 0 deletions FancyWM/MultiDisplayTilingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ public int AutoSplitCount
}
}

public bool DelayReposition
{
get => m_delayReposition;
set
{
foreach (var tiling in m_tilingServices.Values)
{
tiling.DelayReposition = value;
}
m_delayReposition = value;
}
}

public ITilingServiceIntent? PendingIntent
{
get => GetActiveTilingService().PendingIntent;
Expand All @@ -93,6 +106,7 @@ public ITilingServiceIntent? PendingIntent
private bool m_showFocus;
private bool m_autoCollapse;
private int m_autoSplitCount;
private bool m_delayReposition;
private IReadOnlyCollection<IWindowMatcher> m_exclusionMatchers = [];
private readonly IObservable<ITilingServiceSettings> m_settings;
private readonly object m_syncRoot = new();
Expand Down
10 changes: 10 additions & 0 deletions FancyWM/Pages/Settings/GeneralPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@
</StackPanel>
</Border>

<Border Style="{DynamicResource SettingsItemStyle}">
<StackPanel>
<DockPanel LastChildFill="True">
<CheckBox DockPanel.Dock="Right" IsChecked="{Binding Path=DelayReposition, Mode=TwoWay}" />
<TextBlock VerticalAlignment="Center" Margin="0,0,16,0" Text="{x:Static res:Strings.General_DelayReposition}" />
</DockPanel>
<TextBlock TextWrapping="WrapWithOverflow" Padding="0,16,0,0" VerticalAlignment="Center" Text="{x:Static res:Strings.General_DelayReposition_Description}" Foreground="{DynamicResource SystemControlPageTextBaseMediumBrush}" />
</StackPanel>
</Border>

<Border Style="{DynamicResource SettingsItemStyle}">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
Expand Down
18 changes: 18 additions & 0 deletions FancyWM/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions FancyWM/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -916,4 +916,10 @@ If you are running a supported non-Insider Windows build and you see this messag
<data name="About.FOSS" xml:space="preserve">
<value>FancyWM is free and open-source, but requires the same time and effort as any other software.</value>
</data>
<data name="General.DelayReposition" xml:space="preserve">
<value>Release window to move</value>
</data>
<data name="General.DelayReposition.Description" xml:space="preserve">
<value>When enabled, the tiling layout will update once the window has finished moving.</value>
</data>
</root>
8 changes: 3 additions & 5 deletions FancyWM/TilingService.Private.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private List<TransitionTarget> CalculateRepositionTargets(IEnumerable<WindowNode

private Rectangle? GetPreviewRectangle()
{
if (m_currentInteraction == UserInteraction.Moving && m_delayedReposition || m_movingPanelNode != null)
if (m_currentInteraction == UserInteraction.Moving && DelayReposition || m_movingPanelNode != null)
{
try
{
Expand Down Expand Up @@ -1036,8 +1036,6 @@ private void OnWindowRemoved(object? sender, WindowChangedEventArgs e)
}
}

bool m_delayedReposition = true;

private void DoWindowMove(IWindow window)
{
var isSwapping = IsSwapModifierPressed();
Expand All @@ -1058,7 +1056,7 @@ private void OnWindowPositionChangeEnd(object? sender, WindowPositionChangedEven
if (!m_active)
return;

if (m_delayedReposition)
if (DelayReposition)
{
DoWindowMove(e.Source);
}
Expand Down Expand Up @@ -1133,7 +1131,7 @@ private void OnWindowPositionChanged(object? sender, WindowPositionChangedEventA

if (e.NewPosition.Width == e.OldPosition.Width && e.NewPosition.Height == e.OldPosition.Height)
{
if (!m_delayedReposition)
if (!DelayReposition)
{
DoWindowMove(e.Source);
}
Expand Down
2 changes: 2 additions & 0 deletions FancyWM/TilingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public bool Active

public int AutoSplitCount { get; set; } = 100;

public bool DelayReposition { get; set; } = false;

public bool AutoCollapse
{
get => m_backend.AutoCollapse;
Expand Down
5 changes: 5 additions & 0 deletions FancyWM/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public sealed class SettingsViewModel : ViewModelBase
public bool AllocateNewPanelSpace { get => m_allocateNewPanelSpace; set => SetField(ref m_allocateNewPanelSpace, value); }
public bool AutoCollapsePanels { get => m_autoCollapsePanels; set => SetField(ref m_autoCollapsePanels, value); }
public int AutoSplitCount { get => m_autoSplitCount; set => SetField(ref m_autoSplitCount, value); }

public bool DelayReposition { get => m_delayReposition; set => SetField(ref m_delayReposition, value); }
public bool AnimateWindowMovement { get => m_animateWindowMovement; set => SetField(ref m_animateWindowMovement, value); }
public bool ModifierMoveWindow { get => m_modifierMoveWindow; set => SetField(ref m_modifierMoveWindow, value); }
public bool ModifierMoveWindowAutoFocus { get => m_modifierMoveWindowAutoFocus; set => SetField(ref m_modifierMoveWindowAutoFocus, value); }
Expand Down Expand Up @@ -179,6 +181,7 @@ public ObservableCollection<KeybindingViewModel>? Keybindings
private bool m_allocateNewPanelSpace;
private bool m_autoCollapsePanels;
private int m_autoSplitCount;
private bool m_delayReposition;
private bool m_customAccentColor;
private bool m_animateWindowMovement;
private bool m_modifierMoveWindow;
Expand Down Expand Up @@ -219,6 +222,7 @@ public SettingsViewModel(IObservableFileEntity<Settings> observable)
AllocateNewPanelSpace = settings.AllocateNewPanelSpace;
AutoCollapsePanels = settings.AutoCollapsePanels;
AutoSplitCount = settings.AutoSplitCount;
DelayReposition = settings.DelayReposition;
AnimateWindowMovement = settings.AnimateWindowMovement;
ModifierMoveWindow = settings.ModifierMoveWindow;
ModifierMoveWindowAutoFocus = settings.ModifierMoveWindowAutoFocus;
Expand Down Expand Up @@ -341,6 +345,7 @@ private void SaveChanges()
x.AllocateNewPanelSpace = AllocateNewPanelSpace;
x.AutoCollapsePanels = AutoCollapsePanels;
x.AutoSplitCount = AutoSplitCount;
x.DelayReposition = DelayReposition;
x.AnimateWindowMovement = AnimateWindowMovement;
x.ModifierMoveWindow = ModifierMoveWindow;
x.ModifierMoveWindowAutoFocus = ModifierMoveWindowAutoFocus;
Expand Down

0 comments on commit 68b387e

Please sign in to comment.