fix: prevent always-on-top from leaking when disabled#583
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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