mirror of
https://github.com/microsoft/PowerToys
synced 2024-11-23 09:28:14 +00:00
Revert "[Peek] Fix PreviewHandler previewer not visible on first activation (#34991)"
This reverts commit 056fba0dcf
.
This commit is contained in:
parent
9e3a19804c
commit
18d7682af5
@ -13,4 +13,5 @@
|
|||||||
GotFocus="UserControl_GotFocus"
|
GotFocus="UserControl_GotFocus"
|
||||||
IsEnabled="False"
|
IsEnabled="False"
|
||||||
IsTabStop="True"
|
IsTabStop="True"
|
||||||
|
Loaded="UserControl_Loaded"
|
||||||
mc:Ignorable="d" />
|
mc:Ignorable="d" />
|
||||||
|
@ -61,8 +61,6 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
|
|
||||||
partial void OnSourceChanged(IPreviewHandler? value)
|
partial void OnSourceChanged(IPreviewHandler? value)
|
||||||
{
|
{
|
||||||
EnsureContainerHwndCreated();
|
|
||||||
|
|
||||||
if (Source != null)
|
if (Source != null)
|
||||||
{
|
{
|
||||||
UpdatePreviewerTheme();
|
UpdatePreviewerTheme();
|
||||||
@ -84,8 +82,6 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
|
|
||||||
private void OnHandlerVisibilityChanged()
|
private void OnHandlerVisibilityChanged()
|
||||||
{
|
{
|
||||||
EnsureContainerHwndCreated();
|
|
||||||
|
|
||||||
if (HandlerVisibility == Visibility.Visible)
|
if (HandlerVisibility == Visibility.Visible)
|
||||||
{
|
{
|
||||||
PInvoke.ShowWindow(containerHwnd, SHOW_WINDOW_CMD.SW_SHOW);
|
PInvoke.ShowWindow(containerHwnd, SHOW_WINDOW_CMD.SW_SHOW);
|
||||||
@ -142,19 +138,8 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
return PInvoke.DefWindowProc(hWnd, msg, wParam, lParam);
|
return PInvoke.DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnsureContainerHwndCreated()
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!containerHwnd.IsNull)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var peekWindow = new HWND(Win32Interop.GetWindowFromWindowId(XamlRoot?.ContentIslandEnvironment?.AppWindowId ?? default));
|
|
||||||
if (peekWindow.IsNull)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fixed (char* pContainerClassName = "PeekShellPreviewHandlerContainer")
|
fixed (char* pContainerClassName = "PeekShellPreviewHandlerContainer")
|
||||||
{
|
{
|
||||||
PInvoke.RegisterClass(new WNDCLASSW()
|
PInvoke.RegisterClass(new WNDCLASSW()
|
||||||
@ -173,7 +158,7 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
0, // Y
|
0, // Y
|
||||||
0, // Width
|
0, // Width
|
||||||
0, // Height
|
0, // Height
|
||||||
peekWindow,
|
(HWND)Win32Interop.GetWindowFromWindowId(XamlRoot.ContentIslandEnvironment.AppWindowId), // Peek UI window
|
||||||
HMENU.Null,
|
HMENU.Null,
|
||||||
HINSTANCE.Null);
|
HINSTANCE.Null);
|
||||||
|
|
||||||
@ -184,8 +169,6 @@ namespace Peek.FilePreviewer.Controls
|
|||||||
|
|
||||||
private void UserControl_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args)
|
private void UserControl_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args)
|
||||||
{
|
{
|
||||||
EnsureContainerHwndCreated();
|
|
||||||
|
|
||||||
var dpi = (float)PInvoke.GetDpiForWindow(containerHwnd) / 96;
|
var dpi = (float)PInvoke.GetDpiForWindow(containerHwnd) / 96;
|
||||||
|
|
||||||
// Resize the container window
|
// Resize the container window
|
||||||
|
Loading…
Reference in New Issue
Block a user