Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f2bd10e
Fix ABM_SETSTATE taskbar handle
OHHIM Oct 20, 2026
88a3ff3
Sync appbar handle fix into setup payload
OHHIM Oct 20, 2026
30a8231
Bump test build to v1.0.1
OHHIM Oct 20, 2026
ed755d8
Set assembly version to 1.0.1
OHHIM Oct 20, 2026
8af613b
Label diagnostics as v1.0.1
OHHIM Oct 20, 2026
bea4e4f
Sync v1.0.1 diagnostics into setup payload
OHHIM Oct 20, 2026
914557a
x
OHHIM Oct 20, 2026
e454b8c
Remove accidental temporary file
OHHIM Oct 20, 2026
6a4e8bd
x
OHHIM Oct 20, 2026
b36a458
Remove accidental temporary file
OHHIM Oct 20, 2026
01d3085
Correct top and side maximized-window gaps
OHHIM Oct 20, 2026
44cb266
Sync top and side maximized-gap correction into setup payload
OHHIM Oct 20, 2026
e76f669
Report focused maximized-gap correction diagnostics
OHHIM Oct 20, 2026
50384e6
Sync focused gap diagnostics into setup payload
OHHIM Oct 20, 2026
7acd5e6
Set focused gap-fix test version
OHHIM Oct 20, 2026
d387d90
Bump gap-fix test project version
OHHIM Oct 20, 2026
06321b1
Add foreground maximized gap watcher
OHHIM Oct 20, 2026
08b19b3
Sync foreground gap watcher into setup payload
OHHIM Oct 20, 2026
b6c0c7e
Compile foreground gap watcher in framework build
OHHIM Oct 20, 2026
c7ce6ae
Watch foreground maximized app for stale top and side gap
OHHIM Oct 20, 2026
dc1fc8e
Sync foreground gap watcher polling into setup payload
OHHIM Oct 20, 2026
b7487f8
Track foreground gap corrections
OHHIM Oct 20, 2026
02afad1
Sync foreground correction counter into setup payload
OHHIM Oct 20, 2026
6743b2f
Report foreground gap watcher activity
OHHIM Oct 20, 2026
8c648a2
Sync foreground gap watcher diagnostics into setup payload
OHHIM Oct 20, 2026
9239e6d
Bump gap watcher test to v1.0.3
OHHIM Oct 20, 2026
6cd1570
Bump project version to v1.0.3
OHHIM Oct 20, 2026
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.3
4 changes: 3 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.3-gapwatch");
b.AppendLine("Runtime: " + Environment.Version);
b.AppendLine("OS: " + Environment.OSVersion);
b.AppendLine("Executable: " + Application.ExecutablePath);
Expand All @@ -29,6 +29,8 @@ 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("Top/side maximized gap corrections on last hide: " + _taskbars.LastGapCorrectionCount);
b.AppendLine("Foreground gap watcher corrections: " + _taskbars.ForegroundGapCorrectionCount);
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: 5 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 @@ -83,17 +78,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 All @@ -104,6 +88,11 @@ private void PollTaskbarState()
return;
}

if (!shouldShow)
{
_taskbars.CorrectForegroundMaximizedGap();
}

if (!shouldShow && now - _lastApplyUtc >= HiddenStateWatchdog)
{
_taskbars.ApplyVisibility(false);
Expand Down
157 changes: 151 additions & 6 deletions bootstrap/payload/TaskbarController.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,27 @@ internal sealed partial class TaskbarController
private bool _originalAppbarCaptured;
private readonly List<WorkAreaEntry> _originalWorkAreas = new List<WorkAreaEntry>();
private bool _workAreasCaptured;
private int _lastGapCorrections;

private sealed class WorkAreaEntry
{
public NativeMethods.RECT Monitor;
public NativeMethods.RECT Work;
}

private sealed class TaskbarEdgeInfo
{
public IntPtr Monitor;
public NativeMethods.RECT MonitorRect;
public int Edge;
public int Thickness;
}

private const int EdgeTop = 0;
private const int EdgeLeft = 1;
private const int EdgeRight = 2;
private const int EdgeBottom = 3;

public TaskbarController(string stateDirectory)
{
_workAreaStatePath = Path.Combine(stateDirectory, "workarea.state");
Expand Down Expand Up @@ -69,17 +83,144 @@ public IList<IntPtr> RefreshTaskbars()
public void ApplyVisibility(bool show)
{
RefreshTaskbars();
List<TaskbarEdgeInfo> edges = show ? null : CaptureTaskbarEdges();

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);
}

if (!show && edges != null)
CorrectTopAndSideMaximizedGaps(edges);
}

