Popup windows will be hidden when minimizing the main frame.

diff --git a/include/win.h b/include/win.h
index 65f4108..5e7d5dd 100644
--- a/include/win.h
+++ b/include/win.h
@@ -154,6 +154,7 @@
 #define WIN_MANAGED            0x0100 /* Window managed by the window system */
 #define WIN_ISDIALOG           0x0200 /* Window is a dialog */
 #define WIN_ISWIN32            0x0400 /* Understands Win32 messages */
+#define WIN_NEEDS_SHOW_OWNEDPOPUP 0x0800 /* WM_SHOWWINDOW:SC_SHOW must be sent in the next ShowOwnedPopup call */
 
   /* BuildWinArray() flags */
 #define BWA_SKIPDISABLED	0x0001
diff --git a/windows/win.c b/windows/win.c
index 938b48c..ece99d9 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -2668,7 +2668,24 @@
     for (; count < totalChild; count++)
     {
         if (pWnd[count]->owner && (pWnd[count]->owner->hwndSelf == owner) && (pWnd[count]->dwStyle & WS_POPUP))
-            SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, fShow ? SW_SHOW : SW_HIDE,IsIconic(owner) ? SW_PARENTOPENING : SW_PARENTCLOSING);
+        {
+            if (fShow)
+            {
+                if (pWnd[count]->flags & WIN_NEEDS_SHOW_OWNEDPOPUP)
+                {
+                    SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_SHOW, IsIconic(owner) ? SW_PARENTOPENING : SW_PARENTCLOSING);
+                    pWnd[count]->flags &= ~WIN_NEEDS_SHOW_OWNEDPOPUP;
+                }
+            }
+            else
+            {
+                if (IsWindowVisible(pWnd[count]->hwndSelf))
+                {
+                    SendMessageA(pWnd[count]->hwndSelf, WM_SHOWWINDOW, SW_HIDE, IsIconic(owner) ? SW_PARENTOPENING : SW_PARENTCLOSING);
+                    pWnd[count]->flags |= WIN_NEEDS_SHOW_OWNEDPOPUP;
+                }
+            }
+        }
     }
 
     WIN_ReleaseDesktop();