diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index b31c70799e..85b99661d5 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -833,6 +833,20 @@ gtk_text_layout_invalidate_cursors (GtkTextLayout *layout, gtk_text_layout_invalidated (layout); } +void +gtk_text_layout_invalidate_selection (GtkTextLayout *layout) +{ + GtkTextIter selection_start, selection_end; + + g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout)); + + if (layout->buffer && + gtk_text_buffer_get_selection_bounds (layout->buffer, + &selection_start, + &selection_end)) + gtk_text_layout_invalidate (layout, &selection_start, &selection_end); +} + void gtk_text_layout_free_line_data (GtkTextLayout *layout, GtkTextLine *line, diff --git a/gtk/gtktextlayoutprivate.h b/gtk/gtktextlayoutprivate.h index 66676c7e7a..480d1ada62 100644 --- a/gtk/gtktextlayoutprivate.h +++ b/gtk/gtktextlayoutprivate.h @@ -287,6 +287,7 @@ void gtk_text_layout_invalidate (GtkTextLayout *layout, void gtk_text_layout_invalidate_cursors(GtkTextLayout *layout, const GtkTextIter *start, const GtkTextIter *end); +void gtk_text_layout_invalidate_selection (GtkTextLayout *layout); void gtk_text_layout_free_line_data (GtkTextLayout *layout, GtkTextLine *line, GtkTextLineData *line_data); diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 33c40d3555..2effe3eae2 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -5046,6 +5046,9 @@ gtk_text_view_state_flags_changed (GtkWidget *widget, gtk_css_node_set_state (priv->selection_node, state); + if (priv->layout) + gtk_text_layout_invalidate_selection (priv->layout); + gtk_widget_queue_draw (widget); }