app: add gimp_motion_buffer_get_last_motion_time() and use it

The last poking into the buffer is gone now.
This commit is contained in:
Michael Natterer 2011-04-18 13:13:51 +02:00
parent d305d000ff
commit 534b48cb0d
3 changed files with 36 additions and 23 deletions

View File

@ -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))

View File

@ -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,

View File

@ -73,28 +73,29 @@ struct _GimpMotionBufferClass
};
GType gimp_motion_buffer_get_type (void) G_GNUC_CONST;
GType gimp_motion_buffer_get_type (void) G_GNUC_CONST;
GimpMotionBuffer * gimp_motion_buffer_new (void);
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);
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);
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);
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__ */