[gtk/wip/exalm/textview-selection: 2/4] textview: Invalidate selection when its style changes
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/exalm/textview-selection: 2/4] textview: Invalidate selection when its style changes
- Date: Mon, 3 May 2021 19:33:14 +0000 (UTC)
commit 0fa4b7a24973b275839a2e1585438c3d588c4601
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon May 3 21:40:37 2021 +0500
textview: Invalidate selection when its style changes
gtk/gtktextlayout.c | 14 ++++++++++++++
gtk/gtktextlayoutprivate.h | 1 +
gtk/gtktextview.c | 3 +++
3 files changed, 18 insertions(+)
---
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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]