From 7f63b5db980f2f73301bb47211f806574c0426de Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Fri, 2 Nov 2001 20:48:15 +0000 Subject: [PATCH] Patch from HideToshi Tajima (#51922) Fri Nov 2 15:30:34 2001 Owen Taylor Patch from HideToshi Tajima (#51922) * gtk/gtkimmulticontext.c: Proxy set_use_preedit(). * gtk/modules/input/gtkimcontextxim.[ch]: Implement set_use_preedit(). * gtk/modules/input/gtkimcontextxim.[ch]: If we have to destroy the input context because we change the client window or use_preedit, make sure we empty the preedit string. --- ChangeLog | 14 +++++++++ ChangeLog.pre-2-0 | 14 +++++++++ ChangeLog.pre-2-10 | 14 +++++++++ ChangeLog.pre-2-2 | 14 +++++++++ ChangeLog.pre-2-4 | 14 +++++++++ ChangeLog.pre-2-6 | 14 +++++++++ ChangeLog.pre-2-8 | 14 +++++++++ gtk/gtkimmulticontext.c | 14 +++++++++ modules/input/gtkimcontextxim.c | 53 +++++++++++++++++++++++++++++---- modules/input/gtkimcontextxim.h | 2 ++ 10 files changed, 161 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index b04af65e89..13917d55dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Fri Nov 2 15:30:34 2001 Owen Taylor + + Patch from HideToshi Tajima (#51922) + + * gtk/gtkimmulticontext.c: Proxy set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: Implement + set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: If we have + to destroy the input context because we change the + client window or use_preedit, make sure we empty + the preedit string. + Fri Nov 2 14:55:53 2001 Owen Taylor * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index b04af65e89..13917d55dc 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,17 @@ +Fri Nov 2 15:30:34 2001 Owen Taylor + + Patch from HideToshi Tajima (#51922) + + * gtk/gtkimmulticontext.c: Proxy set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: Implement + set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: If we have + to destroy the input context because we change the + client window or use_preedit, make sure we empty + the preedit string. + Fri Nov 2 14:55:53 2001 Owen Taylor * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index b04af65e89..13917d55dc 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +Fri Nov 2 15:30:34 2001 Owen Taylor + + Patch from HideToshi Tajima (#51922) + + * gtk/gtkimmulticontext.c: Proxy set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: Implement + set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: If we have + to destroy the input context because we change the + client window or use_preedit, make sure we empty + the preedit string. + Fri Nov 2 14:55:53 2001 Owen Taylor * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index b04af65e89..13917d55dc 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,17 @@ +Fri Nov 2 15:30:34 2001 Owen Taylor + + Patch from HideToshi Tajima (#51922) + + * gtk/gtkimmulticontext.c: Proxy set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: Implement + set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: If we have + to destroy the input context because we change the + client window or use_preedit, make sure we empty + the preedit string. + Fri Nov 2 14:55:53 2001 Owen Taylor * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index b04af65e89..13917d55dc 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,17 @@ +Fri Nov 2 15:30:34 2001 Owen Taylor + + Patch from HideToshi Tajima (#51922) + + * gtk/gtkimmulticontext.c: Proxy set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: Implement + set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: If we have + to destroy the input context because we change the + client window or use_preedit, make sure we empty + the preedit string. + Fri Nov 2 14:55:53 2001 Owen Taylor * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index b04af65e89..13917d55dc 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,17 @@ +Fri Nov 2 15:30:34 2001 Owen Taylor + + Patch from HideToshi Tajima (#51922) + + * gtk/gtkimmulticontext.c: Proxy set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: Implement + set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: If we have + to destroy the input context because we change the + client window or use_preedit, make sure we empty + the preedit string. + Fri Nov 2 14:55:53 2001 Owen Taylor * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index b04af65e89..13917d55dc 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +Fri Nov 2 15:30:34 2001 Owen Taylor + + Patch from HideToshi Tajima (#51922) + + * gtk/gtkimmulticontext.c: Proxy set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: Implement + set_use_preedit(). + + * gtk/modules/input/gtkimcontextxim.[ch]: If we have + to destroy the input context because we change the + client window or use_preedit, make sure we empty + the preedit string. + Fri Nov 2 14:55:53 2001 Owen Taylor * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c, diff --git a/gtk/gtkimmulticontext.c b/gtk/gtkimmulticontext.c index 4d4cce66ba..ea51bab2d1 100644 --- a/gtk/gtkimmulticontext.c +++ b/gtk/gtkimmulticontext.c @@ -45,6 +45,8 @@ static void gtk_im_multicontext_focus_out (GtkIMContext static void gtk_im_multicontext_reset (GtkIMContext *context); static void gtk_im_multicontext_set_cursor_location (GtkIMContext *context, GdkRectangle *area); +static void gtk_im_multicontext_set_use_preedit (GtkIMContext *context, + gboolean use_preedit); static gboolean gtk_im_multicontext_get_surrounding (GtkIMContext *context, gchar **text, gint *cursor_index); @@ -115,6 +117,7 @@ gtk_im_multicontext_class_init (GtkIMMulticontextClass *class) im_context_class->focus_out = gtk_im_multicontext_focus_out; im_context_class->reset = gtk_im_multicontext_reset; im_context_class->set_cursor_location = gtk_im_multicontext_set_cursor_location; + im_context_class->set_use_preedit = gtk_im_multicontext_set_use_preedit; im_context_class->set_surrounding = gtk_im_multicontext_set_surrounding; im_context_class->get_surrounding = gtk_im_multicontext_get_surrounding; @@ -321,6 +324,17 @@ gtk_im_multicontext_set_cursor_location (GtkIMContext *context, gtk_im_context_set_cursor_location (slave, area); } +static void +gtk_im_multicontext_set_use_preedit (GtkIMContext *context, + gboolean use_preedit) +{ + GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context); + GtkIMContext *slave = gtk_im_multicontext_get_slave (multicontext); + + if (slave) + gtk_im_context_set_use_preedit (slave, use_preedit); +} + static gboolean gtk_im_multicontext_get_surrounding (GtkIMContext *context, gchar **text, diff --git a/modules/input/gtkimcontextxim.c b/modules/input/gtkimcontextxim.c index 1285103d40..2f5faeb3b1 100644 --- a/modules/input/gtkimcontextxim.c +++ b/modules/input/gtkimcontextxim.c @@ -42,6 +42,8 @@ static void gtk_im_context_xim_focus_in (GtkIMContext *co static void gtk_im_context_xim_focus_out (GtkIMContext *context); static void gtk_im_context_xim_set_cursor_location (GtkIMContext *context, GdkRectangle *area); +static void gtk_im_context_xim_set_use_preedit (GtkIMContext *context, + gboolean use_preedit); static void gtk_im_context_xim_get_preedit_string (GtkIMContext *context, gchar **str, PangoAttrList **attrs, @@ -216,12 +218,14 @@ gtk_im_context_xim_class_init (GtkIMContextXIMClass *class) im_context_class->focus_in = gtk_im_context_xim_focus_in; im_context_class->focus_out = gtk_im_context_xim_focus_out; im_context_class->set_cursor_location = gtk_im_context_xim_set_cursor_location; + im_context_class->set_use_preedit = gtk_im_context_xim_set_use_preedit; gobject_class->finalize = gtk_im_context_xim_finalize; } static void gtk_im_context_xim_init (GtkIMContextXIM *im_context_xim) { + im_context_xim->use_preedit = TRUE; } static void @@ -238,18 +242,29 @@ gtk_im_context_xim_finalize (GObject *obj) g_free (context_xim->mb_charset); } +static void +reinitialize_ic (GtkIMContextXIM *context_xim) +{ + if (context_xim->ic) + { + XDestroyIC (context_xim->ic); + context_xim->ic = NULL; + + if (context_xim->preedit_length) + { + context_xim->preedit_length = 0; + g_signal_emit_by_name (context_xim, "preedit_changed"); + } + } +} + static void gtk_im_context_xim_set_client_window (GtkIMContext *context, GdkWindow *client_window) { GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context); - if (context_xim->ic) - { - XDestroyIC (context_xim->ic); - context_xim->ic = NULL; - } - + reinitialize_ic (context_xim); context_xim->client_window = client_window; } @@ -425,6 +440,23 @@ gtk_im_context_xim_set_cursor_location (GtkIMContext *context, return; } +static void +gtk_im_context_xim_set_use_preedit (GtkIMContext *context, + gboolean use_preedit) +{ + GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context); + + use_preedit = use_preedit != FALSE; + + if (context_xim->use_preedit != use_preedit) + { + context_xim->use_preedit = use_preedit; + reinitialize_ic (context_xim); + } + + return; +} + static void gtk_im_context_xim_reset (GtkIMContext *context) { @@ -784,6 +816,15 @@ gtk_im_context_xim_get_ic (GtkIMContextXIM *context_xim) if (!context_xim->ic && context_xim->client_window) { + if (!context_xim->use_preedit) + { + context_xim->ic = XCreateIC (context_xim->im_info->im, + XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, GDK_DRAWABLE_XID (context_xim->client_window), + NULL); + return context_xim->ic; + } + if ((context_xim->im_info->style & PREEDIT_MASK) == XIMPreeditCallbacks) { context_xim->preedit_start_callback.client_data = (XPointer)context_xim; diff --git a/modules/input/gtkimcontextxim.h b/modules/input/gtkimcontextxim.h index 7d276acd67..96d1df5eed 100644 --- a/modules/input/gtkimcontextxim.h +++ b/modules/input/gtkimcontextxim.h @@ -70,6 +70,8 @@ struct _GtkIMContextXIM XIMCallback status_draw_callback; XIC ic; + + guint use_preedit : 1; }; struct _GtkIMContextXIMClass