private List<TaskbarEdgeInfo> CaptureTaskbarEdges()
{
List<TaskbarEdgeInfo> edges = new List<TaskbarEdgeInfo>();
foreach (IntPtr taskbar in _taskbars)
{
NativeMethods.RECT taskbarRect;
if (!NativeMethods.GetWindowRect(taskbar, out taskbarRect)) continue;

IntPtr monitor = NativeMethods.MonitorFromWindow(taskbar, NativeMethods.MONITOR_DEFAULTTONEAREST);
if (monitor == IntPtr.Zero) continue;

NativeMethods.MONITORINFO mi = new NativeMethods.MONITORINFO();
mi.cbSize = Marshal.SizeOf(typeof(NativeMethods.MONITORINFO));
if (!NativeMethods.GetMonitorInfo(monitor, ref mi)) continue;

int width = taskbarRect.Right - taskbarRect.Left;
int height = taskbarRect.Bottom - taskbarRect.Top;
if (width <= 0 || height <= 0) continue;

TaskbarEdgeInfo info = new TaskbarEdgeInfo();
info.Monitor = monitor;
info.MonitorRect = mi.rcMonitor;
if (width >= height)
{
bool top = Math.Abs(taskbarRect.Top - mi.rcMonitor.Top) <=
Math.Abs(taskbarRect.Bottom - mi.rcMonitor.Bottom);
info.Edge = top ? EdgeTop : EdgeBottom;
info.Thickness = height;
}
else
{
bool left = Math.Abs(taskbarRect.Left - mi.rcMonitor.Left) <=
Math.Abs(taskbarRect.Right - mi.rcMonitor.Right);
info.Edge = left ? EdgeLeft : EdgeRight;
info.Thickness = width;
}
edges.Add(info);
}
return edges;
}

private void CorrectTopAndSideMaximizedGaps(List<TaskbarEdgeInfo> edges)
{
_lastGapCorrections = 0;
foreach (TaskbarEdgeInfo edge in edges)
{
if (edge.Edge == EdgeBottom) continue;

NativeMethods.EnumWindows(delegate(IntPtr hWnd, IntPtr lParam)
{
if (!NativeMethods.IsWindowVisible(hWnd)) return true;
string cls = GetWindowClass(hWnd);
if (IsTaskbarClass(cls)) return true;

IntPtr monitor = NativeMethods.MonitorFromWindow(hWnd, NativeMethods.MONITOR_DEFAULTTONEAREST);
if (monitor != edge.Monitor) return true;

NativeMethods.RECT r;
if (!NativeMethods.GetWindowRect(hWnd, out r)) return true;
int width = r.Right - r.Left;
int height = r.Bottom - r.Top;
if (width <= 0 || height <= 0) return true;

NativeMethods.RECT m = edge.MonitorRect;
int tolerance = Math.Max(16, edge.Thickness / 2);
int minGap = Math.Max(12, edge.Thickness / 3);
int maxGap = Math.Max(160, edge.Thickness * 3);
int gap = 0;
bool looksMaximized = false;

if (edge.Edge == EdgeTop)
{
gap = r.Top - m.Top;
looksMaximized = r.Left <= m.Left + tolerance &&
r.Right >= m.Right - tolerance &&
r.Bottom >= m.Bottom - tolerance;
}
else if (edge.Edge == EdgeLeft)
{
gap = r.Left - m.Left;
looksMaximized = r.Top <= m.Top + tolerance &&
r.Bottom >= m.Bottom - tolerance &&
r.Right >= m.Right - tolerance;
}
else if (edge.Edge == EdgeRight)
{
gap = m.Right - r.Right;
looksMaximized = r.Top <= m.Top + tolerance &&
r.Bottom >= m.Bottom - tolerance &&
r.Left <= m.Left + tolerance;
}

if (!looksMaximized || gap < minGap || gap > maxGap) return true;

int x = r.Left;
int y = r.Top;
int cx = width;
int cy = height;

if (edge.Edge == EdgeTop)
{
y -= gap;
cy += gap;
}
else if (edge.Edge == EdgeLeft)
{
x -= gap;
cx += gap;
}
else if (edge.Edge == EdgeRight)
{
cx += gap;
}

if (NativeMethods.SetWindowPos(hWnd, IntPtr.Zero, x, y, cx, cy,
NativeMethods.SWP_NOACTIVATE | NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOSENDCHANGING))
_lastGapCorrections++;

return true;
}, IntPtr.Zero);
}
}

public int LastGapCorrectionCount
{
get { return _lastGapCorrections; }
}

private static void ForceTaskbarOnScreen(IntPtr h)
Expand Down Expand Up @@ -131,8 +272,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
106 changes: 106 additions & 0 deletions bootstrap/payload/TaskbarController.GapWatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace SlipperyTaskbar
{
internal sealed partial class TaskbarController
{
private DateTime _lastForegroundGapCheckUtc = DateTime.MinValue;
private int _foregroundGapCorrections;

[DllImport("user32.dll")]
private static extern bool IsZoomed(IntPtr hWnd);

public void CorrectForegroundMaximizedGap()
{
DateTime now = DateTime.UtcNow;
if (_lastForegroundGapCheckUtc != DateTime.MinValue &&
now - _lastForegroundGapCheckUtc < TimeSpan.FromMilliseconds(75))
return;
_lastForegroundGapCheckUtc = now;

IntPtr hWnd = NativeMethods.GetForegroundWindow();
if (hWnd == IntPtr.Zero || !NativeMethods.IsWindowVisible(hWnd) || !IsZoomed(hWnd)) return;

string cls = GetWindowClass(hWnd);
if (IsTaskbarClass(cls) || IsShellUiWindow(hWnd)) return;

NativeMethods.RECT r;
if (!NativeMethods.GetWindowRect(hWnd, out r)) return;

IntPtr monitor = NativeMethods.MonitorFromWindow(hWnd, NativeMethods.MONITOR_DEFAULTTONEAREST);
if (monitor == IntPtr.Zero) return;

NativeMethods.MONITORINFO mi = new NativeMethods.MONITORINFO();
mi.cbSize = Marshal.SizeOf(typeof(NativeMethods.MONITORINFO));
if (!NativeMethods.GetMonitorInfo(monitor, ref mi)) return;

NativeMethods.RECT m = mi.rcMonitor;
int monitorWidth = m.Right - m.Left;
int monitorHeight = m.Bottom - m.Top;
if (monitorWidth <= 0 || monitorHeight <= 0) return;

int tolerance = Math.Max(12, Math.Min(monitorWidth, monitorHeight) / 100);
int maxGap = 192;

int topGap = r.Top - m.Top;
int leftGap = r.Left - m.Left;
int rightGap = m.Right - r.Right;
int bottomGap = m.Bottom - r.Bottom;

bool changed = false;
int x = r.Left;
int y = r.Top;
int right = r.Right;
int bottom = r.Bottom;

if (topGap >= 12 && topGap <= maxGap &&
Math.Abs(leftGap) <= tolerance && Math.Abs(rightGap) <= tolerance && Math.Abs(bottomGap) <= tolerance)
{
y = m.Top;
changed = true;
}
else if (leftGap >= 12 && leftGap <= maxGap &&
Math.Abs(topGap) <= tolerance && Math.Abs(rightGap) <= tolerance && Math.Abs(bottomGap) <= tolerance)
{
x = m.Left;
changed = true;
}
else if (rightGap >= 12 && rightGap <= maxGap &&
Math.Abs(topGap) <= tolerance && Math.Abs(leftGap) <= tolerance && Math.Abs(bottomGap) <= tolerance)
{
right = m.Right;
changed = true;
}

if (!changed) return;

int cx = right - x;
int cy = bottom - y;
if (cx <= 0 || cy <= 0) return;

if (NativeMethods.SetWindowPos(hWnd, IntPtr.Zero, x, y, cx, cy,
NativeMethods.SWP_NOACTIVATE | NativeMethods.SWP_NOZORDER | NativeMethods.SWP_NOSENDCHANGING))
{
_lastGapCorrections++;
_foregroundGapCorrections++;
}
}

public int ForegroundGapCorrectionCount
{
get { return _foregroundGapCorrections; }
}
}
}
4 changes: 3 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.3-gapwatch");
b.AppendLine("Runtime: " + Environment.Version);
b.AppendLine("OS: " + Environment.OSVersion);
b.AppendLine("Executable: " + Application.ExecutablePath);
Expand All @@ -29,6 +29,8 @@ 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("Top/side maximized gap corrections on last hide: " + _taskbars.LastGapCorrectionCount);
b.AppendLine("Foreground gap watcher corrections: " + _taskbars.ForegroundGapCorrectionCount);
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
Loading
Loading