3
3
using System . Linq ;
4
4
using System . Windows ;
5
5
using System . Windows . Input ;
6
+ using ChefKeys ;
6
7
using Flow . Launcher . Core . Resource ;
7
8
using Flow . Launcher . Helper ;
8
9
using Flow . Launcher . Infrastructure . Hotkey ;
@@ -33,6 +34,8 @@ public enum EResultType
33
34
public string ResultValue { get ; private set ; } = string . Empty ;
34
35
public static string EmptyHotkey => InternationalizationManager . Instance . GetTranslation ( "none" ) ;
35
36
37
+ private static bool isOpenFlowHotkey ;
38
+
36
39
public HotkeyControlDialog ( string hotkey , string defaultHotkey , IHotkeySettings hotkeySettings , string windowTitle = "" )
37
40
{
38
41
WindowTitle = windowTitle switch
@@ -46,6 +49,14 @@ public HotkeyControlDialog(string hotkey, string defaultHotkey, IHotkeySettings
46
49
SetKeysToDisplay ( CurrentHotkey ) ;
47
50
48
51
InitializeComponent ( ) ;
52
+
53
+ // TODO: This is a temporary way to enforce changing only the open flow hotkey to Win, and will be removed by PR #3157
54
+ isOpenFlowHotkey = _hotkeySettings . RegisteredHotkeys
55
+ . Any ( x => x . DescriptionResourceKey == "flowlauncherHotkey"
56
+ && x . Hotkey . ToString ( ) == hotkey ) ;
57
+
58
+ ChefKeysManager . StartMenuEnableBlocking = true ;
59
+ ChefKeysManager . Start ( ) ;
49
60
}
50
61
51
62
private void Reset ( object sender , RoutedEventArgs routedEventArgs )
@@ -61,12 +72,18 @@ private void Delete(object sender, RoutedEventArgs routedEventArgs)
61
72
62
73
private void Cancel ( object sender , RoutedEventArgs routedEventArgs )
63
74
{
75
+ ChefKeysManager . StartMenuEnableBlocking = false ;
76
+ ChefKeysManager . Stop ( ) ;
77
+
64
78
ResultType = EResultType . Cancel ;
65
79
Hide ( ) ;
66
80
}
67
81
68
82
private void Save ( object sender , RoutedEventArgs routedEventArgs )
69
83
{
84
+ ChefKeysManager . StartMenuEnableBlocking = false ;
85
+ ChefKeysManager . Stop ( ) ;
86
+
70
87
if ( KeysToDisplay . Count == 1 && KeysToDisplay [ 0 ] == EmptyHotkey )
71
88
{
72
89
ResultType = EResultType . Delete ;
@@ -85,6 +102,9 @@ private void OnPreviewKeyDown(object sender, KeyEventArgs e)
85
102
//when alt is pressed, the real key should be e.SystemKey
86
103
Key key = e . Key == Key . System ? e . SystemKey : e . Key ;
87
104
105
+ if ( ChefKeysManager . StartMenuBlocked && key . ToString ( ) == ChefKeysManager . StartMenuSimulatedKey )
106
+ return ;
107
+
88
108
SpecialKeyState specialKeyState = GlobalHotkey . CheckModifiers ( ) ;
89
109
90
110
var hotkeyModel = new HotkeyModel (
@@ -168,8 +188,13 @@ private void SetKeysToDisplay(HotkeyModel? hotkey)
168
188
}
169
189
}
170
190
171
- private static bool CheckHotkeyAvailability ( HotkeyModel hotkey , bool validateKeyGesture ) =>
172
- hotkey . Validate ( validateKeyGesture ) && HotKeyMapper . CheckAvailability ( hotkey ) ;
191
+ private static bool CheckHotkeyAvailability ( HotkeyModel hotkey , bool validateKeyGesture )
192
+ {
193
+ if ( isOpenFlowHotkey && ( hotkey . ToString ( ) == "LWin" || hotkey . ToString ( ) == "RWin" ) )
194
+ return true ;
195
+
196
+ return hotkey . Validate ( validateKeyGesture ) && HotKeyMapper . CheckAvailability ( hotkey ) ;
197
+ }
173
198
174
199
private void Overwrite ( object sender , RoutedEventArgs e )
175
200
{
0 commit comments