Skip to content

Commit ffb2200

Browse files
authored
Recover from task switcher issue with minimized windows (#4400)
Catches case where window is activated but not restored / maximized and then manually does that
1 parent 87fb7ae commit ffb2200

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

Flow.Launcher/PluginSettingsWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
ResizeMode="CanResize"
1212
SnapsToDevicePixels="True"
1313
StateChanged="Window_StateChanged"
14+
Activated="Window_Activated"
1415
UseLayoutRounding="True"
1516
WindowStartupLocation="CenterScreen">
1617
<WindowChrome.WindowChrome>

Flow.Launcher/PluginSettingsWindow.xaml.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Flow.Launcher;
1212
public partial class PluginSettingsWindow
1313
{
1414
private readonly Settings _settings;
15+
private WindowState _lastNonMinimizedWindowState = WindowState.Normal;
1516

1617
public string PluginId { get; }
1718

@@ -84,14 +85,34 @@ private void OnCloseExecuted(object sender, ExecutedRoutedEventArgs e)
8485

8586
private void OnLoaded(object sender, RoutedEventArgs e)
8687
{
88+
if (WindowState != WindowState.Minimized)
89+
{
90+
_lastNonMinimizedWindowState = WindowState;
91+
}
92+
8793
RefreshMaximizeRestoreButton();
8894
}
8995

9096
private void Window_StateChanged(object sender, EventArgs e)
9197
{
98+
if (WindowState != WindowState.Minimized)
99+
{
100+
_lastNonMinimizedWindowState = WindowState;
101+
}
102+
92103
RefreshMaximizeRestoreButton();
93104
}
94105

106+
private void Window_Activated(object sender, EventArgs e)
107+
{
108+
// Band-aid fix: Rare edge case where Alt+Tab activates the window but doesn't trigger StateChanged
109+
// So we need to restore/maximize it here if it's still minimized
110+
if (WindowState == WindowState.Minimized)
111+
{
112+
WindowState = _lastNonMinimizedWindowState;
113+
}
114+
}
115+
95116
private void RefreshMaximizeRestoreButton()
96117
{
97118
if (WindowState == WindowState.Maximized)

Flow.Launcher/SettingWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ResizeMode="CanResize"
2323
SnapsToDevicePixels="True"
2424
StateChanged="Window_StateChanged"
25+
Activated="Window_Activated"
2526
Top="{Binding SettingWindowTop, Mode=TwoWay}"
2627
UseLayoutRounding="True"
2728
WindowStartupLocation="Manual"

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ private void Window_StateChanged(object sender, EventArgs e)
101101
_settings.SettingWindowState = WindowState;
102102
}
103103
}
104+
private void Window_Activated(object sender, EventArgs e)
105+
{
106+
107+
// Band-aid fix: Rare edge case where Alt+Tab activates the window but doesn't trigger StateChanged
108+
// So we need to restore/maximize it here if it's still minimized
109+
if (WindowState == WindowState.Minimized && _settings.SettingWindowState != WindowState.Minimized)
110+
{
111+
WindowState = _settings.SettingWindowState;
112+
}
113+
}
104114

105115
private void Window_LocationChanged(object sender, EventArgs e)
106116
{

0 commit comments

Comments
 (0)