From efa8ed13d275cd7059d5a4399a945aab5cce1a30 Mon Sep 17 00:00:00 2001 From: rampaa Date: Mon, 14 Oct 2024 02:10:25 +0300 Subject: [PATCH] Minor --- JL.Windows/ConfigManager.cs | 4 ++-- JL.Windows/GUI/MainWindow.xaml.cs | 12 ++++++------ JL.Windows/GUI/PopupWindow.xaml.cs | 4 ++-- JL.Windows/Utilities/KeyGestureUtils.cs | 4 ++-- JL.Windows/Utilities/WindowsUtils.cs | 16 ++++++++-------- JL.Windows/WinApi.cs | 10 +++++----- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/JL.Windows/ConfigManager.cs b/JL.Windows/ConfigManager.cs index a6493459..fb05930c 100644 --- a/JL.Windows/ConfigManager.cs +++ b/JL.Windows/ConfigManager.cs @@ -450,7 +450,7 @@ public static void ApplyPreferences() ? MainWindowBackgroundOpacityOnUnhover / 100 : MainWindow.Instance.OpacitySlider.Value / 100; - WinApi.UnregisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); KeyGestureUtils.GlobalKeyGestureDict.Clear(); KeyGestureUtils.GlobalKeyGestureNameToIntDict.Clear(); @@ -520,7 +520,7 @@ public static void ApplyPreferences() if (GlobalHotKeys && !DisableHotkeys) { - WinApi.RegisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.RegisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } MainWindow.Instance.AddNameMenuItem.SetInputGestureText(ShowAddNameWindowKeyGesture); diff --git a/JL.Windows/GUI/MainWindow.xaml.cs b/JL.Windows/GUI/MainWindow.xaml.cs index ab00e1ae..a49cda58 100644 --- a/JL.Windows/GUI/MainWindow.xaml.cs +++ b/JL.Windows/GUI/MainWindow.xaml.cs @@ -474,16 +474,16 @@ public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e) { if (KeyGestureUtils.GlobalKeyGestureNameToIntDict.TryGetValue(nameof(ConfigManager.DisableHotkeys), out int id)) { - WinApi.UnregisterAllHotKeys(WindowHandle, id); + WinApi.UnregisterAllGlobalHotKeys(WindowHandle, id); } else { - WinApi.UnregisterAllHotKeys(WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(WindowHandle); } } else { - WinApi.RegisterAllHotKeys(WindowHandle); + WinApi.RegisterAllGlobalHotKeys(WindowHandle); } } } @@ -1624,11 +1624,11 @@ private void Window_StateChanged(object sender, EventArgs e) if (keyGestureIdsToIgnore.Count > 0) { - WinApi.UnregisterAllHotKeys(WindowHandle, keyGestureIdsToIgnore); + WinApi.UnregisterAllGlobalHotKeys(WindowHandle, keyGestureIdsToIgnore); } else { - WinApi.UnregisterAllHotKeys(WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(WindowHandle); } } } @@ -1643,7 +1643,7 @@ private void Window_StateChanged(object sender, EventArgs e) if (ConfigManager.GlobalHotKeys) { - WinApi.RegisterAllHotKeys(WindowHandle); + WinApi.RegisterAllGlobalHotKeys(WindowHandle); } if (SizeToContent is SizeToContent.Manual && (ConfigManager.MainWindowDynamicHeight || ConfigManager.MainWindowDynamicWidth)) diff --git a/JL.Windows/GUI/PopupWindow.xaml.cs b/JL.Windows/GUI/PopupWindow.xaml.cs index ae14ad7a..5138cfd7 100644 --- a/JL.Windows/GUI/PopupWindow.xaml.cs +++ b/JL.Windows/GUI/PopupWindow.xaml.cs @@ -1299,11 +1299,11 @@ public async Task HandleHotKey(KeyGesture keyGesture, KeyEventArgs? e) { if (ConfigManager.DisableHotkeys) { - WinApi.UnregisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } else { - WinApi.RegisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.RegisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } } } diff --git a/JL.Windows/Utilities/KeyGestureUtils.cs b/JL.Windows/Utilities/KeyGestureUtils.cs index b3957922..3046e00a 100644 --- a/JL.Windows/Utilities/KeyGestureUtils.cs +++ b/JL.Windows/Utilities/KeyGestureUtils.cs @@ -181,7 +181,7 @@ public static KeyGesture GetKeyGestureFromConfig(SqliteConnection connection, st KeyGesture newKeyGesture = (KeyGesture)keyGestureConverter.ConvertFromInvariantString(keyGestureString)!; if (ConfigManager.GlobalHotKeys) { - WinApi.AddHotKeyToKeyGestureDict(keyGestureName, newKeyGesture); + WinApi.AddHotKeyToGlobalKeyGestureDict(keyGestureName, newKeyGesture); } return newKeyGesture; @@ -190,7 +190,7 @@ public static KeyGesture GetKeyGestureFromConfig(SqliteConnection connection, st ConfigDBManager.InsertSetting(connection, keyGestureName, defaultKeyGesture.ToFormattedString()); if (ConfigManager.GlobalHotKeys) { - WinApi.AddHotKeyToKeyGestureDict(keyGestureName, defaultKeyGesture); + WinApi.AddHotKeyToGlobalKeyGestureDict(keyGestureName, defaultKeyGesture); } return defaultKeyGesture; diff --git a/JL.Windows/Utilities/WindowsUtils.cs b/JL.Windows/Utilities/WindowsUtils.cs index 805de7d9..63cdb6e9 100644 --- a/JL.Windows/Utilities/WindowsUtils.cs +++ b/JL.Windows/Utilities/WindowsUtils.cs @@ -150,7 +150,7 @@ public static void ShowAddNameWindow(Window owner, string? selectedText, string if (ConfigManager.GlobalHotKeys && !ConfigManager.DisableHotkeys) { - WinApi.UnregisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } _ = addNameWindowInstance.ShowDialog(); @@ -166,7 +166,7 @@ public static void ShowAddWordWindow(Window owner, string? selectedText) if (ConfigManager.GlobalHotKeys && !ConfigManager.DisableHotkeys) { - WinApi.UnregisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } _ = addWordWindowInstance.ShowDialog(); @@ -182,7 +182,7 @@ public static void ShowPreferencesWindow() if (ConfigManager.GlobalHotKeys && !ConfigManager.DisableHotkeys) { - WinApi.UnregisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } _ = preferencesWindow.ShowDialog(); @@ -214,7 +214,7 @@ public static async Task ShowManageDictionariesWindow() if (ConfigManager.GlobalHotKeys && !ConfigManager.DisableHotkeys) { - WinApi.UnregisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } _ = manageDictionariesWindow.ShowDialog(); @@ -234,7 +234,7 @@ public static async Task ShowManageFrequenciesWindow() if (ConfigManager.GlobalHotKeys && !ConfigManager.DisableHotkeys) { - WinApi.UnregisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } _ = manageFrequenciesWindow.ShowDialog(); @@ -251,7 +251,7 @@ public static void ShowStatsWindow() if (ConfigManager.GlobalHotKeys && !ConfigManager.DisableHotkeys) { - WinApi.UnregisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } _ = statsWindow.ShowDialog(); @@ -271,7 +271,7 @@ public static async Task ShowManageAudioSourcesWindow() if (ConfigManager.GlobalHotKeys && !ConfigManager.DisableHotkeys) { - WinApi.UnregisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.UnregisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } _ = manageAudioSourcesWindow.ShowDialog(); @@ -702,7 +702,7 @@ public static void UpdateMainWindowVisibility() if (ConfigManager.GlobalHotKeys && !ConfigManager.DisableHotkeys) { - WinApi.RegisterAllHotKeys(MainWindow.Instance.WindowHandle); + WinApi.RegisterAllGlobalHotKeys(MainWindow.Instance.WindowHandle); } } diff --git a/JL.Windows/WinApi.cs b/JL.Windows/WinApi.cs index c15e7978..f1e1e2b4 100644 --- a/JL.Windows/WinApi.cs +++ b/JL.Windows/WinApi.cs @@ -186,7 +186,7 @@ public static ulong GetClipboardSequenceNo() return GetClipboardSequenceNumber(); } - public static void AddHotKeyToKeyGestureDict(string hotkeyName, KeyGesture keyGesture) + public static void AddHotKeyToGlobalKeyGestureDict(string hotkeyName, KeyGesture keyGesture) { int id = KeyGestureUtils.GlobalKeyGestureDict.Count; @@ -208,7 +208,7 @@ public static void AddHotKeyToKeyGestureDict(string hotkeyName, KeyGesture keyGe } } - public static void RegisterAllHotKeys(nint windowHandle) + public static void RegisterAllGlobalHotKeys(nint windowHandle) { foreach (KeyValuePair keyValuePair in KeyGestureUtils.GlobalKeyGestureDict) { @@ -216,7 +216,7 @@ public static void RegisterAllHotKeys(nint windowHandle) } } - public static void UnregisterAllHotKeys(nint windowHandle) + public static void UnregisterAllGlobalHotKeys(nint windowHandle) { foreach (int id in KeyGestureUtils.GlobalKeyGestureDict.Keys) { @@ -224,7 +224,7 @@ public static void UnregisterAllHotKeys(nint windowHandle) } } - public static void UnregisterAllHotKeys(nint windowHandle, int keyGestureIdToIgnore) + public static void UnregisterAllGlobalHotKeys(nint windowHandle, int keyGestureIdToIgnore) { foreach (int id in KeyGestureUtils.GlobalKeyGestureDict.Keys) { @@ -237,7 +237,7 @@ public static void UnregisterAllHotKeys(nint windowHandle, int keyGestureIdToIgn } } - public static void UnregisterAllHotKeys(nint windowHandle, List keyGestureIdsToIgnore) + public static void UnregisterAllGlobalHotKeys(nint windowHandle, List keyGestureIdsToIgnore) { foreach (int id in KeyGestureUtils.GlobalKeyGestureDict.Keys) {