From 3dd2f47626b20155cdf1974f39f4d641a56c93f3 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 6 Apr 2016 15:14:25 +0800
Subject: user32: Before asking a WM to activate a window make sure that the
 window is in foreground and not minimized.

This patch fixes iconify action using WM's taskbar buttons for Winamp.
---
 dlls/user32/focus.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/focus.c b/dlls/user32/focus.c
index 3746950..2ab599a 100644
--- a/dlls/user32/focus.c
+++ b/dlls/user32/focus.c
@@ -156,9 +156,10 @@ static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus )
                       (LPARAM)previous );
         if (GetAncestor( hwnd, GA_PARENT ) == GetDesktopWindow())
             PostMessageW( GetDesktopWindow(), WM_PARENTNOTIFY, WM_NCACTIVATE, (LPARAM)hwnd );
-    }
 
-    USER_Driver->pSetActiveWindow( hwnd );
+        if (hwnd == GetForegroundWindow() && !IsIconic( hwnd ))
+            USER_Driver->pSetActiveWindow( hwnd );
+    }
 
     /* now change focus if necessary */
     if (focus)
-- 
2.8.0

