diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index 9b9a9525d..40ef5e91a 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -96,7 +96,12 @@ namespace Flow.Launcher.Plugin
///
///
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 000000000..21c8ee53e
--- /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 4312df3c3..def54e04b 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -75,6 +75,8 @@ namespace Flow.Launcher
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 0110a11d7..c832c258d 100644
--- a/Flow.Launcher/ViewModel/MainViewModel.cs
+++ b/Flow.Launcher/ViewModel/MainViewModel.cs
@@ -578,6 +578,8 @@ namespace Flow.Launcher.ViewModel
// 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 @@ namespace Flow.Launcher.ViewModel
MainWindowOpacity = 1;
MainWindowVisibilityStatus = true;
+ VisibilityChanged?.Invoke(this, new VisibilityChangedEventArgs { IsVisible = true });
});
}
@@ -1048,6 +1051,7 @@ namespace Flow.Launcher.ViewModel
MainWindowVisibilityStatus = false;
MainWindowVisibility = Visibility.Collapsed;
+ VisibilityChanged?.Invoke(this, new VisibilityChangedEventArgs { IsVisible = false });
}
///