From 4740b9185f04cabe0c2f34f0455a4bc455e039ae Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Mon, 10 Jun 2019 21:29:07 +0300 Subject: [PATCH] 149: Stored Client Layout doesn't persist information about maximized EVE client windows --- .../Configuration/Interface/ClientLayout.cs | 7 ++++++- Eve-O-Preview/Eve-O-Preview.csproj | 2 +- .../Services/Implementation/ThumbnailManager.cs | 16 ++++++++++++---- .../Services/Implementation/WindowManager.cs | 12 +++++++++++- .../Services/Interface/IWindowManager.cs | 5 ++--- .../Services/Interface/InteropConstants.cs | 3 ++- 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Eve-O-Preview/Configuration/Interface/ClientLayout.cs b/Eve-O-Preview/Configuration/Interface/ClientLayout.cs index 02266c4..c158401 100644 --- a/Eve-O-Preview/Configuration/Interface/ClientLayout.cs +++ b/Eve-O-Preview/Configuration/Interface/ClientLayout.cs @@ -6,18 +6,23 @@ namespace EveOPreview.Configuration { } - public ClientLayout(int x, int y, int width, int height) + public ClientLayout(int x, int y, int width, int height, bool maximized) { this.X = x; this.Y = y; this.Width = width; this.Height = height; + this.IsMaximized = maximized; } public int X { get; set; } + public int Y { get; set; } public int Width { get; set; } + public int Height { get; set; } + + public bool IsMaximized { get; set; } } } \ No newline at end of file diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index 5e9d4aa..375b7a6 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -10,7 +10,7 @@ WinExe Properties EveOPreview - Eve-O Preview + EVE-O Preview v4.7 diff --git a/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs b/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs index 9f55ac2..ea0904f 100644 --- a/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs +++ b/Eve-O-Preview/Services/Implementation/ThumbnailManager.cs @@ -590,7 +590,14 @@ namespace EveOPreview.Services return; } - this._windowManager.MoveWindow(clientHandle, clientLayout.X, clientLayout.Y, clientLayout.Width, clientLayout.Height); + if (clientLayout.IsMaximized) + { + this._windowManager.MaximizeWindow(clientHandle); + } + else + { + this._windowManager.MoveWindow(clientHandle, clientLayout.X, clientLayout.Y, clientLayout.Width, clientLayout.Height); + } } private void UpdateClientLayouts() @@ -604,16 +611,17 @@ namespace EveOPreview.Services { IThumbnailView view = entry.Value; (int Left, int Top, int Right, int Bottom) position = this._windowManager.GetWindowPosition(view.Id); - int width = Math.Abs(position.Right - position.Left); int height = Math.Abs(position.Bottom - position.Top); - if (!this.IsValidWindowPosition(position.Left, position.Top, width, height)) + var isMaximized = this._windowManager.IsWindowMaximized(view.Id); + + if (!(isMaximized || this.IsValidWindowPosition(position.Left, position.Top, width, height))) { continue; } - this._configuration.SetClientLayout(view.Title, new ClientLayout(position.Left, position.Top, width, height)); + this._configuration.SetClientLayout(view.Title, new ClientLayout(position.Left, position.Top, width, height, isMaximized)); } } diff --git a/Eve-O-Preview/Services/Implementation/WindowManager.cs b/Eve-O-Preview/Services/Implementation/WindowManager.cs index b7e7135..c1b8d88 100644 --- a/Eve-O-Preview/Services/Implementation/WindowManager.cs +++ b/Eve-O-Preview/Services/Implementation/WindowManager.cs @@ -31,7 +31,7 @@ namespace EveOPreview.Services.Implementation if ((style & InteropConstants.WS_MINIMIZE) == InteropConstants.WS_MINIMIZE) { - User32NativeMethods.ShowWindowAsync(handle, InteropConstants.SW_SHOWNORMAL); + User32NativeMethods.ShowWindowAsync(handle, InteropConstants.SW_RESTORE); } } @@ -56,6 +56,11 @@ namespace EveOPreview.Services.Implementation User32NativeMethods.MoveWindow(handle, left, top, width, height, true); } + public void MaximizeWindow(IntPtr handle) + { + User32NativeMethods.ShowWindowAsync(handle, InteropConstants.SW_SHOWMAXIMIZED); + } + public (int Left, int Top, int Right, int Bottom) GetWindowPosition(IntPtr handle) { User32NativeMethods.GetWindowRect(handle, out RECT windowRectangle); @@ -63,6 +68,11 @@ namespace EveOPreview.Services.Implementation return (windowRectangle.Left, windowRectangle.Top, windowRectangle.Right, windowRectangle.Bottom); } + public bool IsWindowMaximized(IntPtr handle) + { + return User32NativeMethods.IsZoomed(handle); + } + public bool IsWindowMinimized(IntPtr handle) { return User32NativeMethods.IsIconic(handle); diff --git a/Eve-O-Preview/Services/Interface/IWindowManager.cs b/Eve-O-Preview/Services/Interface/IWindowManager.cs index 50a01b6..c1ce08d 100644 --- a/Eve-O-Preview/Services/Interface/IWindowManager.cs +++ b/Eve-O-Preview/Services/Interface/IWindowManager.cs @@ -8,14 +8,13 @@ namespace EveOPreview.Services bool IsCompositionEnabled { get; } IntPtr GetForegroundWindowHandle(); - void ActivateWindow(IntPtr handle); void MinimizeWindow(IntPtr handle, bool enableAnimation); - void MoveWindow(IntPtr handle, int left, int top, int width, int height); + void MaximizeWindow(IntPtr handle); (int Left, int Top, int Right, int Bottom) GetWindowPosition(IntPtr handle); + bool IsWindowMaximized(IntPtr handle); bool IsWindowMinimized(IntPtr handle); - IDwmThumbnail GetLiveThumbnail(IntPtr destination, IntPtr source); Image GetStaticThumbnail(IntPtr source); } diff --git a/Eve-O-Preview/Services/Interface/InteropConstants.cs b/Eve-O-Preview/Services/Interface/InteropConstants.cs index e6df312..5fdd320 100644 --- a/Eve-O-Preview/Services/Interface/InteropConstants.cs +++ b/Eve-O-Preview/Services/Interface/InteropConstants.cs @@ -56,7 +56,7 @@ namespace EveOPreview.Services public const UInt32 WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE); public const UInt32 WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST); public const UInt32 WS_EX_LAYERED = 0x00080000; - public const UInt32 WS_EX_NOINHERITLAYOUT = 0x00100000; // Disable inheritence of mirroring by children + public const UInt32 WS_EX_NOINHERITLAYOUT = 0x00100000; // Disable inheritance of mirroring by children public const UInt32 WS_EX_LAYOUTRTL = 0x00400000; // Right to left mirroring public const UInt32 WS_EX_COMPOSITED = 0x02000000; public const UInt32 WS_EX_NOACTIVATE = 0x08000000; @@ -78,5 +78,6 @@ namespace EveOPreview.Services public const int SW_SHOWNORMAL = 1; public const int SW_SHOWMINIMIZED = 2; public const int SW_SHOWMAXIMIZED = 3; + public const int SW_RESTORE = 9; } } \ No newline at end of file