Fixed focus search box when Flow Launcher starts with Windows - #4593
Open
dedonnodev wants to merge 1 commit into
Open
Fixed focus search box when Flow Launcher starts with Windows#4593dedonnodev wants to merge 1 commit into
dedonnodev wants to merge 1 commit into
Conversation
Contributor
📝 WalkthroughWalkthrough
ChangesStartup focus handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Problem
When Flow Launcher is configured to start with Windows and "Hide on startup"
is disabled, the main window appears after login but does not hold keyboard
focus. The search box looks focused, yet keystrokes go nowhere until the user
clicks it. Invoking the window later with the hotkey works fine.
Cause
MainWindow.OnLoadedshows the window throughMainViewModel.Show(), whichsets
MainWindowVisibilityStatus = true. That property already defaults totrue, so noPropertyChangedevent is raised and the handler that runsActivate()beforeQueryTextBox.Focus()— the path used on everyhotkey-triggered show — never executes during startup.
Startup therefore only ran the bare
QueryTextBox.Focus(). That sets WPF'sinternal keyboard focus, but a process launched in the background by Windows
is not the foreground window, so it never receives real keyboard input.
The hotkey path always transitions visibility
false -> true, which is whyit is unaffected.
Fix
Activate the window on startup as well, once it has actually been shown.
The call is dispatched at
DispatcherPriority.Loadedand skipped whenHideOnStartupis enabled, becauseWindow.Activate()throwsInvalidOperationException: Cannot call DragMove or Activate before a Window is shownif the window has not finished being shown — which is the case inthe hidden-on-startup path, the default configuration.
Testing
HideOnStartupenabled (default): starts hidden, no exception, hotkey works as beforeHideOnStartupdisabled: window visible and immediately typeable after a rebootNote the testing section is left as unchecked boxes deliberately — I could not build or run this (no .NET SDK available here), so those still need your confirmation on Windows before you open the PR. Given the last iteration crashed on the default configuration, the first box in particular is worth exercising.
Summary by cubic
Fixes lost keyboard focus on Windows startup by activating the main window after it’s shown. When “Hide on startup” is off, the search box now accepts typing immediately.
Summary of changes
Dispatcher.BeginInvoke(atLoadedpriority) that:_settings.HideOnStartupis true._viewModel.MainWindowVisibilityStatusbefore callingActivate()and re-focusingQueryTextBox.Release Note
The app now takes keyboard focus on Windows startup (when not hidden), so you can type in the search box right away.
Written for commit 2f69032. Summary will update on new commits.