[gimp/gimp-2-10] app: add back a timeout-based idle function to queue a canvas redraw.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add back a timeout-based idle function to queue a canvas redraw.
- Date: Fri, 22 Oct 2021 21:29:08 +0000 (UTC)
commit 71b23da329223ab765ecf855efbb3adc82ede7d6
Author: Jehan <jehan girinstud io>
Date: Tue May 11 19:11:30 2021 +0200
app: add back a timeout-based idle function to queue a canvas redraw.
I'm still very unclear why exactly but it would seem that just queuing
the redraw with an idle function is not enough. At least on Windows,
Jacob was having cases where opening an image would get stuck unless the
mouse was moved (causing draw events most likely).
So let's use a timeout function instead. Probably no need to queue the
idle followed by the timeout function as we had before commit
4fee04b839. Instead just directly queue a draw if relevant, then run the
timeout at regular interval (marching ants speed).
(cherry picked from commit 668c9de5a556a1d5407ddca8b787b4fad4ea0faf)
app/display/gimpdisplayshell-selection.c | 65 ++++++++++++++++----------------
1 file changed, 33 insertions(+), 32 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c
index 38756591e3..eca6cc1039 100644
--- a/app/display/gimpdisplayshell-selection.c
+++ b/app/display/gimpdisplayshell-selection.c
@@ -76,7 +76,7 @@ static void selection_zoom_segs (Selection *selection,
static void selection_generate_segs (Selection *selection);
static void selection_free_segs (Selection *selection);
-static gboolean selection_start_timeout (Selection *selection);
+static gboolean selection_timeout (Selection *selection);
static gboolean selection_window_state_event (GtkWidget *shell,
GdkEventWindowState *event,
@@ -229,10 +229,22 @@ selection_start (Selection *selection)
selection_stop (selection);
/* If this selection is paused, do not start it */
- if (selection->paused == 0 && selection->timeout == 0)
+ if (selection->paused == 0 &&
+ gimp_display_get_image (selection->shell->display) &&
+ selection->show_selection)
{
- selection->timeout = g_idle_add ((GSourceFunc) selection_start_timeout,
- selection);
+ /* Draw the ants once */
+ selection_timeout (selection);
+
+ if (selection->segs_in && selection->shell_visible)
+ {
+ GimpDisplayConfig *config = selection->shell->display->config;
+
+ selection->timeout = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
+ config->marching_ants_speed,
+ (GSourceFunc) selection_timeout,
+ selection, NULL);
+ }
}
}
@@ -439,41 +451,30 @@ selection_free_segs (Selection *selection)
}
static gboolean
-selection_start_timeout (Selection *selection)
+selection_timeout (Selection *selection)
{
- /* Draw the ants */
- if (gimp_display_get_image (selection->shell->display) &&
- selection->show_selection)
- {
- GimpDisplayConfig *config = selection->shell->display->config;
- gint64 time = g_get_monotonic_time ();
+ GimpDisplayConfig *config = selection->shell->display->config;
+ gint64 time = g_get_monotonic_time ();
- if ((time - selection->shell->selection_update) / 1000 > config->marching_ants_speed)
- {
- GdkWindow *window;
- cairo_rectangle_int_t rect;
- cairo_region_t *region;
+ if ((time - selection->shell->selection_update) / 1000 > config->marching_ants_speed)
+ {
+ GdkWindow *window;
+ cairo_rectangle_int_t rect;
+ cairo_region_t *region;
- window = gtk_widget_get_window (GTK_WIDGET (selection->shell));
+ window = gtk_widget_get_window (GTK_WIDGET (selection->shell));
- rect.x = 0;
- rect.y = 0;
- rect.width = gdk_window_get_width (window);
- rect.height = gdk_window_get_height (window);
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = gdk_window_get_width (window);
+ rect.height = gdk_window_get_height (window);
- region = cairo_region_create_rectangle (&rect);
- gtk_widget_queue_draw_region (GTK_WIDGET (selection->shell), region);
- cairo_region_destroy (region);
- }
- else
- {
- return G_SOURCE_CONTINUE;
- }
+ region = cairo_region_create_rectangle (&rect);
+ gtk_widget_queue_draw_region (GTK_WIDGET (selection->shell), region);
+ cairo_region_destroy (region);
}
- selection->timeout = 0;
-
- return G_SOURCE_REMOVE;
+ return G_SOURCE_CONTINUE;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]