| | |
| | | } |
| | | |
| | | public void MoveToDesktopLayer(IntPtr hwnd, DesktopLayerMode mode, MonitorInfo monitor) |
| | | => MoveToDesktopLayer(hwnd, mode, monitor.Bounds); |
| | | |
| | | public void MoveToDesktopLayer(IntPtr hwnd, DesktopLayerMode mode, RectD bounds) |
| | | { |
| | | var candidates = mode == DesktopLayerMode.WorkerW |
| | | ? _strategies.OrderBy(strategy => strategy is WorkerWDesktopLayerStrategy ? 0 : 1) |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (strategy.TryAttachWallpaperWindow(hwnd, monitor, out var error)) |
| | | if (strategy.TryAttachDesktopWindow(hwnd, bounds, out var error)) |
| | | { |
| | | return; |
| | | } |
| | |
| | | ["strategy"] = strategy.Name, |
| | | ["reason"] = error ?? "Unknown" |
| | | }); |
| | | } |
| | | } |
| | | |
| | | public void RestoreTopLevelWindow(IntPtr hwnd) |
| | | { |
| | | RestoreTopLevelStyle(hwnd); |
| | | NativeMethods.SetParent(hwnd, IntPtr.Zero); |
| | | var error = NativeMethods.GetLastError(); |
| | | if (error != 0) |
| | | { |
| | | _diagnostics.Record( |
| | | DiagnosticSeverity.Warning, |
| | | DiagnosticCodes.Win32InteropFailed, |
| | | "RestoreTopLevelWindow failed.", |
| | | new Dictionary<string, string> { ["hwnd"] = hwnd.ToString("X"), ["error"] = error.ToString() }); |
| | | } |
| | | |
| | | if (!NativeMethods.SetWindowPos( |
| | | hwnd, |
| | | IntPtr.Zero, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | 0, |
| | | NativeMethods.SwpNoMove | NativeMethods.SwpNoSize | NativeMethods.SwpNoZOrder | NativeMethods.SwpNoActivate | NativeMethods.SwpFrameChanged)) |
| | | { |
| | | RecordWin32Failure("RestoreTopLevelWindow.SetWindowPos", hwnd); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | return new RectD(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top); |
| | | } |
| | | |
| | | private static void RestoreTopLevelStyle(IntPtr hwnd) |
| | | { |
| | | var current = unchecked((uint)NativeMethods.GetWindowLongPtr(hwnd, NativeMethods.GwlStyle).ToInt64()); |
| | | var updated = (current | NativeMethods.WsPopup | NativeMethods.WsVisible) & ~NativeMethods.WsChild; |
| | | NativeMethods.SetWindowLongPtr(hwnd, NativeMethods.GwlStyle, new IntPtr(unchecked((int)updated))); |
| | | } |
| | | } |