summaryrefslogtreecommitdiff
path: root/src/w32console.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32console.c')
-rw-r--r--src/w32console.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/w32console.c b/src/w32console.c
index c2b87928cc1..7dcbc795cac 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -659,6 +659,24 @@ w32_face_attributes (struct frame *f, int face_id)
return char_attr;
}
+/* The IME window is needed to receive the session notifications
+ required to reset the low level keyboard hook state. */
+
+static BOOL CALLBACK
+find_ime_window (HWND hwnd, LPARAM arg)
+{
+ char window_class[32];
+
+ GetClassName (hwnd, window_class, sizeof (window_class));
+ if (strcmp (window_class, "IME") == 0)
+ {
+ *(HWND *) arg = hwnd;
+ return FALSE;
+ }
+ /* keep looking */
+ return TRUE;
+}
+
void
initialize_w32_display (struct terminal *term, int *width, int *height)
{
@@ -705,6 +723,10 @@ initialize_w32_display (struct terminal *term, int *width, int *height)
/* Remember original console settings. */
keyboard_handle = GetStdHandle (STD_INPUT_HANDLE);
GetConsoleMode (keyboard_handle, &prev_console_mode);
+ /* Make sure ENABLE_EXTENDED_FLAGS is set in console settings,
+ otherwise restoring the original setting of ENABLE_MOUSE_INPUT
+ will not work. */
+ prev_console_mode |= ENABLE_EXTENDED_FLAGS;
prev_screen = GetStdHandle (STD_OUTPUT_HANDLE);
@@ -814,11 +836,14 @@ initialize_w32_display (struct terminal *term, int *width, int *height)
else
w32_console_unicode_input = 0;
- /* Setup w32_display_info structure for this frame. */
+ /* Setup w32_display_info structure for this frame. */
w32_initialize_display_info (build_string ("Console"));
+ HWND hwnd = NULL;
+ EnumThreadWindows (GetCurrentThreadId (), find_ime_window, (LPARAM) &hwnd);
+
/* Set up the keyboard hook. */
- setup_w32_kbdhook ();
+ setup_w32_kbdhook (hwnd);
}