From c01509ccc4e4b24be0575f8577921ea5031a75c5 Mon Sep 17 00:00:00 2001
From: Noomen Hamza <noomen@macadamian.com>
Date: Sun, 4 Jul 1999 15:54:11 +0000
Subject: [PATCH] Windows should be activated in these cases: 1- when we click
 on non active window. 2- when we cancel a moving or resizing of a non active
 window.

---
 windows/nonclient.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/windows/nonclient.c b/windows/nonclient.c
index 8d47dc638c3..0ba158fbe3c 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -2220,13 +2220,34 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam )
     SendMessage16( hwnd, WM_EXITSIZEMOVE, 0, 0 );
     SendMessage16( hwnd, WM_SETVISIBLE, !IsIconic16(hwnd), 0L);
 
-    if( moved && !((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
+    /* window moved or resized */
+    if (moved)
     {
+        /* if the moving/resizing isn't canceled call SetWindowPos
+         * with the new position or the new size of the window
+         */
+        if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
+        {
 	/* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
 	SetWindowPos( hwnd, 0, sizingRect.left, sizingRect.top,
 			sizingRect.right - sizingRect.left,
 			sizingRect.bottom - sizingRect.top,
 		      ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
+        }
+        else
+        {
+            /* if the moving/resizing is canceled and the window is not active
+             * call SetWindowPos to activate and to show this window
+             */
+            if (GetActiveWindow() != hwnd)
+                SetWindowPos( hwnd, 0, 0, 0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
+        }
+    }
+    else
+    {
+        /* show the window if it is not moved/resized and it is not active */
+        if (GetActiveWindow() != hwnd)
+            SetWindowPos( hwnd, 0, 0, 0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
     }
 
     if( IsWindow(hwnd) )
-- 
GitLab