File tree 3 files changed +11
-19
lines changed
Flow.Launcher.Infrastructure
3 files changed +11
-19
lines changed Original file line number Diff line number Diff line change @@ -365,21 +365,10 @@ public static unsafe void SwitchToEnglishKeyboardLayout(bool backupPrevious)
365
365
// No installed English layout found
366
366
if ( enHKL == HKL . Null ) return ;
367
367
368
- // When application is exiting, the Application.Current will be null
369
- if ( Application . Current == null ) return ;
370
-
371
- // Get the FL main window
372
- var hwnd = GetWindowHandle ( Application . Current . MainWindow , true ) ;
368
+ // Get the foreground window
369
+ var hwnd = PInvoke . GetForegroundWindow ( ) ;
373
370
if ( hwnd == HWND . Null ) return ;
374
371
375
- // Check if the FL main window is the current foreground window
376
- if ( ! IsForegroundWindow ( hwnd ) )
377
- {
378
- var result = PInvoke . SetForegroundWindow ( hwnd ) ;
379
- // If we cannot set the foreground window, we can use the foreground window and switch the layout
380
- if ( ! result ) hwnd = PInvoke . GetForegroundWindow ( ) ;
381
- }
382
-
383
372
// Get the current foreground window thread ID
384
373
var threadId = PInvoke . GetWindowThreadProcessId ( hwnd ) ;
385
374
if ( threadId == 0 ) throw new Win32Exception ( Marshal . GetLastWin32Error ( ) ) ;
Original file line number Diff line number Diff line change 1
- #nullable enable
2
-
3
- using System . Collections . ObjectModel ;
1
+ using System . Collections . ObjectModel ;
4
2
using System . Threading . Tasks ;
5
3
using System . Windows ;
6
4
using System . Windows . Input ;
9
7
using Flow . Launcher . Infrastructure . Hotkey ;
10
8
using Flow . Launcher . Infrastructure . UserSettings ;
11
9
10
+ #nullable enable
11
+
12
12
namespace Flow . Launcher
13
13
{
14
14
public partial class HotkeyControl
@@ -242,7 +242,11 @@ private async Task OpenHotkeyDialogAsync()
242
242
HotKeyMapper . RemoveHotkey ( Hotkey ) ;
243
243
}
244
244
245
- var dialog = new HotkeyControlDialog ( Hotkey , DefaultHotkey , WindowTitle ) ;
245
+ var dialog = new HotkeyControlDialog ( Hotkey , DefaultHotkey , WindowTitle )
246
+ {
247
+ Owner = Window . GetWindow ( this )
248
+ } ;
249
+
246
250
await dialog . ShowAsync ( ) ;
247
251
switch ( dialog . ResultType )
248
252
{
Original file line number Diff line number Diff line change 5
5
using System . Windows ;
6
6
using CommunityToolkit . Mvvm . Input ;
7
7
using Flow . Launcher . Core . Plugin ;
8
- using Flow . Launcher . Infrastructure ;
9
8
using Flow . Launcher . Infrastructure . UserSettings ;
10
9
using Flow . Launcher . Plugin ;
11
10
using Flow . Launcher . ViewModel ;
@@ -116,6 +115,7 @@ private async Task OpenHelperAsync()
116
115
{
117
116
var helpDialog = new ContentDialog ( )
118
117
{
118
+ Owner = Application . Current . MainWindow ,
119
119
Content = new StackPanel
120
120
{
121
121
Children =
@@ -146,7 +146,6 @@ private async Task OpenHelperAsync()
146
146
}
147
147
}
148
148
} ,
149
-
150
149
PrimaryButtonText = ( string ) Application . Current . Resources [ "commonOK" ] ,
151
150
CornerRadius = new CornerRadius ( 8 ) ,
152
151
Style = ( Style ) Application . Current . Resources [ "ContentDialog" ]
You can’t perform that action at this time.
0 commit comments