Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.4
6 changes: 6 additions & 0 deletions bootstrap/payload/SlipperyContext.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ internal sealed partial class SlipperyContext : ApplicationContext, IDisposable
private bool _lastShouldShow = true;
private DateTime _lastApplyUtc = DateTime.MinValue;
private DateTime _trayInteractionPinUntilUtc = DateTime.MinValue;
private DateTime _lastAppbarPolicyCheckUtc = DateTime.MinValue;
private DateTime _lastAppbarPolicyRepairUtc = DateTime.MinValue;
private int _appbarPolicyRepairAttempts;
private int _appbarPolicyRepairSuccesses;
private IntPtr _mouseHook = IntPtr.Zero;
private NativeMethods.LowLevelMouseProc _mouseHookProc;
private bool _disposed;
Expand All @@ -49,6 +53,7 @@ internal sealed partial class SlipperyContext : ApplicationContext, IDisposable
private static readonly TimeSpan TrayInteractionPinGrace = TimeSpan.FromMilliseconds(900);
private static readonly TimeSpan TrayClickPinGrace = TimeSpan.FromMilliseconds(1800);
private static readonly TimeSpan TrayHoverPinGrace = TimeSpan.FromMilliseconds(500);
private static readonly TimeSpan AppbarPolicyWatchInterval = TimeSpan.FromMilliseconds(500);

public SlipperyContext()
{
Expand Down Expand Up @@ -215,6 +220,7 @@ private void SetEnabled(bool value)
_trayInteractionPinUntilUtc = DateTime.MinValue;
_taskbars.EnsureAppbarPolicy(_enabled);
_taskbars.EnsureWorkAreaPolicy(_enabled);
_lastAppbarPolicyCheckUtc = DateTime.MinValue;

if (!_enabled)
{
Expand Down
5 changes: 4 additions & 1 deletion bootstrap/payload/SlipperyContext.Diagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private void CopyDiagnostics()
{
StringBuilder b = new StringBuilder();
b.AppendLine("Slippery Taskbar C# diagnostics");
b.AppendLine("Build: 1.0.0");
b.AppendLine("Build: 1.0.4-policy");
b.AppendLine("Runtime: " + Environment.Version);
b.AppendLine("OS: " + Environment.OSVersion);
b.AppendLine("Executable: " + Application.ExecutablePath);
Expand All @@ -29,6 +29,9 @@ private void CopyDiagnostics()
b.AppendLine("Start with Windows: " + _startWithWindows);
b.AppendLine("Keep visible while interacting: " + _preferencesStore.Current.KeepVisibleWhileInteracting);
b.AppendLine("Native auto-hide active: " + ((_taskbars.GetAppbarState() & NativeMethods.ABS_AUTOHIDE) != 0));
b.AppendLine("Appbar policy repair attempts: " + _appbarPolicyRepairAttempts);
b.AppendLine("Appbar policy repair successes: " + _appbarPolicyRepairSuccesses);
b.AppendLine("Last appbar policy repair UTC: " + (_lastAppbarPolicyRepairUtc == DateTime.MinValue ? "never" : _lastAppbarPolicyRepairUtc.ToString("O")));
b.AppendLine("Tray visibility guard active: " + (DateTime.UtcNow < _trayInteractionPinUntilUtc || _taskbars.IsTrayOverflowOpen()));
b.AppendLine("Notification-area mouse guard installed: " + (_mouseHook != IntPtr.Zero));
b.AppendLine("Work area: " + _taskbars.DescribeWorkArea());
Expand Down
21 changes: 21 additions & 0 deletions bootstrap/payload/SlipperyContext.Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ internal void HandleWindowMessage(ref Message m)
case NativeMethods.WM_DISPLAYCHANGE:
case NativeMethods.WM_SETTINGCHANGE:
_taskbars.RefreshTaskbars();
RepairAppbarPolicyIfNeeded();
break;
case NativeMethods.WM_POWERBROADCAST:
int power = m.WParam.ToInt32();
Expand All @@ -44,6 +45,7 @@ internal void HandleWindowMessage(ref Message m)
_taskbars.RefreshTaskbars();
_taskbars.EnsureAppbarPolicy(_enabled);
_taskbars.EnsureWorkAreaPolicy(_enabled);
_lastAppbarPolicyCheckUtc = DateTime.UtcNow;
_visibleUntilUtc = DateTime.UtcNow.AddMilliseconds(750);
}
break;
Expand All @@ -55,6 +57,7 @@ private void HandleExplorerRestart()
_taskbars.RefreshTaskbars();
_taskbars.EnsureAppbarPolicy(_enabled);
_taskbars.EnsureWorkAreaPolicy(_enabled);
_lastAppbarPolicyCheckUtc = DateTime.UtcNow;
_visibleUntilUtc = DateTime.UtcNow.AddMilliseconds(750);

// NotifyIcon normally recreates itself after TaskbarCreated, but
Expand All @@ -66,6 +69,24 @@ private void HandleExplorerRestart()
}
}

