mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add support for concurrent operation of explorers & dialogs adding
This commit is contained in:
parent
d4e672d630
commit
c2157e2df1
1 changed files with 30 additions and 15 deletions
|
|
@ -13,6 +13,7 @@ using NHotkey;
|
|||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.UI.Accessibility;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Flow.Launcher.Infrastructure.DialogJump
|
||||
{
|
||||
|
|
@ -64,12 +65,12 @@ namespace Flow.Launcher.Infrastructure.DialogJump
|
|||
|
||||
private static HWND _mainWindowHandle = HWND.Null;
|
||||
|
||||
private static readonly Dictionary<DialogJumpExplorerPair, IDialogJumpExplorerWindow> _dialogJumpExplorers = new();
|
||||
private static readonly ConcurrentDictionary<DialogJumpExplorerPair, IDialogJumpExplorerWindow> _dialogJumpExplorers = new();
|
||||
|
||||
private static DialogJumpExplorerPair _lastExplorer = null;
|
||||
private static readonly object _lastExplorerLock = new();
|
||||
|
||||
private static readonly Dictionary<DialogJumpDialogPair, IDialogJumpDialogWindow> _dialogJumpDialogs = new();
|
||||
private static readonly ConcurrentDictionary<DialogJumpDialogPair, IDialogJumpDialogWindow> _dialogJumpDialogs = new();
|
||||
|
||||
private static IDialogJumpDialogWindow _dialogWindow = null;
|
||||
private static readonly object _dialogWindowLock = new();
|
||||
|
|
@ -105,22 +106,13 @@ namespace Flow.Launcher.Infrastructure.DialogJump
|
|||
|
||||
#region Initialize & Setup
|
||||
|
||||
public static void InitializeDialogJump(IList<DialogJumpExplorerPair> dialogJumpExplorers,
|
||||
IList<DialogJumpDialogPair> dialogJumpDialogs)
|
||||
public static void InitializeDialogJump()
|
||||
{
|
||||
if (_initialized) return;
|
||||
|
||||
// Initialize Dialog Jump explorers & dialogs
|
||||
_dialogJumpExplorers.Add(WindowsDialogJumpExplorer, null);
|
||||
foreach (var explorer in dialogJumpExplorers)
|
||||
{
|
||||
_dialogJumpExplorers.Add(explorer, null);
|
||||
}
|
||||
_dialogJumpDialogs.Add(WindowsDialogJumpDialog, null);
|
||||
foreach (var dialog in dialogJumpDialogs)
|
||||
{
|
||||
_dialogJumpDialogs.Add(dialog, null);
|
||||
}
|
||||
// Initialize preinstalled Dialog Jump explorers & dialogs
|
||||
_dialogJumpExplorers.TryAdd(WindowsDialogJumpExplorer, null);
|
||||
_dialogJumpDialogs.TryAdd(WindowsDialogJumpDialog, null);
|
||||
|
||||
// Initialize main window handle
|
||||
_mainWindowHandle = Win32Helper.GetMainWindowHandle();
|
||||
|
|
@ -135,6 +127,29 @@ namespace Flow.Launcher.Infrastructure.DialogJump
|
|||
_initialized = true;
|
||||
}
|
||||
|
||||
public static void InitializeDialogJumpPlugin(PluginPair pair)
|
||||
{
|
||||
// Add Dialog Jump explorers & dialogs
|
||||
if (pair.Plugin is IDialogJumpExplorer explorer)
|
||||
{
|
||||
var dialogJumpExplorer = new DialogJumpExplorerPair
|
||||
{
|
||||
Plugin = explorer,
|
||||
Metadata = pair.Metadata
|
||||
};
|
||||
_dialogJumpExplorers.TryAdd(dialogJumpExplorer, null);
|
||||
}
|
||||
else if (pair.Plugin is IDialogJumpDialog dialog)
|
||||
{
|
||||
var dialogJumpDialog = new DialogJumpDialogPair
|
||||
{
|
||||
Plugin = dialog,
|
||||
Metadata = pair.Metadata
|
||||
};
|
||||
_dialogJumpDialogs.TryAdd(dialogJumpDialog, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetupDialogJump(bool enabled)
|
||||
{
|
||||
if (enabled == _enabled) return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue