* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
GList*
_gdk_event_queue_find_first (GdkDisplay *display)
{
- GList *tmp_list = display->queued_events;
+ GList *tmp_list;
+ GList *pending_motion = NULL;
+
+ if (display->event_pause_count > 0)
+ return NULL;
+ tmp_list = display->queued_events;
while (tmp_list)
{
GdkEventPrivate *event = tmp_list->data;
- if (!(event->flags & GDK_EVENT_PENDING))
- return tmp_list;
+
+ if (event->flags & GDK_EVENT_PENDING)
+ continue;
+
+ if (pending_motion)
+ return pending_motion;
+
+ if (event->event.type == GDK_MOTION_NOTIFY && !display->flushing_events)
+ pending_motion = tmp_list;
+ else
+ return tmp_list;
tmp_list = g_list_next (tmp_list);
}
}
/**
- * _gdk_event_queue_insert_after:
+ * _gdk_event_queue_insert_before:
* @display: a #GdkDisplay
- * @sibling: Append after this event.
- * @event: Event to append.
+ * @sibling: Append before this event
+ * @event: Event to prepend
*
- * Appends an event before the specified event, or if it isn't in
- * the queue, onto the tail of the event queue.
+ * Prepends an event before the specified event, or if it isn't in
+ * the queue, onto the head of the event queue.
*
- * Returns: the newly appended list node.
+ * Returns: the newly prepended list node.
*
* Since: 2.16
*/
return event;
}
+void
+_gdk_event_queue_handle_motion_compression (GdkDisplay *display)
+{
+ GList *tmp_list;
+ GList *pending_motions = NULL;
+ GdkWindow *pending_motion_window = NULL;
+ GdkDevice *pending_motion_device = NULL;
+
+ /* If the last N events in the event queue are motion notify
+ * events for the same window, drop all but the last */
+
+ tmp_list = display->queued_tail;
+
+ while (tmp_list)
+ {
+ GdkEventPrivate *event = tmp_list->data;
+
+ if (event->flags & GDK_EVENT_PENDING)
+ break;
+
+ if (event->event.type != GDK_MOTION_NOTIFY)
+ break;
+
+ if (pending_motion_window != NULL &&
+ pending_motion_window != event->event.motion.window)
+ break;
+
+ if (pending_motion_device != NULL &&
+ pending_motion_device != event->event.motion.device)
+ break;
+
+ pending_motion_window = event->event.motion.window;
+ pending_motion_device = event->event.motion.device;
+ pending_motions = tmp_list;
+
+ tmp_list = tmp_list->prev;
+ }
+
+ while (pending_motions && pending_motions->next != NULL)
+ {
+ GList *next = pending_motions->next;
+ display->queued_events = g_list_delete_link (display->queued_events,
+ pending_motions);
+ pending_motions = next;
+ }
+
+ if (pending_motions &&
+ pending_motions == display->queued_events &&
+ pending_motions == display->queued_tail)
+ {
+ GdkFrameClock *clock = gdk_window_get_frame_clock (pending_motion_window);
+ gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
+ }
+}
+
/**
* gdk_event_handler_set:
* @func: the function to call to handle events from GDK.
new_event->button.x_root = 0.;
new_event->button.y_root = 0.;
break;
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ new_event->touch.x = 0.;
+ new_event->touch.y = 0.;
+ new_event->touch.x_root = 0.;
+ new_event->touch.y_root = 0.;
+ break;
case GDK_SCROLL:
new_event->scroll.x = 0.;
new_event->scroll.y = 0.;
new_event->scroll.x_root = 0.;
new_event->scroll.y_root = 0.;
+ new_event->scroll.delta_x = 0.;
+ new_event->scroll.delta_y = 0.;
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
return FALSE;
}
-
+
+void
+_gdk_event_set_pointer_emulated (GdkEvent *event,
+ gboolean emulated)
+{
+ if (gdk_event_is_allocated (event))
+ {
+ GdkEventPrivate *private = (GdkEventPrivate *) event;
+
+ if (emulated)
+ private->flags |= GDK_EVENT_POINTER_EMULATED;
+ else
+ private->flags &= ~(GDK_EVENT_POINTER_EMULATED);
+ }
+}
+
+gboolean
+_gdk_event_get_pointer_emulated (GdkEvent *event)
+{
+ if (gdk_event_is_allocated (event))
+ return (((GdkEventPrivate *) event)->flags & GDK_EVENT_POINTER_EMULATED) != 0;
+
+ return FALSE;
+}
+
/**
* gdk_event_copy:
* @event: a #GdkEvent
sizeof (gdouble) * gdk_device_get_n_axes (event->button.device));
break;
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ if (event->touch.axes)
+ new_event->touch.axes = g_memdup (event->touch.axes,
+ sizeof (gdouble) * gdk_device_get_n_axes (event->touch.device));
+ break;
+
case GDK_MOTION_NOTIFY:
if (event->motion.axes)
new_event->motion.axes = g_memdup (event->motion.axes,
case GDK_BUTTON_RELEASE:
g_free (event->button.axes);
break;
-
+
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ g_free (event->touch.axes);
+ break;
+
case GDK_EXPOSE:
case GDK_DAMAGE:
if (event->expose.region)
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
return event->button.time;
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ return event->touch.time;
case GDK_SCROLL:
return event->scroll.time;
case GDK_KEY_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
- *state = event->button.state;
+ *state = event->button.state;
+ return TRUE;
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ *state = event->touch.state;
return TRUE;
case GDK_SCROLL:
*state = event->scroll.state;
x = event->button.x;
y = event->button.y;
break;
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ x = event->touch.x;
+ y = event->touch.y;
+ break;
case GDK_MOTION_NOTIFY:
x = event->motion.x;
y = event->motion.y;
x = event->button.x_root;
y = event->button.y_root;
break;
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ x = event->touch.x_root;
+ y = event->touch.y_root;
+ break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
x = event->crossing.x_root;
switch (event->type)
{
case GDK_SCROLL:
- dir = event->scroll.direction;
+ if (event->scroll.direction == GDK_SCROLL_SMOOTH)
+ fetched = FALSE;
+ else
+ dir = event->scroll.direction;
break;
default:
fetched = FALSE;
return fetched;
}
+/**
+ * gdk_event_get_scroll_deltas:
+ * @event: a #GdkEvent
+ * @delta_x: (out): return location for X delta
+ * @delta_y: (out): return location for Y delta
+ *
+ * Retrieves the scroll deltas from a #GdkEvent
+ *
+ * Returns: %TRUE if the event contains smooth scroll information
+ *
+ * Since: 3.4
+ **/
+gboolean
+gdk_event_get_scroll_deltas (const GdkEvent *event,
+ gdouble *delta_x,
+ gdouble *delta_y)
+{
+ gboolean fetched = TRUE;
+ gdouble dx = 0.0;
+ gdouble dy = 0.0;
+
+ switch (event->type)
+ {
+ case GDK_SCROLL:
+ if (event->scroll.direction == GDK_SCROLL_SMOOTH)
+ {
+ dx = event->scroll.delta_x;
+ dy = event->scroll.delta_y;
+ }
+ else
+ fetched = FALSE;
+ break;
+ default:
+ fetched = FALSE;
+ break;
+ }
+
+ if (delta_x)
+ *delta_x = dx;
+
+ if (delta_y)
+ *delta_y = dy;
+
+ return fetched;
+}
+
/**
* gdk_event_get_axis:
* @event: a #GdkEvent
switch (event->type)
{
- case GDK_MOTION_NOTIFY:
+ case GDK_MOTION_NOTIFY:
x = event->motion.x;
y = event->motion.y;
break;
x = event->button.x;
y = event->button.y;
break;
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ x = event->touch.x;
+ y = event->touch.y;
+ break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
x = event->crossing.x;
device = event->button.device;
axes = event->button.axes;
}
+ else if (event->type == GDK_TOUCH_BEGIN ||
+ event->type == GDK_TOUCH_UPDATE ||
+ event->type == GDK_TOUCH_END ||
+ event->type == GDK_TOUCH_CANCEL)
+ {
+ device = event->touch.device;
+ axes = event->touch.axes;
+ }
else if (event->type == GDK_MOTION_NOTIFY)
{
device = event->motion.device;
case GDK_BUTTON_RELEASE:
event->button.device = device;
break;
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ event->touch.device = device;
+ break;
case GDK_SCROLL:
event->scroll.device = device;
break;
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
return event->button.device;
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ return event->touch.device;
case GDK_SCROLL:
return event->scroll.device;
case GDK_PROXIMITY_IN:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
case GDK_FOCUS_CHANGE:
* also trigger a context menu if this modifier is pressed.
*
* This function should always be used instead of simply checking for
- * event->button == 3.
+ * event->button == %GDK_BUTTON_SECONDARY.
*
* Returns: %TRUE if the event should trigger a context menu.
*
g_return_val_if_fail (GDK_IS_WINDOW (bevent->window), FALSE);
- if (bevent->button == 3 &&
+ if (bevent->button == GDK_BUTTON_SECONDARY &&
! (bevent->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK)))
return TRUE;
GDK_MODIFIER_INTENT_CONTEXT_MENU);
if (modifier != 0 &&
- bevent->button == 1 &&
+ bevent->button == GDK_BUTTON_PRIMARY &&
! (bevent->state & (GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) &&
(bevent->state & modifier))
return TRUE;
return NULL;
}
+/**
+ * gdk_event_get_event_sequence:
+ * @event: a #GdkEvent
+ *
+ * If @event if of type %GDK_TOUCH_BEGIN, %GDK_TOUCH_UPDATE,
+ * %GDK_TOUCH_END or %GDK_TOUCH_CANCEL, returns the #GdkEventSequence
+ * to which the event belongs. Otherwise, return %NULL.
+ *
+ * Returns: the event sequence that the event belongs to
+ *
+ * Since: 3.4
+ */
+GdkEventSequence *
+gdk_event_get_event_sequence (const GdkEvent *event)
+{
+ if (!event)
+ return NULL;
+
+ if (event->type == GDK_TOUCH_BEGIN ||
+ event->type == GDK_TOUCH_UPDATE ||
+ event->type == GDK_TOUCH_END ||
+ event->type == GDK_TOUCH_CANCEL)
+ return event->touch.sequence;
+
+ return NULL;
+}
+
/**
* gdk_set_show_events:
* @show_events: %TRUE to output event debugging information.