+2002-02-22 Jason Rumney <jasonr@gnu.org>
+
+ * w32term.h (struct w32_output): New member menu_command_in_progress.
+
+ * w32menu.c (menubar_selection_callback): Free the menu and
+ clear the menu_command_in_progress flag.
+
+ * w32fns.c (mouse_move_timer, mouse_button_timer): Initialize.
+ (menu_free_timer): New variable.
+ (MENU_FREE_ID, MENU_FREE_DELAY): New constants.
+ (w32_wnd_proc) <WM_TIMER>: Handle menu_free_timer.
+ <WM_EXITMENULOOP>: Delay before freeing menu. Do nothing if a
+ menu command is in progress.
+ <WM_COMMAND>: Set the menu_command_in_progress flag. Kill
+ any menu_free_timer that is running.
+
+ * w32term.c (w32_text_out): Renamed from W32_TEXTOUT.
+ Call ExtTextOutA rather than ExtTextOut.
+
2002-02-22 Eli Zaretskii <eliz@gnu.org>
* puresize.h (BASE_PURESIZE): Increase to 755000.
static int button_state = 0;
static W32Msg saved_mouse_button_msg;
-static unsigned mouse_button_timer; /* non-zero when timer is active */
+static unsigned mouse_button_timer = 0; /* non-zero when timer is active */
static W32Msg saved_mouse_move_msg;
-static unsigned mouse_move_timer;
+static unsigned mouse_move_timer = 0;
/* Window that is tracking the mouse. */
static HWND track_mouse_window;
/* W95 mousewheel handler */
unsigned int msh_mousewheel = 0;
+/* Timers */
#define MOUSE_BUTTON_ID 1
#define MOUSE_MOVE_ID 2
+#define MENU_FREE_ID 3
+/* The delay (milliseconds) before a menu is freed after WM_EXITMENULOOP
+ is received. */
+#define MENU_FREE_DELAY 1000
+static unsigned menu_free_timer = 0;
/* The below are defined in frame.c. */
KillTimer (hwnd, mouse_move_timer);
mouse_move_timer = 0;
}
+ else if (wParam == menu_free_timer)
+ {
+ KillTimer (hwnd, menu_free_timer);
+ menu_free_timer = 0;
+ if (!f->output_data.w32->menu_command_in_progress)
+ {
+ /* Free memory used by owner-drawn and help-echo strings. */
+ w32_free_menu_strings (hwnd);
+ f->output_data.w32->menubar_active = 0;
+ }
+ }
return 0;
case WM_NCACTIVATE:
case WM_EXITMENULOOP:
f = x_window_to_frame (dpyinfo, hwnd);
- /* Free memory used by owner-drawn and help-echo strings. */
- w32_free_menu_strings (hwnd);
-
- /* Indicate that menubar can be modified again. */
- if (f)
- f->output_data.w32->menubar_active = 0;
+ /* 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)
+ menu_free_timer = SetTimer (hwnd, MENU_FREE_ID, MENU_FREE_DELAY, NULL);
goto dflt;
case WM_MENUSELECT:
w32_system_caret_hwnd = NULL;
DestroyCaret ();
}
+ goto command;
+ case WM_COMMAND:
+ 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);
+ menu_free_timer = 0;
+ }
+ }
case WM_MOVE:
case WM_SIZE:
- case WM_COMMAND:
command:
wmsg.dwModifiers = w32_get_modifiers ();
my_post_msg (&wmsg, hwnd, msg, wParam, lParam);