From e5b8023190bc48e9317e0f8a1bfac3bcd72d6701 Mon Sep 17 00:00:00 2001 From: Anton Kasyanov Date: Sun, 5 Jun 2016 14:38:35 +0300 Subject: [PATCH] 'Hide Preview if active window is not EVE client' makes thumbnail blink after switching to a EVE client --- .../Presentation/ThumbnailManager.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Eve-O-Preview/Presentation/ThumbnailManager.cs b/Eve-O-Preview/Presentation/ThumbnailManager.cs index b6f414a..e50c672 100644 --- a/Eve-O-Preview/Presentation/ThumbnailManager.cs +++ b/Eve-O-Preview/Presentation/ThumbnailManager.cs @@ -96,7 +96,7 @@ namespace EveOPreview.UI public void RefreshThumbnails() { IntPtr foregroundWindowHandle = DwmApiNativeMethods.GetForegroundWindow(); - Boolean hideAllThumbnails = (this._configuration.HideThumbnailsOnLostFocus && !this.IsClientWindowActive(foregroundWindowHandle)) || !DwmApiNativeMethods.DwmIsCompositionEnabled(); + Boolean hideAllThumbnails = (this._configuration.HideThumbnailsOnLostFocus && this.IsNonClientWindowActive(foregroundWindowHandle)) || !DwmApiNativeMethods.DwmIsCompositionEnabled(); this.DisableViewEvents(); @@ -354,17 +354,25 @@ namespace EveOPreview.UI view.Refresh(); } - private bool IsClientWindowActive(IntPtr windowHandle) + private bool IsNonClientWindowActive(IntPtr windowHandle) { - foreach (KeyValuePair entry in _thumbnailViews) + // We just don't know ATM + if (windowHandle == IntPtr.Zero) { - if (entry.Value.IsKnownHandle(windowHandle)) + return false; + } + + foreach (KeyValuePair entry in this._thumbnailViews) + { + IThumbnailView view = entry.Value; + + if (view.IsKnownHandle(windowHandle)) { - return true; + return false; } } - return false; + return true; } private void ThumbnailZoomIn(IThumbnailView view)