diff --git a/shell/windows/LayersShell/MainWindow.xaml.cs b/shell/windows/LayersShell/MainWindow.xaml.cs index 6c85723..3b27cea 100644 --- a/shell/windows/LayersShell/MainWindow.xaml.cs +++ b/shell/windows/LayersShell/MainWindow.xaml.cs @@ -35,25 +35,39 @@ public sealed partial class MainWindow : Window _hwnd = WindowNative.GetWindowHandle(this); App.Log($"hwnd = {_hwnd:X}"); - var appWindow = AppWindow.GetFromWindowId(Win32Interop.GetWindowIdFromWindow(_hwnd)); - if (appWindow is not null) + try { - appWindow.SetPresenter(AppWindowPresenterKind.Overlapped); - if (appWindow.Presenter is OverlappedPresenter op) + var appWindow = AppWindow.GetFromWindowId(Win32Interop.GetWindowIdFromWindow(_hwnd)); + App.Log($"appWindow null? {appWindow is null}"); + if (appWindow is not null) { - op.IsAlwaysOnTop = true; - op.IsResizable = true; - op.IsMaximizable = false; - op.IsMinimizable = true; - op.SetBorderAndTitleBar(hasBorder: false, hasTitleBar: false); + appWindow.SetPresenter(AppWindowPresenterKind.Overlapped); + App.Log($"presenter kind: {appWindow.Presenter?.Kind}"); + if (appWindow.Presenter is OverlappedPresenter op) + { + op.IsAlwaysOnTop = true; + op.IsResizable = true; + op.IsMaximizable = false; + op.IsMinimizable = true; + op.SetBorderAndTitleBar(hasBorder: false, hasTitleBar: false); + App.Log("OverlappedPresenter configured"); + } + appWindow.ResizeClient(new SizeInt32((int)DefaultLogicalWidth, (int)DefaultLogicalHeight)); + App.Log("ResizeClient ok"); } - appWindow.ResizeClient(new SizeInt32((int)DefaultLogicalWidth, (int)DefaultLogicalHeight)); } + catch (Exception ex) { App.Log($"appWindow setup FAILED: {ex}"); throw; } - SystemBackdrop = new MicaBackdrop { Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.Base }; + try + { + SystemBackdrop = new MicaBackdrop { Kind = Microsoft.UI.Composition.SystemBackdrops.MicaKind.Base }; + App.Log("SystemBackdrop assigned"); + } + catch (Exception ex) { App.Log($"SystemBackdrop FAILED: {ex}"); throw; } Activated += OnActivated; Closed += OnClosed; + App.Log("events wired"); DispatcherQueue.TryEnqueue(() => {