[gimp] app: don't use a timeout for delaying display flushing
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: don't use a timeout for delaying display flushing
- Date: Mon, 11 Oct 2010 21:34:02 +0000 (UTC)
commit c79deb40dd70333112316560ba3ac7680c5a8427
Author: Michael Natterer <mitch gimp org>
Date: Mon Oct 11 23:33:33 2010 +0200
app: don't use a timeout for delaying display flushing
because it might never be called. Instead, check the time since
the last flush_now and make sure they are at least 20 ms apart.
app/display/gimpdisplay.c | 60 +++++++++++++-------------------------------
1 files changed, 18 insertions(+), 42 deletions(-)
---
diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c
index f52c282..18a049a 100644
--- a/app/display/gimpdisplay.c
+++ b/app/display/gimpdisplay.c
@@ -49,7 +49,7 @@
#include "gimp-intl.h"
-#define FLUSH_NOW_TIMEOUT 20
+#define FLUSH_NOW_INTERVAL 20000 /* 20 ms in microseconds */
enum
@@ -75,7 +75,7 @@ struct _GimpDisplayPrivate
GtkWidget *shell;
GSList *update_areas;
- guint flush_now_timeout;
+ GTimeVal last_flush_now;
};
#define GIMP_DISPLAY_GET_PRIVATE(display) \
@@ -88,7 +88,6 @@ struct _GimpDisplayPrivate
static void gimp_display_progress_iface_init (GimpProgressInterface *iface);
-static void gimp_display_dispose (GObject *object);
static void gimp_display_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -140,7 +139,6 @@ gimp_display_class_init (GimpDisplayClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = gimp_display_dispose;
object_class->set_property = gimp_display_set_property;
object_class->get_property = gimp_display_get_property;
@@ -192,20 +190,6 @@ gimp_display_progress_iface_init (GimpProgressInterface *iface)
}
static void
-gimp_display_dispose (GObject *object)
-{
- GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (object);
-
- if (private->flush_now_timeout)
- {
- g_source_remove (private->flush_now_timeout);
- private->flush_now_timeout = 0;
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
gimp_display_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -634,12 +618,6 @@ gimp_display_set_image (GimpDisplay *display,
shell = gimp_display_get_shell (display);
- if (private->flush_now_timeout)
- {
- g_source_remove (private->flush_now_timeout);
- private->flush_now_timeout = 0;
- }
-
if (private->image)
{
/* stop any active tool */
@@ -815,18 +793,6 @@ gimp_display_flush_now (GimpDisplay *display)
/* private functions */
-static gboolean
-gimp_display_flush_now_timeout (GimpDisplay *display)
-{
- GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
-
- private->flush_now_timeout = 0;
-
- gimp_display_shell_flush (gimp_display_get_shell (display), TRUE);
-
- return FALSE;
-}
-
static void
gimp_display_flush_whenever (GimpDisplay *display,
gboolean now)
@@ -857,12 +823,22 @@ gimp_display_flush_whenever (GimpDisplay *display,
if (now)
{
- if (! private->flush_now_timeout)
- private->flush_now_timeout =
- gdk_threads_add_timeout_full (G_PRIORITY_HIGH_IDLE,
- FLUSH_NOW_TIMEOUT,
- (GSourceFunc) gimp_display_flush_now_timeout,
- display, NULL);
+ GTimeVal time_now;
+ gint diff_usec;
+
+ g_get_current_time (&time_now);
+
+ diff_usec = (((guint64) time_now.tv_sec * G_USEC_PER_SEC +
+ (guint64) time_now.tv_usec) -
+ ((guint64) private->last_flush_now.tv_sec * G_USEC_PER_SEC +
+ (guint64) private->last_flush_now.tv_usec));
+
+ if (diff_usec > FLUSH_NOW_INTERVAL)
+ {
+ gimp_display_shell_flush (gimp_display_get_shell (display), now);
+
+ g_get_current_time (&private->last_flush_now);
+ }
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]