private void RepairAppbarPolicyIfNeeded()
{
if (!_enabled) return;

_lastAppbarPolicyCheckUtc = DateTime.UtcNow;
uint state = _taskbars.GetAppbarState();
if ((state & NativeMethods.ABS_AUTOHIDE) != 0) return;

_appbarPolicyRepairAttempts++;
_taskbars.RefreshTaskbars();
_taskbars.EnsureAppbarPolicy(true);
_lastAppbarPolicyRepairUtc = DateTime.UtcNow;

uint after = _taskbars.GetAppbarState();
if ((after & NativeMethods.ABS_AUTOHIDE) != 0)
_appbarPolicyRepairSuccesses++;
}

private void HandleRawInput(IntPtr rawInputHandle)
{
uint size = 0;
Expand Down
22 changes: 6 additions & 16 deletions bootstrap/payload/SlipperyContext.Polling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ private IntPtr MouseHookCallback(int nCode, IntPtr wParam, IntPtr lParam)
NativeMethods.MSLLHOOKSTRUCT mouse = (NativeMethods.MSLLHOOKSTRUCT)Marshal.PtrToStructure(
lParam, typeof(NativeMethods.MSLLHOOKSTRUCT));

// Do not touch ABM_SETSTATE here. Changing ABS_AUTOHIDE causes
// Explorer to recalculate the desktop work area, which makes
// maximized windows resize when Win or a tray flyout is used.
// Instead, pre-authorize the notification-area transition and
// keep the actual taskbar window physically on-screen.
if (_taskbars.IsPointOverNotificationArea(mouse.pt))
{
TimeSpan grace = message == NativeMethods.WM_LBUTTONDOWN
Expand Down Expand Up @@ -60,6 +55,12 @@ private void PollTaskbarState()
ReconcileWinKeyStateFromPolling();
DateTime now = DateTime.UtcNow;

if (_lastAppbarPolicyCheckUtc == DateTime.MinValue ||
now - _lastAppbarPolicyCheckUtc >= AppbarPolicyWatchInterval)
{
RepairAppbarPolicyIfNeeded();
}

bool trayOverflowOpen = _taskbars.IsTrayOverflowOpen();
if (trayOverflowOpen)
{
Expand All @@ -83,17 +84,6 @@ private void PollTaskbarState()
bool allTaskbarsVisible;
_taskbars.GetActualVisibilityState(out anyTaskbarVisible, out allTaskbarsVisible);

// Native auto-hide is enabled only so Windows releases the taskbar's work
// area. Explorer may still try to reveal the bar when the pointer touches
// an edge, so immediately correct any visibility that Slippery did not
// authorize. Conversely, if Explorer auto-hides while Start/shell UI is
// active, put the taskbar back on-screen.
// Only correct the dangerous direction here: Explorer revealing a
// taskbar that Slippery intends to keep hidden. When the taskbar is
// intentionally visible, Explorer is allowed to own the intermediate
// frames of Start/tray/XAML animations. Re-showing or repositioning the
// taskbar during those frames is what caused the visible close/reopen
// stutter around the hidden-icons flyout.
bool unauthorizedReveal = !shouldShow && anyTaskbarVisible;

if (shouldShow != _lastShouldShow || unauthorizedReveal || _lastApplyUtc == DateTime.MinValue)
Expand Down
10 changes: 4 additions & 6 deletions bootstrap/payload/TaskbarController.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ public void ApplyVisibility(bool show)
foreach (IntPtr h in _taskbars)
{
if (!NativeMethods.IsWindow(h)) continue;

// Match Buttery Taskbar's least-invasive visibility model: one
// synchronous ShowWindow call, with Explorer left in control of the
// taskbar's own auto-hide/XAML animation and position. Do not pair
// this with SetWindowPos or force the bar back onto the monitor; those
// operations can fight Explorer mid-animation and create a flash.
NativeMethods.ShowWindow(h, show ? NativeMethods.SW_SHOWNOACTIVATE : NativeMethods.SW_HIDE);
}
}
Expand Down Expand Up @@ -131,8 +125,12 @@ public uint GetAppbarState()

private void SetAppbarState(uint state)
{
IntPtr primaryTaskbar = NativeMethods.FindWindow("Shell_TrayWnd", null);
if (primaryTaskbar == IntPtr.Zero) return;

NativeMethods.APPBARDATA data = new NativeMethods.APPBARDATA();
data.cbSize = (uint)Marshal.SizeOf(typeof(NativeMethods.APPBARDATA));
data.hWnd = primaryTaskbar;
data.lParam = new IntPtr((long)state);
NativeMethods.SHAppBarMessage(NativeMethods.ABM_SETSTATE, ref data);
}
Expand Down
6 changes: 6 additions & 0 deletions src/SlipperyContext.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ internal sealed partial class SlipperyContext : ApplicationContext, IDisposable
private bool _lastShouldShow = true;
private DateTime _lastApplyUtc = DateTime.MinValue;
private DateTime _trayInteractionPinUntilUtc = DateTime.MinValue;
private DateTime _lastAppbarPolicyCheckUtc = DateTime.MinValue;
private DateTime _lastAppbarPolicyRepairUtc = DateTime.MinValue;
private int _appbarPolicyRepairAttempts;
private int _appbarPolicyRepairSuccesses;
private IntPtr _mouseHook = IntPtr.Zero;
private NativeMethods.LowLevelMouseProc _mouseHookProc;
private bool _disposed;
Expand All @@ -49,6 +53,7 @@ internal sealed partial class SlipperyContext : ApplicationContext, IDisposable
private static readonly TimeSpan TrayInteractionPinGrace = TimeSpan.FromMilliseconds(900);
private static readonly TimeSpan TrayClickPinGrace = TimeSpan.FromMilliseconds(1800);
private static readonly TimeSpan TrayHoverPinGrace = TimeSpan.FromMilliseconds(500);
private static readonly TimeSpan AppbarPolicyWatchInterval = TimeSpan.FromMilliseconds(500);

public SlipperyContext()
{
Expand Down Expand Up @@ -215,6 +220,7 @@ private void SetEnabled(bool value)
_trayInteractionPinUntilUtc = DateTime.MinValue;
_taskbars.EnsureAppbarPolicy(_enabled);
_taskbars.EnsureWorkAreaPolicy(_enabled);
_lastAppbarPolicyCheckUtc = DateTime.MinValue;

if (!_enabled)
{
Expand Down
5 changes: 4 additions & 1 deletion src/SlipperyContext.Diagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private void CopyDiagnostics()
{
StringBuilder b = new StringBuilder();
b.AppendLine("Slippery Taskbar C# diagnostics");
b.AppendLine("Build: 1.0.0");
b.AppendLine("Build: 1.0.4-policy");
b.AppendLine("Runtime: " + Environment.Version);
b.AppendLine("OS: " + Environment.OSVersion);
b.AppendLine("Executable: " + Application.ExecutablePath);
Expand All @@ -29,6 +29,9 @@ private void CopyDiagnostics()
b.AppendLine("Start with Windows: " + _startWithWindows);
b.AppendLine("Keep visible while interacting: " + _preferencesStore.Current.KeepVisibleWhileInteracting);
b.AppendLine("Native auto-hide active: " + ((_taskbars.GetAppbarState() & NativeMethods.ABS_AUTOHIDE) != 0));
b.AppendLine("Appbar policy repair attempts: " + _appbarPolicyRepairAttempts);
b.AppendLine("Appbar policy repair successes: " + _appbarPolicyRepairSuccesses);
b.AppendLine("Last appbar policy repair UTC: " + (_lastAppbarPolicyRepairUtc == DateTime.MinValue ? "never" : _lastAppbarPolicyRepairUtc.ToString("O")));
b.AppendLine("Tray visibility guard active: " + (DateTime.UtcNow < _trayInteractionPinUntilUtc || _taskbars.IsTrayOverflowOpen()));
b.AppendLine("Notification-area mouse guard installed: " + (_mouseHook != IntPtr.Zero));
b.AppendLine("Work area: " + _taskbars.DescribeWorkArea());
Expand Down
21 changes: 21 additions & 0 deletions src/SlipperyContext.Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ internal void HandleWindowMessage(ref Message m)
case NativeMethods.WM_DISPLAYCHANGE:
case NativeMethods.WM_SETTINGCHANGE:
_taskbars.RefreshTaskbars();
RepairAppbarPolicyIfNeeded();
break;
case NativeMethods.WM_POWERBROADCAST:
int power = m.WParam.ToInt32();
Expand All @@ -44,6 +45,7 @@ internal void HandleWindowMessage(ref Message m)
_taskbars.RefreshTaskbars();
_taskbars.EnsureAppbarPolicy(_enabled);
_taskbars.EnsureWorkAreaPolicy(_enabled);
_lastAppbarPolicyCheckUtc = DateTime.UtcNow;
_visibleUntilUtc = DateTime.UtcNow.AddMilliseconds(750);
}
break;
Expand All @@ -55,6 +57,7 @@ private void HandleExplorerRestart()
_taskbars.RefreshTaskbars();
_taskbars.EnsureAppbarPolicy(_enabled);
_taskbars.EnsureWorkAreaPolicy(_enabled);
_lastAppbarPolicyCheckUtc = DateTime.UtcNow;
_visibleUntilUtc = DateTime.UtcNow.AddMilliseconds(750);

// NotifyIcon normally recreates itself after TaskbarCreated, but
Expand All @@ -66,6 +69,24 @@ private void HandleExplorerRestart()
}
}

private void RepairAppbarPolicyIfNeeded()
{
if (!_enabled) return;

_lastAppbarPolicyCheckUtc = DateTime.UtcNow;
uint state = _taskbars.GetAppbarState();
if ((state & NativeMethods.ABS_AUTOHIDE) != 0) return;

_appbarPolicyRepairAttempts++;
_taskbars.RefreshTaskbars();
_taskbars.EnsureAppbarPolicy(true);
_lastAppbarPolicyRepairUtc = DateTime.UtcNow;

uint after = _taskbars.GetAppbarState();
if ((after & NativeMethods.ABS_AUTOHIDE) != 0)
_appbarPolicyRepairSuccesses++;
}

private void HandleRawInput(IntPtr rawInputHandle)
{
uint size = 0;
Expand Down
22 changes: 6 additions & 16 deletions src/SlipperyContext.Polling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ private IntPtr MouseHookCallback(int nCode, IntPtr wParam, IntPtr lParam)
NativeMethods.MSLLHOOKSTRUCT mouse = (NativeMethods.MSLLHOOKSTRUCT)Marshal.PtrToStructure(
lParam, typeof(NativeMethods.MSLLHOOKSTRUCT));

// Do not touch ABM_SETSTATE here. Changing ABS_AUTOHIDE causes
// Explorer to recalculate the desktop work area, which makes
// maximized windows resize when Win or a tray flyout is used.
// Instead, pre-authorize the notification-area transition and
// keep the actual taskbar window physically on-screen.
if (_taskbars.IsPointOverNotificationArea(mouse.pt))
{
TimeSpan grace = message == NativeMethods.WM_LBUTTONDOWN
Expand Down Expand Up @@ -60,6 +55,12 @@ private void PollTaskbarState()
ReconcileWinKeyStateFromPolling();
DateTime now = DateTime.UtcNow;

if (_lastAppbarPolicyCheckUtc == DateTime.MinValue ||
now - _lastAppbarPolicyCheckUtc >= AppbarPolicyWatchInterval)
{
RepairAppbarPolicyIfNeeded();
}

bool trayOverflowOpen = _taskbars.IsTrayOverflowOpen();
if (trayOverflowOpen)
{
Expand All @@ -83,17 +84,6 @@ private void PollTaskbarState()
bool allTaskbarsVisible;
_taskbars.GetActualVisibilityState(out anyTaskbarVisible, out allTaskbarsVisible);

// Native auto-hide is enabled only so Windows releases the taskbar's work
// area. Explorer may still try to reveal the bar when the pointer touches
// an edge, so immediately correct any visibility that Slippery did not
// authorize. Conversely, if Explorer auto-hides while Start/shell UI is
// active, put the taskbar back on-screen.
// Only correct the dangerous direction here: Explorer revealing a
// taskbar that Slippery intends to keep hidden. When the taskbar is
// intentionally visible, Explorer is allowed to own the intermediate
// frames of Start/tray/XAML animations. Re-showing or repositioning the
// taskbar during those frames is what caused the visible close/reopen
// stutter around the hidden-icons flyout.
bool unauthorizedReveal = !shouldShow && anyTaskbarVisible;

if (shouldShow != _lastShouldShow || unauthorizedReveal || _lastApplyUtc == DateTime.MinValue)
Expand Down
4 changes: 2 additions & 2 deletions src/SlipperyTaskbar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<PublishTrimmed>false</PublishTrimmed>
<Version>1.0.0</Version>
<FileVersion>1.0.0.0</FileVersion>
<Version>1.0.4</Version>
<FileVersion>1.0.4.0</FileVersion>
<Product>Slippery Taskbar</Product>
<Description>Hide the Windows 11 taskbar until the Windows key or shell UI intentionally reveals it.</Description>
</PropertyGroup>
Expand Down
9 changes: 4 additions & 5 deletions src/TaskbarController.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public void ApplyVisibility(bool show)
{
if (!NativeMethods.IsWindow(h)) continue;

// Match Buttery Taskbar's least-invasive visibility model: one
// synchronous ShowWindow call, with Explorer left in control of the
// taskbar's own auto-hide/XAML animation and position. Do not pair
// this with SetWindowPos or force the bar back onto the monitor; those
// operations can fight Explorer mid-animation and create a flash.
NativeMethods.ShowWindow(h, show ? NativeMethods.SW_SHOWNOACTIVATE : NativeMethods.SW_HIDE);
}
}
Expand Down Expand Up @@ -131,8 +126,12 @@ public uint GetAppbarState()

private void SetAppbarState(uint state)
{
IntPtr primaryTaskbar = NativeMethods.FindWindow("Shell_TrayWnd", null);
if (primaryTaskbar == IntPtr.Zero) return;

NativeMethods.APPBARDATA data = new NativeMethods.APPBARDATA();
data.cbSize = (uint)Marshal.SizeOf(typeof(NativeMethods.APPBARDATA));
data.hWnd = primaryTaskbar;
data.lParam = new IntPtr((long)state);
NativeMethods.SHAppBarMessage(NativeMethods.ABM_SETSTATE, ref data);
}
Expand Down
Loading