Skip to content
Open
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
16 changes: 16 additions & 0 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ private void OnLoaded(object sender, RoutedEventArgs e)
// Since the default main window visibility is visible, so we need set focus during startup
QueryTextBox.Focus();

// When the window is shown on startup, focusing QueryTextBox is not enough: the window also
// has to be activated to actually take OS-level keyboard focus. Otherwise, when Flow Launcher
// is auto-started with Windows (Startup folder or logon task), the search box looks focused but
// keystrokes go elsewhere until the user clicks it.
// This is dispatched at Loaded priority because Activate() throws if the window has not finished
// being shown yet, and skipped entirely when the window starts hidden for the same reason.
if (!_settings.HideOnStartup)
{
Dispatcher.BeginInvoke(new Action(() =>
{
if (!_viewModel.MainWindowVisibilityStatus) return;
Activate();
QueryTextBox.Focus();
}), DispatcherPriority.Loaded);
}

// Set the initial state of the QueryTextBoxCursorMovedToEnd property
// Without this part, when shown for the first time, switching the context menu does not move the cursor to the end.
_viewModel.QueryTextCursorMovedToEnd = false;
Expand Down
Loading