changeset 76075:25965473846d

(current_popup_menu): Use from w32menu.c. (w32_wnd_proc): Use menubar_active and current_popup_menu to determine whether a menubar menu has been cancelled.
author Jason Rumney <jasonr@gnu.org>
date Thu, 22 Feb 2007 22:50:04 +0000
parents 5978a80d504e
children 59abcab48ea2
files src/w32fns.c
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32fns.c	Thu Feb 22 22:49:41 2007 +0000
+++ b/src/w32fns.c	Thu Feb 22 22:50:04 2007 +0000
@@ -297,6 +297,9 @@
 
 static HWND w32_visible_system_caret_hwnd;
 
+/* From w32menu.c  */
+extern HMENU current_popup_menu;
+
 
 /* Error if we are not connected to MS-Windows.  */
 void
@@ -3411,7 +3414,9 @@
 	  KillTimer (hwnd, menu_free_timer);
 	  menu_free_timer = 0;
 	  f = x_window_to_frame (dpyinfo, hwnd);
-	  if (!f->output_data.w32->menu_command_in_progress)
+          /* If a popup menu is active, don't wipe its strings.  */
+	  if (f->output_data.w32->menubar_active
+              && current_popup_menu == NULL)
 	    {
 	      /* Free memory used by owner-drawn and help-echo strings.  */
 	      w32_free_menu_strings (hwnd);
@@ -3473,10 +3478,13 @@
     case WM_EXITMENULOOP:
       f = x_window_to_frame (dpyinfo, hwnd);
 
-      /* If a menu command is not already in progress, check again
-	 after a short delay, since Windows often (always?) sends the
-	 WM_EXITMENULOOP before the corresponding WM_COMMAND message.  */
-      if (f && !f->output_data.w32->menu_command_in_progress)
+      /* If a menu is still active, check again after a short delay,
+	 since Windows often (always?) sends the WM_EXITMENULOOP
+	 before the corresponding WM_COMMAND message.
+         Don't do this if a popup menu is active, since it is only
+         menubar menus that require cleaning up in this way.
+      */
+      if (f && f->output_data.w32->menubar_active && current_popup_menu == NULL)
 	menu_free_timer = SetTimer (hwnd, MENU_FREE_ID, MENU_FREE_DELAY, NULL);
       goto dflt;
 
@@ -3634,7 +3642,6 @@
       f = x_window_to_frame (dpyinfo, hwnd);
       if (f && HIWORD (wParam) == 0)
 	{
-	  f->output_data.w32->menu_command_in_progress = 1;
 	  if (menu_free_timer)
 	    {
 	      KillTimer (hwnd, menu_free_timer);