diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-03-04 14:55:40 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-03-04 15:18:30 -0500 |
commit | d28df0b87e1422a0491970c1b0f9c9bcc5e7689c (patch) | |
tree | 764bd6f2b8b4065728ac50191a0e536038a77f07 | |
parent | d1fbfb9c4ed5ebf456f8bbcf16b6ba3a5e2e796a (diff) | |
download | gtk+-preedit-selection-fix.tar.gz |
textview: Delete selection when preedit startspreedit-selection-fix
This prevents confusing misrendering when the preedit text
pushes the selection text out of the rendered selection.
Fixes: #1123
-rw-r--r-- | gtk/gtktextview.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index c3289a0ce8..5b8bca680a 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -504,8 +504,10 @@ static void gtk_text_view_commit_handler (GtkIMContext *conte GtkTextView *text_view); static void gtk_text_view_commit_text (GtkTextView *text_view, const char *text); +static void gtk_text_view_preedit_start_handler (GtkIMContext *context, + GtkTextView *text_view); static void gtk_text_view_preedit_changed_handler (GtkIMContext *context, - GtkTextView *text_view); + GtkTextView *text_view); static gboolean gtk_text_view_retrieve_surrounding_handler (GtkIMContext *context, GtkTextView *text_view); static gboolean gtk_text_view_delete_surrounding_handler (GtkIMContext *context, @@ -1883,6 +1885,8 @@ gtk_text_view_init (GtkTextView *text_view) g_signal_connect (priv->im_context, "commit", G_CALLBACK (gtk_text_view_commit_handler), text_view); + g_signal_connect (priv->im_context, "preedit-start", + G_CALLBACK (gtk_text_view_preedit_start_handler), text_view); g_signal_connect (priv->im_context, "preedit-changed", G_CALLBACK (gtk_text_view_preedit_changed_handler), text_view); g_signal_connect (priv->im_context, "retrieve-surrounding", @@ -8213,6 +8217,13 @@ gtk_text_view_commit_text (GtkTextView *text_view, } static void +gtk_text_view_preedit_start_handler (GtkIMContext *context, + GtkTextView *self) +{ + gtk_text_buffer_delete_selection (self->priv->buffer, TRUE, self->priv->editable); +} + +static void gtk_text_view_preedit_changed_handler (GtkIMContext *context, GtkTextView *text_view) { |