Skip to content

Commit 700b988

Browse files
VictoriousRaptorCopilotJack251970
authored andcommitted
Add option to show taskbar when Flow Launcher is opend (Flow-Launcher#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 4aff4a2 commit 700b988

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

Flow.Launcher.Infrastructure/NativeMethods.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,7 @@ CoTaskMemFree
5252

5353
IShellLinkW
5454
SLR_FLAGS
55-
WIN32_FIND_DATAW
55+
WIN32_FIND_DATAW
56+
57+
MonitorFromWindow
58+
PostMessage

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ public bool KeepMaxResults
202202

203203
public bool HideOnStartup { get; set; } = true;
204204
public bool HideWhenDeactivated { get; set; } = true;
205+
public bool ShowTaskbarWhenInvoked { get; set; } = false;
205206

206207
private bool _showAtTopmost = false;
207208
public bool ShowAtTopmost

Flow.Launcher.Infrastructure/Win32Helper.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,5 +416,32 @@ public static string SelectFile()
416416
}
417417

418418
#endregion
419+
420+
#region Taskbar
421+
422+
public static unsafe void ShowTaskbar()
423+
{
424+
// Find the taskbar window
425+
var taskbarHwnd = PInvoke.FindWindowEx(HWND.Null, HWND.Null, "Shell_TrayWnd", null);
426+
if (taskbarHwnd == HWND.Null) return;
427+
428+
// Magic from https://github.com/Oliviaophia/SmartTaskbar
429+
const uint TrayBarFlag = 0x05D1;
430+
var mon = PInvoke.MonitorFromWindow(taskbarHwnd, Windows.Win32.Graphics.Gdi.MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST);
431+
PInvoke.PostMessage(taskbarHwnd, TrayBarFlag, new WPARAM(1), new LPARAM((nint)mon.Value));
432+
}
433+
434+
public static void HideTaskbar()
435+
{
436+
// Find the taskbar window
437+
var taskbarHwnd = PInvoke.FindWindowEx(HWND.Null, HWND.Null, "Shell_TrayWnd", null);
438+
if (taskbarHwnd == HWND.Null) return;
439+
440+
// Magic from https://github.com/Oliviaophia/SmartTaskbar
441+
const uint TrayBarFlag = 0x05D1;
442+
PInvoke.PostMessage(taskbarHwnd, TrayBarFlag, new WPARAM(0), IntPtr.Zero);
443+
}
444+
445+
#endregion
419446
}
420447
}

Flow.Launcher/Languages/en.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
<system:String x:Key="flowlauncher_settings">Settings</system:String>
3636
<system:String x:Key="general">General</system:String>
3737
<system:String x:Key="hideFlowLauncherWhenLoseFocus">Hide Flow Launcher when focus is lost</system:String>
38+
<system:String x:Key="showTaskbarWhenOpened">Show taskbar when Flow Launcher is opened</system:String>
39+
<system:String x:Key="showTaskbarWhenOpenedToolTip">Temporarily show the taskbar when Flow Launcher is opened, useful for auto-hidden taskbars.</system:String>
3840
<system:String x:Key="SearchWindowPosition">Search Window Location</system:String>
3941
<system:String x:Key="SearchWindowScreenRememberLastLaunchLocation">Remember Last Position</system:String>
4042
<system:String x:Key="SearchWindowScreenCursor">Monitor with Mouse Cursor</system:String>

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949
OnContent="{DynamicResource enable}" />
5050
</ui:SettingsCard>
5151

52+
<ui:SettingsCard
53+
Margin="0 4 0 0"
54+
Description="{DynamicResource showTaskbarWhenOpenedToolTip}"
55+
Header="{DynamicResource showTaskbarWhenOpened}">
56+
<ui:ToggleSwitch
57+
IsOn="{Binding Settings.ShowTaskbarWhenInvoked}"
58+
OffContent="{DynamicResource disable}"
59+
OnContent="{DynamicResource enable}" />
60+
</ui:SettingsCard>
61+
5262
<ui:SettingsCard
5363
Margin="0 14 0 0"
5464
Description="{DynamicResource showAtTopmostToolTip}"

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable
4949
private readonly ResultsViewModel _results, _contextMenu;
5050
private readonly IReadOnlyList<Result> _emptyResult = [];
5151

52+
private bool _taskbarShownByFlow = false;
5253
#endregion
5354

5455
#region Constructor
@@ -1429,6 +1430,13 @@ public void Show()
14291430
MainWindowVisibility = Visibility.Visible;
14301431
MainWindowVisibilityStatus = true;
14311432
VisibilityChanged?.Invoke(this, new VisibilityChangedEventArgs { IsVisible = true });
1433+
1434+
// Show the taskbar if the setting is enabled
1435+
if (Settings.ShowTaskbarWhenInvoked && !_taskbarShownByFlow)
1436+
{
1437+
Win32Helper.ShowTaskbar();
1438+
_taskbarShownByFlow = true;
1439+
}
14321440
}
14331441

14341442
public async void Hide()
@@ -1473,6 +1481,13 @@ public async void Hide()
14731481
}
14741482
}, DispatcherPriority.Render);
14751483

1484+
// Hide the taskbar if the setting is enabled
1485+
if (_taskbarShownByFlow)
1486+
{
1487+
Win32Helper.HideTaskbar();
1488+
_taskbarShownByFlow = false;
1489+
}
1490+
14761491
// Update WPF properties
14771492
MainWindowVisibilityStatus = false;
14781493
MainWindowVisibility = Visibility.Collapsed;

0 commit comments

Comments
 (0)