Skip to content

Commit

Permalink
Steal focus when bringing up the Launcher prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
traies committed Jun 3, 2020
1 parent 9e58bf9 commit e5c330a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/modules/launcher/Wox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public MainWindow(Settings settings, MainViewModel mainVM)
DataContext = mainVM;
_viewModel = mainVM;
_settings = settings;
_viewModel.WindowChangedToVisible += OnWindowChangedToVisible;
InitializeComponent();
}
public MainWindow()
Expand Down Expand Up @@ -239,5 +240,11 @@ private void OnTextChanged(object sender, TextChangedEventArgs e)
{

}

// Steal focus when the launcher prompt is visible again.
private void OnWindowChangedToVisible(object sender, EventArgs e)
{
Focus();
}
}
}
3 changes: 3 additions & 0 deletions src/modules/launcher/Wox/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class MainViewModel : BaseModel, ISavable

#endregion

public event EventHandler WindowChangedToVisible;

#region Constructor

public MainViewModel(Settings settings)
Expand Down Expand Up @@ -619,6 +621,7 @@ private void ToggleWox()
if (MainWindowVisibility != Visibility.Visible)
{
MainWindowVisibility = Visibility.Visible;
WindowChangedToVisible?.Invoke(this, new EventArgs());
}
else
{
Expand Down

0 comments on commit e5c330a

Please # to comment.