[gnome-builder] source-view: be careful with spurious size-allocate emission
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] source-view: be careful with spurious size-allocate emission
- Date: Sun, 10 May 2015 00:38:05 +0000 (UTC)
commit ec5422a37125d15340c5fe4ad394e7d4190c4e75
Author: Christian Hergert <christian hergert me>
Date: Sat May 9 17:33:30 2015 -0700
source-view: be careful with spurious size-allocate emission
There will be a lot of these updates when the buffer is initially loading.
So just keep delaying a bit until we slow down on invalidation and can
actually land at our target location.
The amount of time this can take varies widely with whatever the idle
handler is doing. I've seen it be quick, and very slow.
Like always, going to require more hacks in gtktextview.c
libide/ide-source-view.c | 36 +++++++++++++++++++++++++++++++++---
1 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 36c88e8..a5a799f 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -61,11 +61,12 @@
#include "ide-symbol.h"
#define DEFAULT_FONT_DESC "Monospace 11"
-#define ANIMATION_X_GROW 50
-#define ANIMATION_Y_GROW 30
+#define ANIMATION_X_GROW 50
+#define ANIMATION_Y_GROW 30
#define SMALL_SCROLL_DURATION_MSEC 100
#define LARGE_SCROLL_DURATION_MSEC 250
#define FIXIT_LABEL_LEN_MAX 30
+#define SCROLL_REPLAY_DELAY 1000
#define _GDK_RECTANGLE_X2(rect) ((rect)->x + (rect)->width)
#define _GDK_RECTANGLE_Y2(rect) ((rect)->y + (rect)->height)
@@ -113,6 +114,8 @@ typedef struct
gunichar modifier;
guint count;
+ guint delayed_scroll_replay;
+
guint scroll_offset;
gint cached_char_height;
gint cached_char_width;
@@ -4732,6 +4735,21 @@ ide_source_view_set_indent_style (IdeSourceView *self,
gtk_source_view_set_insert_spaces_instead_of_tabs (GTK_SOURCE_VIEW (self), FALSE);
}
+static gboolean
+ide_source_view_replay_scroll (gpointer data)
+{
+ IdeSourceView *self = data;
+ IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+
+ g_assert (IDE_IS_SOURCE_VIEW (self));
+
+ priv->delayed_scroll_replay = 0;
+
+ ide_source_view_scroll_mark_onscreen (self, priv->scroll_mark);
+
+ return G_SOURCE_REMOVE;
+}
+
static void
ide_source_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -4753,7 +4771,13 @@ ide_source_view_size_allocate (GtkWidget *widget,
* has not yet reached our target location.
*/
if (priv->scrolling_to_scroll_mark)
- ide_source_view_scroll_mark_onscreen (self, priv->scroll_mark);
+ {
+ if (priv->delayed_scroll_replay != 0)
+ g_source_remove (priv->delayed_scroll_replay);
+ priv->delayed_scroll_replay = g_timeout_add (SCROLL_REPLAY_DELAY,
+ ide_source_view_replay_scroll,
+ self);
+ }
IDE_EXIT;
}
@@ -4766,6 +4790,12 @@ ide_source_view_dispose (GObject *object)
ide_source_view_clear_snippets (self);
+ if (priv->delayed_scroll_replay)
+ {
+ priv->delayed_scroll_replay = 0;
+ g_source_remove (priv->delayed_scroll_replay);
+ }
+
g_clear_object (&priv->capture);
g_clear_object (&priv->indenter);
g_clear_object (&priv->line_change_renderer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]