Add option to show taskbar when Flow Launcher is opend (#4177)

* Add option to show taskbar when Flow Launcher is invoked

Co-authored-by: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>

* Fix: Use ABM_ACTIVATE instead of ABM_SETSTATE for temporary taskbar showing

Co-authored-by: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>

* Remove unnecessary unsafe keyword from ShowTaskbar method

Co-authored-by: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>

* Fix missing closing braces in Win32Helper.cs

Co-authored-by: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>

* Change wording from 'invoked' to 'opened' in localization strings

Co-authored-by: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>

* Show/hide tasking when showing/hiding Flow

* Remove unused APPBARDATA

* Guard HideTaskbar() with state so show/hide stay balanced

* Improve taskbar visibility management in MainViewModel

Moved taskbar show logic to after keyboard layout switch in Show().Ensures consistent taskbar state when invoking or hiding the app.

* Clean code

* Clean code

* Remove blank line

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Jack Ye <jack1160210343@gmail.com>
Co-authored-by: Jack251970 <1160210343@qq.com>
This commit is contained in:
VictoriousRaptor 2025-12-31 18:05:53 +08:00 committed by GitHub
parent 8092a440f4
commit 8e80c3bde6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 59 additions and 1 deletions

View file

@ -92,3 +92,5 @@ PBT_APMRESUMESUSPEND
PowerRegisterSuspendResumeNotification
PowerUnregisterSuspendResumeNotification
DeviceNotifyCallbackRoutine
MonitorFromWindow

View file

@ -481,6 +481,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
}
public bool LeaveCmdOpen { get; set; }
public bool HideWhenDeactivated { get; set; } = true;
public bool ShowTaskbarWhenInvoked { get; set; } = false;
private bool _showAtTopmost = false;
public bool ShowAtTopmost

View file

@ -1016,5 +1016,32 @@ namespace Flow.Launcher.Infrastructure
}
#endregion
#region Taskbar
public static unsafe void ShowTaskbar()
{
// Find the taskbar window
var taskbarHwnd = PInvoke.FindWindowEx(HWND.Null, HWND.Null, "Shell_TrayWnd", null);
if (taskbarHwnd == HWND.Null) return;
// Magic from https://github.com/Oliviaophia/SmartTaskbar
const uint TrayBarFlag = 0x05D1;
var mon = PInvoke.MonitorFromWindow(taskbarHwnd, Windows.Win32.Graphics.Gdi.MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST);
PInvoke.PostMessage(taskbarHwnd, TrayBarFlag, new WPARAM(1), new LPARAM((nint)mon.Value));
}
public static void HideTaskbar()
{
// Find the taskbar window
var taskbarHwnd = PInvoke.FindWindowEx(HWND.Null, HWND.Null, "Shell_TrayWnd", null);
if (taskbarHwnd == HWND.Null) return;
// Magic from https://github.com/Oliviaophia/SmartTaskbar
const uint TrayBarFlag = 0x05D1;
PInvoke.PostMessage(taskbarHwnd, TrayBarFlag, new WPARAM(0), IntPtr.Zero);
}
#endregion
}
}

View file

@ -81,6 +81,8 @@
<system:String x:Key="useLogonTaskForStartupTooltip">After uninstallation, you need to manually remove this task (Flow.Launcher Startup) via Task Scheduler</system:String>
<system:String x:Key="setAutoStartFailed">Error setting launch on startup</system:String>
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Hide Flow Launcher when focus is lost</system:String>
<system:String x:Key="showTaskbarWhenOpened">Show taskbar when Flow Launcher is opened</system:String>
<system:String x:Key="showTaskbarWhenOpenedToolTip">Temporarily show the taskbar when Flow Launcher is opened, useful for auto-hidden taskbars.</system:String>
<system:String x:Key="dontPromptUpdateMsg">Do not show new version notifications</system:String>
<system:String x:Key="SearchWindowPosition">Search Window Location</system:String>
<system:String x:Key="SearchWindowScreenRememberLastLaunchLocation">Remember Last Position</system:String>

View file

@ -72,6 +72,16 @@
OnContent="{DynamicResource enable}" />
</ui:SettingsCard>
<ui:SettingsCard
Margin="0 4 0 0"
Description="{DynamicResource showTaskbarWhenOpenedToolTip}"
Header="{DynamicResource showTaskbarWhenOpened}">
<ui:ToggleSwitch
IsOn="{Binding Settings.ShowTaskbarWhenInvoked}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}" />
</ui:SettingsCard>
<ui:SettingsCard
Margin="0 4 0 0"
Description="{DynamicResource hideNotifyIconToolTip}"

View file

@ -64,6 +64,8 @@ namespace Flow.Launcher.ViewModel
Priority = 0 // Priority is for calculating scores in UpdateResultView
};
private bool _taskbarShownByFlow = false;
#endregion
#region Constructor
@ -2134,6 +2136,13 @@ namespace Flow.Launcher.ViewModel
{
Win32Helper.SwitchToEnglishKeyboardLayout(true);
}
// Show the taskbar if the setting is enabled
if (Settings.ShowTaskbarWhenInvoked && !_taskbarShownByFlow)
{
Win32Helper.ShowTaskbar();
_taskbarShownByFlow = true;
}
}
public async void Hide(bool reset = true)
@ -2202,6 +2211,13 @@ namespace Flow.Launcher.ViewModel
Win32Helper.RestorePreviousKeyboardLayout();
}
// Hide the taskbar if the setting is enabled
if (_taskbarShownByFlow)
{
Win32Helper.HideTaskbar();
_taskbarShownByFlow = false;
}
// Delay for a while to make sure clock will not flicker
await Task.Delay(50);