mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[PTRun]Bring back acrylic and proper fix to title bar accent showing (#33458)
* Revert "[PTRun]Fix accent on title bar bleed into UI (#33046)" This reverts commit8bb5a33572. * Revert "[PTRun]Use Mica backdrop to fix crashes with WPFUI (#32118)" This reverts commitb9da1e6abf. * Fix DWMAttributes in Wox Plugin Native Methods * Fix titlebar accent showing * Fix number on wrong enum
This commit is contained in:
@@ -19,13 +19,13 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
|||||||
/// <param name="hwnd">handle to the window to exclude</param>
|
/// <param name="hwnd">handle to the window to exclude</param>
|
||||||
public static void SetWindowExclusionFromLivePreview(IntPtr hwnd)
|
public static void SetWindowExclusionFromLivePreview(IntPtr hwnd)
|
||||||
{
|
{
|
||||||
int renderPolicy = (int)DwmNCRenderingPolicies.Enabled;
|
uint renderPolicy = (uint)DwmNCRenderingPolicies.Enabled;
|
||||||
|
|
||||||
_ = NativeMethods.DwmSetWindowAttribute(
|
_ = NativeMethods.DwmSetWindowAttribute(
|
||||||
hwnd,
|
hwnd,
|
||||||
12,
|
12,
|
||||||
ref renderPolicy,
|
ref renderPolicy,
|
||||||
sizeof(int));
|
sizeof(uint));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -32,9 +32,9 @@
|
|||||||
|
|
||||||
<Grid x:Name="RootGrid" MouseDown="OnMouseDown">
|
<Grid x:Name="RootGrid" MouseDown="OnMouseDown">
|
||||||
<!-- We set the background here because the Acrylic can be too translucent / background too bright on Light theme -->
|
<!-- We set the background here because the Acrylic can be too translucent / background too bright on Light theme -->
|
||||||
<!--<Grid.Background>
|
<Grid.Background>
|
||||||
<SolidColorBrush Opacity="0.8" Color="{DynamicResource ApplicationBackgroundColor}" />
|
<SolidColorBrush Opacity="0.8" Color="{DynamicResource ApplicationBackgroundColor}" />
|
||||||
</Grid.Background>-->
|
</Grid.Background>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
@@ -45,11 +45,6 @@
|
|||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Padding="12,4,12,3">
|
Padding="12,4,12,3">
|
||||||
<local:LauncherControl x:Name="SearchBox" />
|
<local:LauncherControl x:Name="SearchBox" />
|
||||||
<Border.Background>
|
|
||||||
<!-- Setting the background of the search bar to fix https://github.com/microsoft/PowerToys/issues/30206 -->
|
|
||||||
<!-- The title bar accent would bleed if the option to "Show accent color on title bars and windows borders" is enabled on Windows -->
|
|
||||||
<SolidColorBrush Opacity="1" Color="{DynamicResource ApplicationBackgroundColor}" />
|
|
||||||
</Border.Background>
|
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- Have to use a Grid instead of a StackPanel for scrolling to work? -->
|
<!-- Have to use a Grid instead of a StackPanel for scrolling to work? -->
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace PowerLauncher
|
|||||||
|
|
||||||
if (OSVersionHelper.IsWindows11())
|
if (OSVersionHelper.IsWindows11())
|
||||||
{
|
{
|
||||||
WindowBackdropType = Wpf.Ui.Controls.WindowBackdropType.Mica;
|
WindowBackdropType = Wpf.Ui.Controls.WindowBackdropType.Acrylic;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ using System.Collections.ObjectModel;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Interop;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using Common.UI;
|
using Common.UI;
|
||||||
using interop;
|
using interop;
|
||||||
@@ -1006,6 +1008,36 @@ namespace PowerLauncher.ViewModel
|
|||||||
if (MainWindowVisibility != Visibility.Visible)
|
if (MainWindowVisibility != Visibility.Visible)
|
||||||
{
|
{
|
||||||
MainWindowVisibility = Visibility.Visible;
|
MainWindowVisibility = Visibility.Visible;
|
||||||
|
|
||||||
|
// HACK: The following code in this if is a fix for https://github.com/microsoft/PowerToys/issues/30206 and https://github.com/microsoft/PowerToys/issues/33135
|
||||||
|
// WPF UI theme watcher removes the composition target background color, among other weird stuff.
|
||||||
|
// https://github.com/lepoco/wpfui/blob/303f0aefcd59a142bc681415dc4360a34a15f33d/src/Wpf.Ui/Controls/Window/WindowBackdrop.cs#L280
|
||||||
|
// So we set it back with https://github.com/lepoco/wpfui/blob/303f0aefcd59a142bc681415dc4360a34a15f33d/src/Wpf.Ui/Controls/Window/WindowBackdrop.cs#L191
|
||||||
|
var window = Application.Current.MainWindow;
|
||||||
|
Wpf.Ui.Controls.WindowBackdrop.RemoveBackground(window);
|
||||||
|
|
||||||
|
// Taken from WPFUI's fix for the title bar issue. We should be able to remove this fix when WPF UI 4 is integrated.
|
||||||
|
// https://github.com/lepoco/wpfui/pull/1122/files#diff-196b404f4db09632665ef546da6c8e57302b2f3e3d082eb4b5c295ae3482d94a
|
||||||
|
IntPtr windowHandle = new WindowInteropHelper(window).Handle;
|
||||||
|
if (windowHandle == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HwndSource windowSource = HwndSource.FromHwnd(windowHandle);
|
||||||
|
|
||||||
|
// Remove background from client area
|
||||||
|
if (windowSource != null && windowSource.Handle != IntPtr.Zero && windowSource?.CompositionTarget != null)
|
||||||
|
{
|
||||||
|
// NOTE: https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
||||||
|
// Specifying DWMWA_COLOR_DEFAULT (value 0xFFFFFFFF) for the color will reset the window back to using the system's default behavior for the caption color.
|
||||||
|
uint titlebarPvAttribute = 0xFFFFFFFE;
|
||||||
|
_ = Wox.Plugin.Common.Win32.NativeMethods.DwmSetWindowAttribute(
|
||||||
|
windowSource.Handle,
|
||||||
|
(int)Wox.Plugin.Common.Win32.DwmWindowAttributes.CaptionColor,
|
||||||
|
ref titlebarPvAttribute,
|
||||||
|
Marshal.SizeOf(typeof(uint)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace Wox.Plugin.Common.Win32
|
|||||||
public static extern int DwmpActivateLivePreview([MarshalAs(UnmanagedType.Bool)] bool fActivate, IntPtr hWndExclude, IntPtr hWndInsertBefore, LivePreviewTrigger lpt, IntPtr prcFinalRect);
|
public static extern int DwmpActivateLivePreview([MarshalAs(UnmanagedType.Bool)] bool fActivate, IntPtr hWndExclude, IntPtr hWndInsertBefore, LivePreviewTrigger lpt, IntPtr prcFinalRect);
|
||||||
|
|
||||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||||
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
|
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref uint attrValue, int attrSize);
|
||||||
|
|
||||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||||
public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out int pvAttribute, int cbAttribute);
|
public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out int pvAttribute, int cbAttribute);
|
||||||
@@ -493,28 +493,28 @@ namespace Wox.Plugin.Common.Win32
|
|||||||
public enum DwmWindowAttributes
|
public enum DwmWindowAttributes
|
||||||
{
|
{
|
||||||
NCRenderingEnabled = 1,
|
NCRenderingEnabled = 1,
|
||||||
NCRenderingPolicy,
|
NCRenderingPolicy = 2,
|
||||||
TransitionsForceDisabled,
|
TransitionsForceDisabled = 3,
|
||||||
AllowNCPaint,
|
AllowNCPaint = 4,
|
||||||
CaptionButtonBounds,
|
CaptionButtonBounds = 5,
|
||||||
NonClientRtlLayout,
|
NonClientRtlLayout = 6,
|
||||||
ForceIconicRepresentation,
|
ForceIconicRepresentation = 7,
|
||||||
Flip3DPolicy,
|
Flip3DPolicy = 8,
|
||||||
ExtendedFrameBounds,
|
ExtendedFrameBounds = 9,
|
||||||
HasIconicBitmap,
|
HasIconicBitmap = 10,
|
||||||
DisallowPeek,
|
DisallowPeek = 11,
|
||||||
ExcludedFromPeek,
|
ExcludedFromPeek = 12,
|
||||||
Cloak,
|
Cloak = 13,
|
||||||
Cloaked,
|
Cloaked = 14,
|
||||||
FreezeRepresentation,
|
FreezeRepresentation = 15,
|
||||||
PassiveUpdateMode,
|
PassiveUpdateMode = 16,
|
||||||
UseHostbackdropbrush,
|
UseHostbackdropbrush = 17,
|
||||||
UseImmersiveDarkMode,
|
UseImmersiveDarkMode = 20,
|
||||||
WindowCornerPreference,
|
WindowCornerPreference = 33,
|
||||||
BorderColor,
|
BorderColor = 34,
|
||||||
CaptionColor,
|
CaptionColor = 35,
|
||||||
TextColor,
|
TextColor = 36,
|
||||||
VisibleFrameBorderThickness,
|
VisibleFrameBorderThickness = 37,
|
||||||
Last,
|
Last,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user