[gimp] app: add gimp_motion_buffer_get_last_motion_time() and use it



commit 534b48cb0d5eeb669efdc97607612759cf6670f4
Author: Michael Natterer <mitch gimp org>
Date:   Mon Apr 18 13:13:51 2011 +0200

    app: add gimp_motion_buffer_get_last_motion_time() and use it
    
    The last poking into the buffer is gone now.

 app/display/gimpdisplayshell-tool-events.c |   14 +++++---
 app/display/gimpmotionbuffer.c             |    8 +++++
 app/display/gimpmotionbuffer.h             |   45 ++++++++++++++-------------
 3 files changed, 40 insertions(+), 27 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index dbf4dad..c8f5b9b 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -870,6 +870,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
               {
                 GdkTimeCoord **history_events;
                 gint           n_history_events;
+                guint32        last_motion_time;
 
                 /*  if the first mouse button is down, check for automatic
                  *  scrolling...
@@ -883,18 +884,21 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
                     gimp_display_shell_autoscroll_start (shell, state, mevent);
                   }
 
-                /* gdk_device_get_history() has several quirks. First is
-                 * that events with borderline timestamps at both ends
-                 * are included. Because of that we need to add 1 to
-                 * lower border. The second is due to poor X event
+                /* gdk_device_get_history() has several quirks. First
+                 * is that events with borderline timestamps at both
+                 * ends are included. Because of that we need to add 1
+                 * to lower border. The second is due to poor X event
                  * resolution. We need to do -1 to ensure that the
                  * amount of events between timestamps is final or
                  * risk loosing some.
                  */
+                last_motion_time =
+                  gimp_motion_buffer_get_last_motion_time (shell->motion_buffer);
+
                 if (motion_mode == GIMP_MOTION_MODE_EXACT     &&
                     shell->display->config->use_event_history &&
                     gdk_device_get_history (mevent->device, mevent->window,
-                                            shell->motion_buffer->last_read_motion_time + 1,
+                                            last_motion_time + 1,
                                             mevent->time - 1,
                                             &history_events,
                                             &n_history_events))
diff --git a/app/display/gimpmotionbuffer.c b/app/display/gimpmotionbuffer.c
index fa94a55..c944af1 100644
--- a/app/display/gimpmotionbuffer.c
+++ b/app/display/gimpmotionbuffer.c
@@ -444,6 +444,14 @@ gimp_motion_buffer_motion_event (GimpMotionBuffer *buffer,
   return TRUE;
 }
 
+guint32
+gimp_motion_buffer_get_last_motion_time (GimpMotionBuffer *buffer)
+{
+  g_return_val_if_fail (GIMP_IS_MOTION_BUFFER (buffer), 0);
+
+  return buffer->last_read_motion_time;
+}
+
 void
 gimp_motion_buffer_request_stroke (GimpMotionBuffer *buffer,
                                    GdkModifierType   state,
diff --git a/app/display/gimpmotionbuffer.h b/app/display/gimpmotionbuffer.h
index a5d2170..ba1b56b 100644
--- a/app/display/gimpmotionbuffer.h
+++ b/app/display/gimpmotionbuffer.h
@@ -73,28 +73,29 @@ struct _GimpMotionBufferClass
 };
 
 
-GType              gimp_motion_buffer_get_type    (void) G_GNUC_CONST;
-
-GimpMotionBuffer * gimp_motion_buffer_new         (void);
-
-void       gimp_motion_buffer_begin_stroke        (GimpMotionBuffer *buffer,
-                                                   guint32           time,
-                                                   GimpCoords       *last_motion);
-void       gimp_motion_buffer_end_stroke          (GimpMotionBuffer *buffer);
-
-gboolean   gimp_motion_buffer_motion_event        (GimpMotionBuffer *buffer,
-                                                   GimpCoords       *coords,
-                                                   guint32           time,
-                                                   gdouble           scale_x,
-                                                   gdouble           scale_y,
-                                                   gboolean          event_fill);
-
-void       gimp_motion_buffer_request_stroke      (GimpMotionBuffer *buffer,
-                                                   GdkModifierType   state,
-                                                   guint32           time);
-void       gimp_motion_buffer_request_hover       (GimpMotionBuffer *buffer,
-                                                   GdkModifierType   state,
-                                                   gboolean          proximity);
+GType              gimp_motion_buffer_get_type     (void) G_GNUC_CONST;
+
+GimpMotionBuffer * gimp_motion_buffer_new          (void);
+
+void       gimp_motion_buffer_begin_stroke         (GimpMotionBuffer *buffer,
+                                                    guint32           time,
+                                                    GimpCoords       *last_motion);
+void       gimp_motion_buffer_end_stroke           (GimpMotionBuffer *buffer);
+
+gboolean   gimp_motion_buffer_motion_event         (GimpMotionBuffer *buffer,
+                                                    GimpCoords       *coords,
+                                                    guint32           time,
+                                                    gdouble           scale_x,
+                                                    gdouble           scale_y,
+                                                    gboolean          event_fill);
+guint32    gimp_motion_buffer_get_last_motion_time (GimpMotionBuffer *buffer);
+
+void       gimp_motion_buffer_request_stroke       (GimpMotionBuffer *buffer,
+                                                    GdkModifierType   state,
+                                                    guint32           time);
+void       gimp_motion_buffer_request_hover        (GimpMotionBuffer *buffer,
+                                                    GdkModifierType   state,
+                                                    gboolean          proximity);
 
 
 #endif /* __GIMP_MOTION_BUFFER_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]