Bug 668239 - texts disappear when notebook switch page at zh_CN locate

In gtkimcontextime.c, use gdk_win32_window_get_impl_hwnd() to get to
the impl's existing native window instead of GDK_WINDOW_HWND() which
implicitly ensures a native window for the widget itself. This seems
to work around whatever GDK problem with native subwindows and fixes
the bug.

This is based on Michael Natterer's fix for gtk-2-24.
This commit is contained in:
Chun-wei Fan 2012-11-26 12:57:05 +08:00
parent 0cb714fe62
commit 656ec39c29

View File

@ -279,7 +279,7 @@ gtk_im_context_ime_set_client_window (GtkIMContext *context,
HIMC himc; HIMC himc;
HWND hwnd; HWND hwnd;
hwnd = GDK_WINDOW_HWND (client_window); hwnd = gdk_win32_window_get_impl_hwnd (client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (himc) if (himc)
{ {
@ -349,7 +349,7 @@ gtk_im_context_ime_reset (GtkIMContext *context)
if (!context_ime->client_window) if (!context_ime->client_window)
return; return;
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc) if (!himc)
return; return;
@ -380,7 +380,7 @@ get_utf8_preedit_string (GtkIMContextIME *context_ime, gint *pos_ret)
if (!context_ime->client_window) if (!context_ime->client_window)
return g_strdup (""); return g_strdup ("");
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc) if (!himc)
return g_strdup (""); return g_strdup ("");
@ -441,7 +441,7 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str)
if (!context_ime->client_window) if (!context_ime->client_window)
return attrs; return attrs;
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc) if (!himc)
return attrs; return attrs;
@ -579,7 +579,7 @@ gtk_im_context_ime_focus_in (GtkIMContext *context)
/* swtich current context */ /* swtich current context */
context_ime->focus = TRUE; context_ime->focus = TRUE;
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc) if (!himc)
return; return;
@ -589,7 +589,7 @@ gtk_im_context_ime_focus_in (GtkIMContext *context)
{ {
gdk_window_add_filter (toplevel, gdk_window_add_filter (toplevel,
gtk_im_context_ime_message_filter, context_ime); gtk_im_context_ime_message_filter, context_ime);
top_hwnd = GDK_WINDOW_HWND (toplevel); top_hwnd = gdk_win32_window_get_impl_hwnd (toplevel);
context_ime->toplevel = toplevel; context_ime->toplevel = toplevel;
} }
@ -652,7 +652,7 @@ gtk_im_context_ime_focus_out (GtkIMContext *context)
/* swtich current context */ /* swtich current context */
context_ime->focus = FALSE; context_ime->focus = FALSE;
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc) if (!himc)
return; return;
@ -714,7 +714,7 @@ gtk_im_context_ime_focus_out (GtkIMContext *context)
gdk_window_remove_filter (toplevel, gdk_window_remove_filter (toplevel,
gtk_im_context_ime_message_filter, gtk_im_context_ime_message_filter,
context_ime); context_ime);
top_hwnd = GDK_WINDOW_HWND (toplevel); top_hwnd = gdk_win32_window_get_impl_hwnd (toplevel);
context_ime->toplevel = NULL; context_ime->toplevel = NULL;
} }
@ -748,7 +748,7 @@ gtk_im_context_ime_set_cursor_location (GtkIMContext *context,
if (!context_ime->client_window) if (!context_ime->client_window)
return; return;
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc) if (!himc)
return; return;
@ -778,7 +778,7 @@ gtk_im_context_ime_set_use_preedit (GtkIMContext *context,
HWND hwnd; HWND hwnd;
HIMC himc; HIMC himc;
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc) if (!himc)
return; return;
@ -814,7 +814,7 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
if (!GTK_IS_WIDGET (widget)) if (!GTK_IS_WIDGET (widget))
return; return;
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc) if (!himc)
return; return;
@ -921,7 +921,7 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
if (!context_ime->focus) if (!context_ime->focus)
return retval; return retval;
hwnd = GDK_WINDOW_HWND (context_ime->client_window); hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
himc = ImmGetContext (hwnd); himc = ImmGetContext (hwnd);
if (!himc) if (!himc)
return retval; return retval;
@ -941,8 +941,8 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
RECT rc; RECT rc;
hwnd_top = hwnd_top =
GDK_WINDOW_HWND (gdk_window_get_toplevel gdk_win32_window_get_impl_hwnd (gdk_window_get_toplevel
(context_ime->client_window)); (context_ime->client_window));
GetWindowRect (hwnd_top, &rc); GetWindowRect (hwnd_top, &rc);
pt.x = wx; pt.x = wx;
pt.y = wy; pt.y = wy;