[gtk/unmapped-text: 1/2] text: Defer most recomputation until we're mapped
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/unmapped-text: 1/2] text: Defer most recomputation until we're mapped
- Date: Sun, 23 Aug 2020 19:14:58 +0000 (UTC)
commit 91dcc7a6f4a61196662cabdd9236444ac09adc22
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Aug 23 15:09:45 2020 -0400
text: Defer most recomputation until we're mapped
It doesn't make sense to update scroll positions or
im cursor locations while we're unmapped, and doing
so causes us to do expensive text measuring.
gtk/gtktext.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 7d7d3e37ab..c4300e9481 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -309,6 +309,7 @@ static void gtk_text_dispose (GObject *object);
*/
static void gtk_text_realize (GtkWidget *widget);
static void gtk_text_unrealize (GtkWidget *widget);
+static void gtk_text_map (GtkWidget *widget);
static void gtk_text_unmap (GtkWidget *widget);
static void gtk_text_measure (GtkWidget *widget,
GtkOrientation orientation,
@@ -710,6 +711,7 @@ gtk_text_class_init (GtkTextClass *class)
gobject_class->set_property = gtk_text_set_property;
gobject_class->get_property = gtk_text_get_property;
+ widget_class->map = gtk_text_map;
widget_class->unmap = gtk_text_unmap;
widget_class->realize = gtk_text_realize;
widget_class->unrealize = gtk_text_unrealize;
@@ -2131,6 +2133,16 @@ gtk_text_get_display_text (GtkText *self,
}
}
+static void
+gtk_text_map (GtkWidget *widget)
+{
+ GtkText *self = GTK_TEXT (widget);
+
+ GTK_WIDGET_CLASS (gtk_text_parent_class)->map (widget);
+
+ gtk_text_recompute (self);
+}
+
static void
gtk_text_unmap (GtkWidget *widget)
{
@@ -3284,8 +3296,6 @@ static void
gtk_text_root (GtkWidget *widget)
{
GTK_WIDGET_CLASS (gtk_text_parent_class)->root (widget);
-
- gtk_text_recompute (GTK_TEXT (widget));
}
/* GtkEditable method implementations
@@ -4329,15 +4339,15 @@ static void
gtk_text_recompute (GtkText *self)
{
gtk_text_reset_layout (self);
- gtk_text_check_cursor_blink (self);
+ gtk_widget_queue_draw (GTK_WIDGET (self));
- gtk_text_adjust_scroll (self);
+ if (!gtk_widget_get_mapped (GTK_WIDGET (self)))
+ return;
+ gtk_text_check_cursor_blink (self);
+ gtk_text_adjust_scroll (self);
update_im_cursor_location (self);
-
gtk_text_update_handles (self);
-
- gtk_widget_queue_draw (GTK_WIDGET (self));
}
static PangoLayout *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]