Skip to content

Commit 8e80c3b

Browse files
VictoriousRaptorCopilotJack251970
authored
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 <[email protected]> * Fix: Use ABM_ACTIVATE instead of ABM_SETSTATE for temporary taskbar showing Co-authored-by: VictoriousRaptor <[email protected]> * Remove unnecessary unsafe keyword from ShowTaskbar method Co-authored-by: VictoriousRaptor <[email protected]> * Fix missing closing braces in Win32Helper.cs Co-authored-by: VictoriousRaptor <[email protected]> * Change wording from 'invoked' to 'opened' in localization strings Co-authored-by: VictoriousRaptor <[email protected]> * 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] <[email protected]> Co-authored-by: Jack Ye <[email protected]> Co-authored-by: Jack251970 <[email protected]>
1 parent 8092a44 commit 8e80c3b

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

Flow.Launcher.Infrastructure/NativeMethods.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,6 @@ PBT_APMRESUMEAUTOMATIC
9191
PBT_APMRESUMESUSPEND
9292
PowerRegisterSuspendResumeNotification
9393
PowerUnregisterSuspendResumeNotification
94-
DeviceNotifyCallbackRoutine
94+
DeviceNotifyCallbackRoutine
95+
96+
MonitorFromWindow

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ public bool HideNotifyIcon
481481
}
482482
public bool LeaveCmdOpen { get; set; }
483483
public bool HideWhenDeactivated { get; set; } = true;
484+
public bool ShowTaskbarWhenInvoked { get; set; } = false;
484485

485486
private bool _showAtTopmost = false;
486487
public bool ShowAtTopmost

Flow.Launcher.Infrastructure/Win32Helper.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,5 +1016,32 @@ protected override bool ReleaseHandle()
10161016
}
10171017

10181018
#endregion
1019+
1020+
#region Taskbar
1021+
1022+
public static unsafe void ShowTaskbar()
1023+
{
1024+
// Find the taskbar window
1025+
var taskbarHwnd = PInvoke.FindWindowEx(HWND.Null, HWND.Null, "Shell_TrayWnd", null);
1026+
if (taskbarHwnd == HWND.Null) return;
1027+
1028+
// Magic from https://github.com/Oliviaophia/SmartTaskbar
1029+
const uint TrayBarFlag = 0x05D1;
1030+
var mon = PInvoke.MonitorFromWindow(taskbarHwnd, Windows.Win32.Graphics.Gdi.MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST);
1031+
PInvoke.PostMessage(taskbarHwnd, TrayBarFlag, new WPARAM(1), new LPARAM((nint)mon.Value));
1032+
}
1033+
1034+
public static void HideTaskbar()
1035+
{
1036+
// Find the taskbar window
1037+
var taskbarHwnd = PInvoke.FindWindowEx(HWND.Null, HWND.Null, "Shell_TrayWnd", null);
1038+
if (taskbarHwnd == HWND.Null) return;
1039+
1040+
// Magic from https://github.com/Oliviaophia/SmartTaskbar
1041+
const uint TrayBarFlag = 0x05D1;
1042+
PInvoke.PostMessage(taskbarHwnd, TrayBarFlag, new WPARAM(0), IntPtr.Zero);
1043+
}
1044+
1045+
#endregion
10191046
}
10201047
}

Flow.Launcher/Languages/en.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
<system:String x:Key="useLogonTaskForStartupTooltip">After uninstallation, you need to manually remove this task (Flow.Launcher Startup) via Task Scheduler</system:String>
8282
<system:String x:Key="setAutoStartFailed">Error setting launch on startup</system:String>
8383
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Hide Flow Launcher when focus is lost</system:String>
84+
<system:String x:Key="showTaskbarWhenOpened">Show taskbar when Flow Launcher is opened</system:String>
85+
<system:String x:Key="showTaskbarWhenOpenedToolTip">Temporarily show the taskbar when Flow Launcher is opened, useful for auto-hidden taskbars.</system:String>
8486
<system:String x:Key="dontPromptUpdateMsg">Do not show new version notifications</system:String>
8587
<system:String x:Key="SearchWindowPosition">Search Window Location</system:String>
8688
<system:String x:Key="SearchWindowScreenRememberLastLaunchLocation">Remember Last Position</system:String>

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@
7272
OnContent="{DynamicResource enable}" />
7373
</ui:SettingsCard>
7474

75+
<ui:SettingsCard
76+
Margin="0 4 0 0"
77+
Description="{DynamicResource showTaskbarWhenOpenedToolTip}"
78+
Header="{DynamicResource showTaskbarWhenOpened}">
79+
<ui:ToggleSwitch
80+
IsOn="{Binding Settings.ShowTaskbarWhenInvoked}"
81+
OffContent="{DynamicResource disable}"
82+
OnContent="{DynamicResource enable}" />
83+
</ui:SettingsCard>
84+
7585
<ui:SettingsCard
7686
Margin="0 4 0 0"
7787
Description="{DynamicResource hideNotifyIconToolTip}"

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable, IResultUp
6464
Priority = 0 // Priority is for calculating scores in UpdateResultView
6565
};
6666

67+
private bool _taskbarShownByFlow = false;
68+
6769
#endregion
6870

6971
#region Constructor
@@ -2134,6 +2136,13 @@ public void Show()
21342136
{
21352137
Win32Helper.SwitchToEnglishKeyboardLayout(true);
21362138
}
2139+
2140+
// Show the taskbar if the setting is enabled
2141+
if (Settings.ShowTaskbarWhenInvoked && !_taskbarShownByFlow)
2142+
{
2143+
Win32Helper.ShowTaskbar();
2144+
_taskbarShownByFlow = true;
2145+
}
21372146
}
21382147

21392148
public async void Hide(bool reset = true)
@@ -2202,6 +2211,13 @@ public async void Hide(bool reset = true)
22022211
Win32Helper.RestorePreviousKeyboardLayout();
22032212
}
22042213

2214+
// Hide the taskbar if the setting is enabled
2215+
if (_taskbarShownByFlow)
2216+
{
2217+
Win32Helper.HideTaskbar();
2218+
_taskbarShownByFlow = false;
2219+
}
2220+
22052221
// Delay for a while to make sure clock will not flicker
22062222
await Task.Delay(50);
22072223

0 commit comments

Comments
 (0)