diff options
author | Christian Hergert <chergert@redhat.com> | 2023-02-21 14:00:44 -0800 |
---|---|---|
committer | Christian Hergert <chergert@redhat.com> | 2023-02-21 14:00:44 -0800 |
commit | fae0529bcd40f29d33e13d2762d77785ded9cc5c (patch) | |
tree | e449ca452633b66d2e70dfd0cb88111155b5c302 | |
parent | db9ef36dcaf221ea6b3968c0e1dbab32bec7bc89 (diff) | |
download | gtksourceview-fae0529bcd40f29d33e13d2762d77785ded9cc5c.tar.gz |
assistant: update popover positioning immediately
Now that a lot of other layers appear to be fixed, we can ramp back up the
number of repositions we do so they don't fallback to the next frame
cycle.
This improves the "jitter" that you feel when updating the completion
results in Builder.
You may want to have an up to date GTK if you're seeing issues with this
as lots of invalidations are being fixed in lower layers.
-rw-r--r-- | gtksourceview/gtksourceassistant-private.h | 2 | ||||
-rw-r--r-- | gtksourceview/gtksourceassistant.c | 65 | ||||
-rw-r--r-- | gtksourceview/gtksourcecompletionlist.c | 2 | ||||
-rw-r--r-- | gtksourceview/gtksourceview-snippets.c | 2 |
4 files changed, 5 insertions, 66 deletions
diff --git a/gtksourceview/gtksourceassistant-private.h b/gtksourceview/gtksourceassistant-private.h index 568e0d7d..b0506da1 100644 --- a/gtksourceview/gtksourceassistant-private.h +++ b/gtksourceview/gtksourceassistant-private.h @@ -54,7 +54,7 @@ void _gtk_source_assistant_set_mark (GtkSourceAssistant GtkTextMark *mark); void _gtk_source_assistant_set_child (GtkSourceAssistant *assistant, GtkWidget *child); -void _gtk_source_assistant_set_needs_position (GtkSourceAssistant *assistant); +gboolean _gtk_source_assistant_update_position (GtkSourceAssistant *assistant); void _gtk_source_assistant_destroy (GtkSourceAssistant *assistant); G_END_DECLS diff --git a/gtksourceview/gtksourceassistant.c b/gtksourceview/gtksourceassistant.c index ff954926..df2b710a 100644 --- a/gtksourceview/gtksourceassistant.c +++ b/gtksourceview/gtksourceassistant.c @@ -117,7 +117,7 @@ get_gutter_width (GtkSourceView *view) return 0; } -static gboolean +gboolean _gtk_source_assistant_update_position (GtkSourceAssistant *assistant) { GtkSourceAssistantPrivate *priv = _gtk_source_assistant_get_instance_private (assistant); @@ -179,56 +179,6 @@ _gtk_source_assistant_update_position (GtkSourceAssistant *assistant) return changed; } -static gboolean -gtk_source_assistant_reposition_tick_cb (GtkWidget *widget, - GdkFrameClock *frame_clock, - gpointer user_data) -{ - GtkSourceAssistant *self = user_data; - GtkSourceAssistantPrivate *priv = _gtk_source_assistant_get_instance_private (self); - - g_assert (GTK_SOURCE_IS_VIEW (widget)); - g_assert (GDK_IS_FRAME_CLOCK (frame_clock)); - g_assert (GTK_SOURCE_IS_ASSISTANT (self)); - - priv->reposition_handler = 0; - - _gtk_source_assistant_update_position (self); - - /* We have to gtk_widget_queue_resize() to ensure that the view will - * continue to have an allocation when the assistant gets snapshotted. - * gtk_widget_queue_allocate() is not enough to make that happen. - * Without this, we often get flickering of the GtkSourceView. - */ - gtk_widget_queue_resize (widget); - - return G_SOURCE_REMOVE; -} - -void -_gtk_source_assistant_set_needs_position (GtkSourceAssistant *self) -{ - GtkSourceAssistantPrivate *priv = _gtk_source_assistant_get_instance_private (self); - - g_return_if_fail (GTK_SOURCE_IS_ASSISTANT (self)); - - if (priv->reposition_handler == 0) - { - GtkSourceView *view = _gtk_source_assistant_get_view (self); - - if (view == NULL) - { - return; - } - - priv->reposition_handler = - gtk_widget_add_tick_callback (GTK_WIDGET (view), - gtk_source_assistant_reposition_tick_cb, - g_object_ref (self), - g_object_unref); - } -} - static void _gtk_source_assistant_show (GtkWidget *widget) { @@ -292,18 +242,7 @@ _gtk_source_assistant_dispose (GObject *object) g_assert (GTK_SOURCE_IS_ASSISTANT (self)); - if (priv->reposition_handler != 0) - { - GtkSourceView *view = _gtk_source_assistant_get_view (self); - - if (view != NULL) - { - gtk_widget_remove_tick_callback (GTK_WIDGET (view), - priv->reposition_handler); - } - - priv->reposition_handler = 0; - } + g_clear_handle_id (&priv->reposition_handler, g_source_remove); _gtk_source_assistant_detach (self); g_clear_object (&priv->mark); diff --git a/gtksourceview/gtksourcecompletionlist.c b/gtksourceview/gtksourcecompletionlist.c index 3532b1b0..184b8ee5 100644 --- a/gtksourceview/gtksourcecompletionlist.c +++ b/gtksourceview/gtksourcecompletionlist.c @@ -263,7 +263,7 @@ _gtk_source_completion_list_reposition_cb (GtkSourceCompletionList *self) { g_assert (GTK_SOURCE_IS_COMPLETION_LIST (self)); - _gtk_source_assistant_set_needs_position (GTK_SOURCE_ASSISTANT (self)); + _gtk_source_assistant_update_position (GTK_SOURCE_ASSISTANT (self)); } static void diff --git a/gtksourceview/gtksourceview-snippets.c b/gtksourceview/gtksourceview-snippets.c index 7cb4c68b..b61bca14 100644 --- a/gtksourceview/gtksourceview-snippets.c +++ b/gtksourceview/gtksourceview-snippets.c @@ -368,7 +368,7 @@ gtk_source_view_snippets_update_informative (GtkSourceViewSnippets *snippets) if (gtk_widget_get_visible (GTK_WIDGET (snippets->informative))) { - _gtk_source_assistant_set_needs_position (GTK_SOURCE_ASSISTANT (snippets->informative)); + _gtk_source_assistant_update_position (GTK_SOURCE_ASSISTANT (snippets->informative)); } else { |