mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
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:
parent
8092a440f4
commit
8e80c3bde6
6 changed files with 59 additions and 1 deletions
|
|
@ -91,4 +91,6 @@ PBT_APMRESUMEAUTOMATIC
|
|||
PBT_APMRESUMESUSPEND
|
||||
PowerRegisterSuspendResumeNotification
|
||||
PowerUnregisterSuspendResumeNotification
|
||||
DeviceNotifyCallbackRoutine
|
||||
DeviceNotifyCallbackRoutine
|
||||
|
||||
MonitorFromWindow
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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}"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue