From fa9613252822d27368c70670fc41d0cac27b1139 Mon Sep 17 00:00:00 2001
From: Odotocodot <48138990+Odotocodot@users.noreply.github.com>
Date: Mon, 3 Jul 2023 22:42:41 +0100
Subject: [PATCH 1/4] Add Plugin API -> VisibiltyChangedEventHandler
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 7 ++++++-
.../VisibilityChangedEventHandler.cs | 21 +++++++++++++++++++
Flow.Launcher/PublicAPIInstance.cs | 2 ++
Flow.Launcher/ViewModel/MainViewModel.cs | 4 ++++
4 files changed, 33 insertions(+), 1 deletion(-)
create mode 100644 Flow.Launcher.Plugin/VisibilityChangedEventHandler.cs
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index 9b9a9525d5c..40ef5e91ae9 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -96,7 +96,12 @@ public interface IPublicAPI
///
///
bool IsMainWindowVisible();
-
+
+ ///
+ /// Invoked when the visibility of the main window has changed
+ ///
+ event VisibilityChangedEventHandler VisibilityChanged;
+
///
/// Show message box
///
diff --git a/Flow.Launcher.Plugin/VisibilityChangedEventHandler.cs b/Flow.Launcher.Plugin/VisibilityChangedEventHandler.cs
new file mode 100644
index 00000000000..21c8ee53e7a
--- /dev/null
+++ b/Flow.Launcher.Plugin/VisibilityChangedEventHandler.cs
@@ -0,0 +1,21 @@
+using System;
+
+namespace Flow.Launcher.Plugin
+{
+ ///
+ /// A delegate for when the visibility is changed
+ ///
+ ///
+ ///
+ public delegate void VisibilityChangedEventHandler(object sender, VisibilityChangedEventArgs args);
+ ///
+ /// The event args for
+ ///
+ public class VisibilityChangedEventArgs : EventArgs
+ {
+ ///
+ /// if the main window has become visible
+ ///
+ public bool IsVisible { get; init; }
+ }
+}
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index 4312df3c386..def54e04bc9 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -75,6 +75,8 @@ public void RestartApp()
public bool IsMainWindowVisible() => _mainVM.MainWindowVisibilityStatus;
+ public event VisibilityChangedEventHandler VisibilityChanged { add => _mainVM.VisibilityChanged += value; remove => _mainVM.VisibilityChanged -= value; }
+
public void CheckForNewUpdate() => _settingsVM.UpdateApp();
public void SaveAppAllSettings()
diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs
index 0110a11d775..c832c258d28 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -578,6 +578,8 @@ private ResultsViewModel SelectedResults
// because it is more accurate and reliable representation than using Visibility as a condition check
public bool MainWindowVisibilityStatus { get; set; } = true;
+ public event VisibilityChangedEventHandler VisibilityChanged;
+
public Visibility SearchIconVisibility { get; set; }
public double MainWindowWidth
@@ -1014,6 +1016,7 @@ public void Show()
MainWindowOpacity = 1;
MainWindowVisibilityStatus = true;
+ VisibilityChanged?.Invoke(this, new VisibilityChangedEventArgs { IsVisible = true });
});
}
@@ -1048,6 +1051,7 @@ public async void Hide()
MainWindowVisibilityStatus = false;
MainWindowVisibility = Visibility.Collapsed;
+ VisibilityChanged?.Invoke(this, new VisibilityChangedEventArgs { IsVisible = false });
}
///
From 7f43d854017c6e664a8cf74bf90a18f81b35bf4d Mon Sep 17 00:00:00 2001
From: Odotocodot <48138990+Odotocodot@users.noreply.github.com>
Date: Sun, 9 Jul 2023 14:07:54 +0100
Subject: [PATCH 2/4] Update Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
Co-authored-by: Jeremy Wu
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index 40ef5e91ae9..474ad6f0a5d 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -98,7 +98,7 @@ public interface IPublicAPI
bool IsMainWindowVisible();
///
- /// Invoked when the visibility of the main window has changed
+ /// Invoked when the visibility of the main window has changed. Currently, the plugin will continue to be subscribed even if it is turned off.
///
event VisibilityChangedEventHandler VisibilityChanged;
From 088818bb32812f0308cf80c32a00bbb160974542 Mon Sep 17 00:00:00 2001
From: Odotocodot <48138990+Odotocodot@users.noreply.github.com>
Date: Sun, 9 Jul 2023 15:54:32 +0100
Subject: [PATCH 3/4] Move delegate into EventHandler.cs
#2216
---
Flow.Launcher.Plugin/EventHandler.cs | 18 ++++++++++++++++
.../VisibilityChangedEventHandler.cs | 21 -------------------
2 files changed, 18 insertions(+), 21 deletions(-)
delete mode 100644 Flow.Launcher.Plugin/VisibilityChangedEventHandler.cs
diff --git a/Flow.Launcher.Plugin/EventHandler.cs b/Flow.Launcher.Plugin/EventHandler.cs
index 009e1721c42..78e4bd4ed81 100644
--- a/Flow.Launcher.Plugin/EventHandler.cs
+++ b/Flow.Launcher.Plugin/EventHandler.cs
@@ -32,6 +32,24 @@ namespace Flow.Launcher.Plugin
/// return true to continue handling, return false to intercept system handling
public delegate bool FlowLauncherGlobalKeyboardEventHandler(int keyevent, int vkcode, SpecialKeyState state);
+ ///
+ /// A delegate for when the visibility is changed
+ ///
+ ///
+ ///
+ public delegate void VisibilityChangedEventHandler(object sender, VisibilityChangedEventArgs args);
+
+ ///
+ /// The event args for
+ ///
+ public class VisibilityChangedEventArgs : EventArgs
+ {
+ ///
+ /// if the main window has become visible
+ ///
+ public bool IsVisible { get; init; }
+ }
+
///
/// Arguments container for the Key Down event
///
diff --git a/Flow.Launcher.Plugin/VisibilityChangedEventHandler.cs b/Flow.Launcher.Plugin/VisibilityChangedEventHandler.cs
deleted file mode 100644
index 21c8ee53e7a..00000000000
--- a/Flow.Launcher.Plugin/VisibilityChangedEventHandler.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-
-namespace Flow.Launcher.Plugin
-{
- ///
- /// A delegate for when the visibility is changed
- ///
- ///
- ///
- public delegate void VisibilityChangedEventHandler(object sender, VisibilityChangedEventArgs args);
- ///
- /// The event args for
- ///
- public class VisibilityChangedEventArgs : EventArgs
- {
- ///
- /// if the main window has become visible
- ///
- public bool IsVisible { get; init; }
- }
-}
From 4eb20e242f3e415b45ef9b0fdbccbe69d5e81a57 Mon Sep 17 00:00:00 2001
From: Ioannis G
Date: Sun, 9 Jul 2023 19:32:29 +0300
Subject: [PATCH 4/4] fix build issue introduced in 088818bb
---
Flow.Launcher.Plugin/EventHandler.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Flow.Launcher.Plugin/EventHandler.cs b/Flow.Launcher.Plugin/EventHandler.cs
index 78e4bd4ed81..893b0ba8047 100644
--- a/Flow.Launcher.Plugin/EventHandler.cs
+++ b/Flow.Launcher.Plugin/EventHandler.cs
@@ -1,4 +1,5 @@
-using System.Windows;
+using System;
+using System.Windows;
using System.Windows.Input;
namespace Flow.Launcher.Plugin