mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
handle esc to dismiss dock flyout
This commit is contained in:
@@ -16,7 +16,7 @@ using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
|
||||
namespace Microsoft.CmdPal.UI.Dock;
|
||||
|
||||
public sealed partial class DockControl : UserControl, INotifyPropertyChanged
|
||||
public sealed partial class DockControl : UserControl, INotifyPropertyChanged, IRecipient<CloseContextMenuMessage>
|
||||
{
|
||||
private DockViewModel _viewModel;
|
||||
|
||||
@@ -104,6 +104,7 @@ public sealed partial class DockControl : UserControl, INotifyPropertyChanged
|
||||
// MainViewModel mainModel = (MainViewModel)DataContext;
|
||||
_viewModel = viewModel;
|
||||
InitializeComponent();
|
||||
WeakReferenceMessenger.Default.Register<CloseContextMenuMessage>(this);
|
||||
}
|
||||
|
||||
internal void UpdateSettings(DockSettings settings)
|
||||
@@ -200,4 +201,12 @@ public sealed partial class DockControl : UserControl, INotifyPropertyChanged
|
||||
// at its search box. The control isn't in the UI tree before that
|
||||
ContextControl.FocusSearchBox();
|
||||
}
|
||||
|
||||
public void Receive(CloseContextMenuMessage message)
|
||||
{
|
||||
if (ContextMenuFlyout.IsOpen)
|
||||
{
|
||||
ContextMenuFlyout.Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,8 +128,6 @@ internal sealed partial class NowDockBand : CommandItem
|
||||
Title = timeString;
|
||||
Subtitle = dateString;
|
||||
|
||||
//// TODO! This is a hack - we shouldn't need to set a Name on band items to get them to appear. We should be able to figure it out if there's a Icon OR HasText
|
||||
// ((NoOpCommand)Command).Name = $"{Title}\n{Subtitle}";
|
||||
_copyDateCommand.Text = dateString;
|
||||
_copyTimeCommand.Text = timeString;
|
||||
}
|
||||
|
||||
@@ -295,21 +295,30 @@ internal sealed class Window
|
||||
/// <returns>The state (none, app, ...) of the window</returns>
|
||||
internal WindowCloakState GetWindowCloakState()
|
||||
{
|
||||
_ = NativeMethods.DwmGetWindowAttribute(Hwnd, (int)DwmWindowAttributes.Cloaked, out var isCloakedState, sizeof(uint));
|
||||
|
||||
switch (isCloakedState)
|
||||
try
|
||||
{
|
||||
case (int)DwmWindowCloakStates.None:
|
||||
return WindowCloakState.None;
|
||||
case (int)DwmWindowCloakStates.CloakedApp:
|
||||
return WindowCloakState.App;
|
||||
case (int)DwmWindowCloakStates.CloakedShell:
|
||||
return WindowWalkerCommandsProvider.VirtualDesktopHelperInstance.IsWindowCloakedByVirtualDesktopManager(hwnd, Desktop.Id) ? WindowCloakState.OtherDesktop : WindowCloakState.Shell;
|
||||
case (int)DwmWindowCloakStates.CloakedInherited:
|
||||
return WindowCloakState.Inherited;
|
||||
default:
|
||||
return WindowCloakState.Unknown;
|
||||
_ = NativeMethods.DwmGetWindowAttribute(Hwnd, (int)DwmWindowAttributes.Cloaked, out var isCloakedState, sizeof(uint));
|
||||
|
||||
switch (isCloakedState)
|
||||
{
|
||||
case (int)DwmWindowCloakStates.None:
|
||||
return WindowCloakState.None;
|
||||
case (int)DwmWindowCloakStates.CloakedApp:
|
||||
return WindowCloakState.App;
|
||||
case (int)DwmWindowCloakStates.CloakedShell:
|
||||
return WindowWalkerCommandsProvider.VirtualDesktopHelperInstance.IsWindowCloakedByVirtualDesktopManager(hwnd, Desktop.Id) ? WindowCloakState.OtherDesktop : WindowCloakState.Shell;
|
||||
case (int)DwmWindowCloakStates.CloakedInherited:
|
||||
return WindowCloakState.Inherited;
|
||||
default:
|
||||
return WindowCloakState.Unknown;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Log?
|
||||
}
|
||||
|
||||
return WindowCloakState.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user