Skip to content

fix: prevent always-on-top from leaking when disabled#583

Merged
rygel merged 1 commit intodevelopfrom
fix/always-on-top-leak
Apr 26, 2026
Merged

fix: prevent always-on-top from leaking when disabled#583
rygel merged 1 commit intodevelopfrom
fix/always-on-top-leak

Conversation

@rygel
Copy link
Copy Markdown
Owner

@rygel rygel commented Apr 26, 2026

Summary

  • Fix window staying topmost when Always On Top is disabled
  • Remove hardcoded Topmost="True" from MainWindow.xaml so preferences control initial state
  • Fix ApplyTopmostState(false) to always call ApplyWin32Topmost(false) (was only called when ForceWin32Topmost was enabled, creating an asymmetric set-but-never-cleared Win32 flag)
  • Remove hardcoded IsChecked="True" from both inline and Settings Always On Top checkboxes

Root cause

EnsureAlwaysOnTop() always calls SetWindowPos(HWND_TOPMOST) via Win32, but ApplyTopmostState(false) only called SetWindowPos(HWND_NOTOPMOST) when ForceWin32Topmost was true (default: false). Combined with Topmost="True" hardcoded in XAML, the Win32 topmost flag was set on startup and never properly cleared when the user toggled the setting off.

Test plan

  • Build succeeds (0 errors)
  • All 1311 tests pass
  • Verify window does NOT start as topmost when Always On Top preference is false
  • Verify toggling Always On Top off properly clears the Win32 topmost flag
  • Verify toggling Always On Top on still works correctly

Three issues caused the window to stay topmost even when the user
disabled Always On Top:

1. MainWindow.xaml hardcoded Topmost=True, forcing the window to start
   as topmost regardless of saved preference. Changed to False so
   ApplyPreferences() controls the initial state.

2. ApplyTopmostState(false) did not call ApplyWin32Topmost(false) unless
   ForceWin32Topmost was enabled. Since EnsureAlwaysOnTop() always
   calls SetWindowPos(HWND_TOPMOST), the manual Win32 topmost flag was
   set but never explicitly cleared. Now always calls ApplyWin32Topmost
   for symmetry.

3. XAML checkboxes for Always On Top (both inline and Settings) hardcoded
   IsChecked=True, which contradicted the preference default. Changed to
   False so ApplyPreferences() controls checkbox state.
@rygel rygel merged commit be6b796 into develop Apr 26, 2026
17 checks passed
@rygel rygel deleted the fix/always-on-top-leak branch April 26, 2026 16:45
@rygel rygel mentioned this pull request Apr 26, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants