[gtk/readonly-events-1: 51/51] events: reorganize getters
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/readonly-events-1: 51/51] events: reorganize getters
- Date: Mon, 17 Feb 2020 05:51:03 +0000 (UTC)
commit b68058d915d4d6099014389da11ca1d1c1408074
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Feb 16 11:58:33 2020 -0500
events: reorganize getters
Restructure the getters for event fields to
be more targeted at particular event types.
Update all callers, and replace all direct
event struct access with getters.
demos/gtk-demo/popover.c | 2 +-
demos/gtk-demo/themes.c | 2 +-
gdk/gdkapplaunchcontext.c | 2 +-
gdk/gdkevents.c | 2997 +++++++++++++++++---------------------
gdk/gdkevents.h | 181 +--
gdk/gdkeventsprivate.h | 50 +-
gdk/gdkkeys.c | 11 +-
gdk/gdksurface.c | 87 +-
gdk/wayland/gdkdevice-wayland.c | 92 +-
gdk/wayland/gdksurface-wayland.c | 2 +-
gdk/win32/gdkevents-win32.c | 92 +-
gdk/win32/gdksurface-win32.c | 2 +-
gdk/x11/gdkdevicemanager-xi2.c | 42 +-
gdk/x11/gdkdrag-x11.c | 15 +-
gdk/x11/gdkeventsource.c | 4 +-
gdk/x11/gdksurface-x11.c | 2 +-
gtk/a11y/gtkaccessibilityutil.c | 6 +-
gtk/gtkbindings.c | 13 +-
gtk/gtkbutton.c | 2 +-
gtk/gtkcellarea.c | 10 +-
gtk/gtkdragdest.c | 4 +-
gtk/gtkdragsource.c | 2 +-
gtk/gtkeventcontrollerkey.c | 14 +-
gtk/gtkeventcontrollerscroll.c | 11 +-
gtk/gtkgesture.c | 41 +-
gtk/gtkgestureclick.c | 6 +-
gtk/gtkgesturedrag.c | 2 +-
gtk/gtkgesturerotate.c | 9 +-
gtk/gtkgesturesingle.c | 9 +-
gtk/gtkgesturestylus.c | 2 +-
gtk/gtkgestureswipe.c | 2 +-
gtk/gtkgesturezoom.c | 6 +-
gtk/gtkiconview.c | 6 +-
gtk/gtkimcontextsimple.c | 35 +-
gtk/gtkimmulticontext.c | 7 +-
gtk/gtklabel.c | 2 +-
gtk/gtkmain.c | 174 ++-
gtk/gtkmountoperation.c | 4 +-
gtk/gtkpadcontroller.c | 6 +-
gtk/gtkrange.c | 2 +-
gtk/gtkscrolledwindow.c | 2 +-
gtk/gtktext.c | 2 +-
gtk/gtktextview.c | 10 +-
gtk/gtktooltip.c | 4 +-
gtk/gtktreeview.c | 2 +-
gtk/gtkwidget.c | 142 +-
gtk/gtkwindow.c | 36 +-
gtk/gtkwindow.h | 4 +-
gtk/inspector/inspect-button.c | 2 +-
tests/testwindowdrag.c | 10 +-
50 files changed, 1883 insertions(+), 2289 deletions(-)
---
diff --git a/demos/gtk-demo/popover.c b/demos/gtk-demo/popover.c
index 03652f6d39..860df60416 100644
--- a/demos/gtk-demo/popover.c
+++ b/demos/gtk-demo/popover.c
@@ -105,7 +105,7 @@ day_selected_cb (GtkCalendar *calendar,
if (gdk_event_get_event_type (event) != GDK_BUTTON_PRESS)
return;
- gdk_event_get_coords (event, &x, &y);
+ gdk_event_get_position (event, &x, &y);
gtk_widget_translate_coordinates (gtk_get_event_widget (event),
GTK_WIDGET (calendar),
x, y,
diff --git a/demos/gtk-demo/themes.c b/demos/gtk-demo/themes.c
index 1ad98b14e7..0627ebe076 100644
--- a/demos/gtk-demo/themes.c
+++ b/demos/gtk-demo/themes.c
@@ -141,7 +141,7 @@ clicked (GtkGestureClick *gesture,
window = gtk_widget_get_ancestor (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)),
GTK_TYPE_WINDOW);
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), NULL);
- gdk_event_get_state (event, &state);
+ state = gdk_event_get_modifier_state (event);
if (state & GDK_CONTROL_MASK)
{
diff --git a/gdk/gdkapplaunchcontext.c b/gdk/gdkapplaunchcontext.c
index c82bcf0034..97c72aad4f 100644
--- a/gdk/gdkapplaunchcontext.c
+++ b/gdk/gdkapplaunchcontext.c
@@ -43,7 +43,7 @@
* context = gdk_display_get_app_launch_context (display);
*
* gdk_app_launch_context_set_display (display);
- * gdk_app_launch_context_set_timestamp (event->time);
+ * gdk_app_launch_context_set_timestamp (gdk_event_get_time (event));
*
* if (!g_app_info_launch_default_for_uri ("http://www.gtk.org", context, &error))
* g_warning ("Launching failed: %s\n", error->message);
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 7864f7ac3c..83d29b76fc 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -264,8 +264,8 @@ _gdk_event_unqueue (GdkDisplay *display)
}
static void
-gdk_event_push_history (GdkEvent *event,
- GdkEvent *history_event)
+gdk_event_push_history (GdkEvent *event,
+ GdkEvent *history_event)
{
GdkTimeCoord *hist;
GdkDevice *device;
@@ -460,2036 +460,1647 @@ gdk_event_free (GdkEvent *event)
}
/**
- * gdk_event_get_surface:
+ * gdk_event_get_axis:
* @event: a #GdkEvent
+ * @axis_use: the axis use to look for
+ * @value: (out): location to store the value found
*
- * Extracts the #GdkSurface associated with an event.
+ * Extract the axis value for a particular axis use from
+ * an event structure.
*
- * Returns: (transfer none): The #GdkSurface associated with the event
- */
-GdkSurface *
-gdk_event_get_surface (GdkEvent *event)
+ * Returns: %TRUE if the specified axis was found, otherwise %FALSE
+ **/
+gboolean
+gdk_event_get_axis (GdkEvent *event,
+ GdkAxisUse axis_use,
+ double *value)
{
- g_return_val_if_fail (event != NULL, NULL);
+ double *axes;
- return event->any.surface;
-}
+ if (axis_use == GDK_AXIS_X || axis_use == GDK_AXIS_Y)
+ {
+ gdouble x, y;
-/**
- * gdk_event_get_time:
- * @event: a #GdkEvent
- *
- * Returns the time stamp from @event, if there is one; otherwise
- * returns #GDK_CURRENT_TIME. If @event is %NULL, returns #GDK_CURRENT_TIME.
- *
- * Returns: time stamp field from @event
- **/
-guint32
-gdk_event_get_time (GdkEvent *event)
-{
- if (event)
- switch (event->any.type)
- {
- case GDK_MOTION_NOTIFY:
- return event->motion.time;
- case GDK_BUTTON_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_TOUCHPAD_SWIPE:
- return event->touchpad_swipe.time;
- case GDK_TOUCHPAD_PINCH:
- return event->touchpad_pinch.time;
- case GDK_SCROLL:
- return event->scroll.time;
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- return event->key.time;
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- return event->crossing.time;
- case GDK_PROXIMITY_IN:
- case GDK_PROXIMITY_OUT:
- return event->proximity.time;
- case GDK_DRAG_ENTER:
- case GDK_DRAG_LEAVE:
- case GDK_DRAG_MOTION:
- case GDK_DROP_START:
- return event->dnd.time;
- case GDK_PAD_BUTTON_PRESS:
- case GDK_PAD_BUTTON_RELEASE:
- return event->pad_button.time;
- case GDK_PAD_RING:
- case GDK_PAD_STRIP:
- return event->pad_axis.time;
- case GDK_PAD_GROUP_MODE:
- return event->pad_group_mode.time;
- case GDK_CONFIGURE:
- case GDK_FOCUS_CHANGE:
- case GDK_DELETE:
- case GDK_GRAB_BROKEN:
- case GDK_EVENT_LAST:
- default:
- /* return current time */
- break;
- }
-
- return GDK_CURRENT_TIME;
+ switch ((guint) event->any.type)
+ {
+ case GDK_MOTION_NOTIFY:
+ x = event->motion.x;
+ y = event->motion.y;
+ break;
+ case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ 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;
+ y = event->crossing.y;
+ break;
+ default:
+ return FALSE;
+ }
+
+ if (axis_use == GDK_AXIS_X && value)
+ *value = x;
+ if (axis_use == GDK_AXIS_Y && value)
+ *value = y;
+
+ return TRUE;
+ }
+ else if (event->any.type == GDK_BUTTON_PRESS ||
+ event->any.type == GDK_BUTTON_RELEASE)
+ {
+ axes = event->button.axes;
+ }
+ else if (event->any.type == GDK_TOUCH_BEGIN ||
+ event->any.type == GDK_TOUCH_UPDATE ||
+ event->any.type == GDK_TOUCH_END ||
+ event->any.type == GDK_TOUCH_CANCEL)
+ {
+ axes = event->touch.axes;
+ }
+ else if (event->any.type == GDK_MOTION_NOTIFY)
+ {
+ axes = event->motion.axes;
+ }
+ else
+ return FALSE;
+
+ return gdk_device_get_axis (event->any.device, axes, axis_use, value);
}
/**
- * gdk_event_get_state:
- * @event: (allow-none): a #GdkEvent or %NULL
- * @state: (out): return location for state
+ * gdk_event_triggers_context_menu:
+ * @event: a #GdkEvent, currently only button events are meaningful values
*
- * If the event contains a “state” field, puts that field in @state.
+ * This function returns whether a #GdkEventButton should trigger a
+ * context menu, according to platform conventions. The right mouse
+ * button always triggers context menus. Additionally, if
+ * gdk_keymap_get_modifier_mask() returns a non-0 mask for
+ * %GDK_MODIFIER_INTENT_CONTEXT_MENU, then the left mouse button will
+ * also trigger a context menu if this modifier is pressed.
*
- * Otherwise stores an empty state (0).
- * @event may be %NULL, in which case it’s treated
- * as if the event had no state field.
+ * This function should always be used instead of simply checking for
+ * event->button == %GDK_BUTTON_SECONDARY.
*
- * Returns: %TRUE if there was a state field in the event
+ * Returns: %TRUE if the event should trigger a context menu.
**/
gboolean
-gdk_event_get_state (GdkEvent *event,
- GdkModifierType *state)
+gdk_event_triggers_context_menu (GdkEvent *event)
{
- g_return_val_if_fail (state != NULL, FALSE);
-
- if (event)
- switch (event->any.type)
- {
- case GDK_MOTION_NOTIFY:
- *state = event->motion.state;
- return TRUE;
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- *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_TOUCHPAD_SWIPE:
- *state = event->touchpad_swipe.state;
- return TRUE;
- case GDK_TOUCHPAD_PINCH:
- *state = event->touchpad_pinch.state;
- return TRUE;
- case GDK_SCROLL:
- *state = event->scroll.state;
- return TRUE;
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- *state = event->key.state;
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ if (event->any.type == GDK_BUTTON_PRESS)
+ {
+ GdkEventButton *bevent = (GdkEventButton *) event;
+ GdkDisplay *display;
+ GdkModifierType modifier;
+
+ g_return_val_if_fail (GDK_IS_SURFACE (bevent->any.surface), FALSE);
+
+ if (bevent->button == GDK_BUTTON_SECONDARY &&
+ ! (bevent->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK)))
return TRUE;
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- *state = event->crossing.state;
+
+ display = gdk_surface_get_display (bevent->any.surface);
+
+ modifier = gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
+ GDK_MODIFIER_INTENT_CONTEXT_MENU);
+
+ if (modifier != 0 &&
+ bevent->button == GDK_BUTTON_PRIMARY &&
+ ! (bevent->state & (GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) &&
+ (bevent->state & modifier))
return TRUE;
- case GDK_CONFIGURE:
- case GDK_FOCUS_CHANGE:
- case GDK_PROXIMITY_IN:
- case GDK_PROXIMITY_OUT:
- case GDK_DRAG_ENTER:
- case GDK_DRAG_LEAVE:
- case GDK_DRAG_MOTION:
- case GDK_DROP_START:
- case GDK_DELETE:
- case GDK_GRAB_BROKEN:
- case GDK_PAD_BUTTON_PRESS:
- case GDK_PAD_BUTTON_RELEASE:
- case GDK_PAD_RING:
- case GDK_PAD_STRIP:
- case GDK_PAD_GROUP_MODE:
- case GDK_EVENT_LAST:
- default:
- /* no state field */
- break;
- }
+ }
- *state = 0;
return FALSE;
}
-/**
- * gdk_event_get_coords:
- * @event: a #GdkEvent
- * @x_win: (out) (optional): location to put event surface x coordinate
- * @y_win: (out) (optional): location to put event surface y coordinate
- *
- * Extract the event surface relative x/y coordinates from an event.
- *
- * Returns: %TRUE if the event delivered event surface coordinates
- **/
-gboolean
-gdk_event_get_coords (GdkEvent *event,
- gdouble *x_win,
- gdouble *y_win)
+static gboolean
+gdk_events_get_axis_distances (GdkEvent *event1,
+ GdkEvent *event2,
+ gdouble *x_distance,
+ gdouble *y_distance,
+ gdouble *distance)
{
- gdouble x = 0, y = 0;
- gboolean fetched = TRUE;
+ gdouble x1, x2, y1, y2;
+ gdouble xd, yd;
- g_return_val_if_fail (event != NULL, FALSE);
+ if (!gdk_event_get_position (event1, &x1, &y1) ||
+ !gdk_event_get_position (event2, &x2, &y2))
+ return FALSE;
- switch ((guint) event->any.type)
- {
- case GDK_CONFIGURE:
- x = event->configure.x;
- y = event->configure.y;
- break;
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- x = event->crossing.x;
- y = event->crossing.y;
- break;
- case GDK_SCROLL:
- x = event->scroll.x;
- y = event->scroll.y;
- break;
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- 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;
- break;
- case GDK_TOUCHPAD_SWIPE:
- x = event->touchpad_swipe.x;
- y = event->touchpad_swipe.y;
- break;
- case GDK_TOUCHPAD_PINCH:
- x = event->touchpad_pinch.x;
- y = event->touchpad_pinch.y;
- break;
- case GDK_DRAG_ENTER:
- case GDK_DRAG_LEAVE:
- case GDK_DRAG_MOTION:
- case GDK_DROP_START:
- x = event->dnd.x;
- y = event->dnd.y;
- break;
- default:
- fetched = FALSE;
- break;
- }
+ xd = x2 - x1;
+ yd = y2 - y1;
- if (x_win)
- *x_win = x;
- if (y_win)
- *y_win = y;
+ if (x_distance)
+ *x_distance = xd;
+
+ if (y_distance)
+ *y_distance = yd;
+
+ if (distance)
+ *distance = sqrt ((xd * xd) + (yd * yd));
- return fetched;
+ return TRUE;
}
/**
- * gdk_event_get_button:
- * @event: a #GdkEvent
- * @button: (out): location to store mouse button number
+ * gdk_events_get_distance:
+ * @event1: first #GdkEvent
+ * @event2: second #GdkEvent
+ * @distance: (out): return location for the distance
*
- * Extract the button number from an event.
+ * If both events have X/Y information, the distance between both coordinates
+ * (as in a straight line going from @event1 to @event2) will be returned.
*
- * Returns: %TRUE if the event delivered a button number
+ * Returns: %TRUE if the distance could be calculated.
**/
gboolean
-gdk_event_get_button (GdkEvent *event,
- guint *button)
+gdk_events_get_distance (GdkEvent *event1,
+ GdkEvent *event2,
+ gdouble *distance)
{
- gboolean fetched = TRUE;
- guint number = 0;
-
- g_return_val_if_fail (event != NULL, FALSE);
-
- switch ((guint) event->any.type)
- {
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- number = event->button.button;
- break;
- case GDK_PAD_BUTTON_PRESS:
- case GDK_PAD_BUTTON_RELEASE:
- number = event->pad_button.button;
- break;
- default:
- fetched = FALSE;
- break;
- }
-
- if (button)
- *button = number;
-
- return fetched;
+ return gdk_events_get_axis_distances (event1, event2,
+ NULL, NULL,
+ distance);
}
/**
- * gdk_event_get_click_count:
- * @event: a #GdkEvent
- * @click_count: (out): location to store click count
+ * gdk_events_get_angle:
+ * @event1: first #GdkEvent
+ * @event2: second #GdkEvent
+ * @angle: (out): return location for the relative angle between both events
*
- * Extracts the click count from an event.
+ * If both events contain X/Y information, this function will return %TRUE
+ * and return in @angle the relative angle from @event1 to @event2. The rotation
+ * direction for positive angles is from the positive X axis towards the positive
+ * Y axis.
*
- * Returns: %TRUE if the event delivered a click count
- */
+ * Returns: %TRUE if the angle could be calculated.
+ **/
gboolean
-gdk_event_get_click_count (GdkEvent *event,
- guint *click_count)
+gdk_events_get_angle (GdkEvent *event1,
+ GdkEvent *event2,
+ gdouble *angle)
{
- gboolean fetched = TRUE;
- guint number = 0;
+ gdouble x_distance, y_distance, distance;
- g_return_val_if_fail (event != NULL, FALSE);
+ if (!gdk_events_get_axis_distances (event1, event2,
+ &x_distance, &y_distance,
+ &distance))
+ return FALSE;
- switch ((guint) event->any.type)
+ if (angle)
{
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- number = 1;
- break;
- default:
- fetched = FALSE;
- break;
- }
+ *angle = atan2 (x_distance, y_distance);
+
+ /* Invert angle */
+ *angle = (2 * G_PI) - *angle;
- if (click_count)
- *click_count = number;
+ /* Shift it 90° */
+ *angle += G_PI / 2;
+
+ /* And constraint it to 0°-360° */
+ *angle = fmod (*angle, 2 * G_PI);
+ }
- return fetched;
+ return TRUE;
}
/**
- * gdk_event_get_keyval:
- * @event: a #GdkEvent
- * @keyval: (out): location to store the keyval
+ * gdk_events_get_center:
+ * @event1: first #GdkEvent
+ * @event2: second #GdkEvent
+ * @x: (out): return location for the X coordinate of the center
+ * @y: (out): return location for the Y coordinate of the center
*
- * Extracts the keyval from an event.
+ * If both events contain X/Y information, the center of both coordinates
+ * will be returned in @x and @y.
*
- * Returns: %TRUE if the event delivered a key symbol
- */
+ * Returns: %TRUE if the center could be calculated.
+ **/
gboolean
-gdk_event_get_keyval (GdkEvent *event,
- guint *keyval)
+gdk_events_get_center (GdkEvent *event1,
+ GdkEvent *event2,
+ gdouble *x,
+ gdouble *y)
{
- gboolean fetched = TRUE;
- guint number = 0;
-
- switch ((guint) event->any.type)
- {
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- number = event->key.keyval;
- break;
- default:
- fetched = FALSE;
- break;
- }
-
- if (keyval)
- *keyval = number;
-
- return fetched;
-}
+ gdouble x1, x2, y1, y2;
-/**
- * gdk_event_get_keycode:
- * @event: a #GdkEvent
- * @keycode: (out): location to store the keycode
- *
- * Extracts the hardware keycode from an event.
- *
- * Also see gdk_event_get_scancode().
- *
- * Returns: %TRUE if the event delivered a hardware keycode
- */
-gboolean
-gdk_event_get_keycode (GdkEvent *event,
- guint16 *keycode)
-{
- gboolean fetched = TRUE;
- guint16 number = 0;
+ if (!gdk_event_get_position (event1, &x1, &y1) ||
+ !gdk_event_get_position (event2, &x2, &y2))
+ return FALSE;
- switch ((guint) event->any.type)
- {
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- number = event->key.hardware_keycode;
- break;
- default:
- fetched = FALSE;
- break;
- }
+ if (x)
+ *x = (x2 + x1) / 2;
- if (keycode)
- *keycode = number;
+ if (y)
+ *y = (y2 + y1) / 2;
- return fetched;
+ return TRUE;
}
-/**
- * gdk_event_get_key_group:
- * @event: a #GdkEvent
- * @group: (out): return location for the key group
- *
- * Extracts the key group from an event.
- *
- * Returns: %TRUE on success, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_key_group (GdkEvent *event,
- guint *group)
+static GdkEventSequence *
+gdk_event_sequence_copy (GdkEventSequence *sequence)
{
- gboolean fetched = TRUE;
-
- switch ((guint) event->any.type)
- {
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- *group = event->key.group;
- break;
- default:
- *group = 0;
- fetched = FALSE;
- break;
- }
-
- return fetched;
+ return sequence;
}
-/**
- * gdk_event_get_key_is_modifier:
- * @event: a #GdkEvent
- * @is_modifier: (out): return location for the value
- *
- * Extracts whether the event is a key event for
- * a modifier key.
- *
- * Returns: %TRUE on success, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_key_is_modifier (GdkEvent *event,
- gboolean *is_modifier)
+static void
+gdk_event_sequence_free (GdkEventSequence *sequence)
{
- gboolean fetched = TRUE;
-
- switch ((guint) event->any.type)
- {
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- *is_modifier = event->key.is_modifier;
- break;
- default:
- *is_modifier = FALSE;
- fetched = FALSE;
- break;
- }
-
- return fetched;
+ /* Nothing to free here */
}
-/**
- * gdk_event_get_scroll_direction:
- * @event: a #GdkEvent
- * @direction: (out): location to store the scroll direction
- *
- * Extracts the scroll direction from an event.
- *
- * Returns: %TRUE if the event delivered a scroll direction
- */
-gboolean
-gdk_event_get_scroll_direction (GdkEvent *event,
- GdkScrollDirection *direction)
-{
- gboolean fetched = TRUE;
- GdkScrollDirection dir = 0;
-
- switch ((guint) event->any.type)
- {
- case GDK_SCROLL:
- if (event->scroll.direction == GDK_SCROLL_SMOOTH)
- fetched = FALSE;
- else
- dir = event->scroll.direction;
- break;
- default:
- fetched = FALSE;
- break;
- }
+G_DEFINE_BOXED_TYPE (GdkEventSequence, gdk_event_sequence,
+ gdk_event_sequence_copy,
+ gdk_event_sequence_free)
- if (direction)
- *direction = dir;
- return fetched;
-}
/**
- * gdk_event_get_scroll_deltas:
+ * gdk_event_get_axes:
* @event: a #GdkEvent
- * @delta_x: (out): return location for X delta
- * @delta_y: (out): return location for Y delta
+ * @axes: (transfer none) (out) (array length=n_axes): the array of values for all axes
+ * @n_axes: (out): the length of array
*
- * Retrieves the scroll deltas from a #GdkEvent
+ * Extracts all axis values from an event.
*
- * Returns: %TRUE if the event contains smooth scroll information
+ * Returns: %TRUE on success, otherwise %FALSE
**/
gboolean
-gdk_event_get_scroll_deltas (GdkEvent *event,
- gdouble *delta_x,
- gdouble *delta_y)
+gdk_event_get_axes (GdkEvent *event,
+ double **axes,
+ guint *n_axes)
{
- gboolean fetched = TRUE;
- gdouble dx = 0.0;
- gdouble dy = 0.0;
-
- switch ((guint) event->any.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;
-}
+ GdkDevice *source_device;
-/**
- * gdk_event_is_scroll_stop_event
- * @event: a #GdkEvent
- *
- * Check whether a scroll event is a stop scroll event. Scroll sequences
- * with smooth scroll information may provide a stop scroll event once the
- * interaction with the device finishes, e.g. by lifting a finger. This
- * stop scroll event is the signal that a widget may trigger kinetic
- * scrolling based on the current velocity.
- *
- * Stop scroll events always have a delta of 0/0.
- *
- * Returns: %TRUE if the event is a scroll stop event
- */
-gboolean
-gdk_event_is_scroll_stop_event (GdkEvent *event)
-{
- return event->scroll.is_stop;
-}
+ if (!event)
+ return FALSE;
-/**
- * gdk_event_get_axis:
- * @event: a #GdkEvent
- * @axis_use: the axis use to look for
- * @value: (out): location to store the value found
- *
- * Extract the axis value for a particular axis use from
- * an event structure.
- *
- * Returns: %TRUE if the specified axis was found, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_axis (GdkEvent *event,
- GdkAxisUse axis_use,
- gdouble *value)
-{
- gdouble *axes;
+ source_device = gdk_event_get_source_device (event);
- g_return_val_if_fail (event != NULL, FALSE);
+ if (!source_device)
+ return FALSE;
- if (axis_use == GDK_AXIS_X || axis_use == GDK_AXIS_Y)
+ if (event->any.type == GDK_MOTION_NOTIFY)
{
- gdouble x, y;
-
- switch ((guint) event->any.type)
- {
- case GDK_MOTION_NOTIFY:
- x = event->motion.x;
- y = event->motion.y;
- break;
- case GDK_SCROLL:
- x = event->scroll.x;
- y = event->scroll.y;
- break;
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- 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;
- y = event->crossing.y;
- break;
- default:
- return FALSE;
- }
-
- if (axis_use == GDK_AXIS_X && value)
- *value = x;
- if (axis_use == GDK_AXIS_Y && value)
- *value = y;
-
+ *axes = event->motion.axes;
+ *n_axes = gdk_device_get_n_axes (source_device);
return TRUE;
}
else if (event->any.type == GDK_BUTTON_PRESS ||
- event->any.type == GDK_BUTTON_RELEASE)
+ event->any.type == GDK_BUTTON_RELEASE)
{
- axes = event->button.axes;
+ *axes = event->button.axes;
+ *n_axes = gdk_device_get_n_axes (source_device);
+ return TRUE;
}
else if (event->any.type == GDK_TOUCH_BEGIN ||
event->any.type == GDK_TOUCH_UPDATE ||
event->any.type == GDK_TOUCH_END ||
event->any.type == GDK_TOUCH_CANCEL)
{
- axes = event->touch.axes;
- }
- else if (event->any.type == GDK_MOTION_NOTIFY)
- {
- axes = event->motion.axes;
+ *axes = event->touch.axes;
+ *n_axes = gdk_device_get_n_axes (source_device);
+ return TRUE;
}
- else
- return FALSE;
- return gdk_device_get_axis (event->any.device, axes, axis_use, value);
+ return FALSE;
}
/**
- * gdk_event_get_device:
- * @event: a #GdkEvent.
+ * gdk_event_get_motion_history:
+ * @event: a #GdkEvent of type %GDK_MOTION_NOTIFY
*
- * If the event contains a “device” field, this function will return
- * it, else it will return %NULL.
+ * Retrieves the history of the @event motion, as a list of time and
+ * coordinates.
*
- * Returns: (nullable) (transfer none): a #GdkDevice, or %NULL.
- **/
-GdkDevice *
-gdk_event_get_device (GdkEvent *event)
+ * Returns: (transfer container) (element-type GdkTimeCoord) (nullable): a list
+ * of time and coordinates
+ */
+GList *
+gdk_event_get_motion_history (GdkEvent *event)
{
- g_return_val_if_fail (event != NULL, NULL);
-
- return event->any.device;
+ if (event->any.type != GDK_MOTION_NOTIFY)
+ return NULL;
+ return g_list_reverse (g_list_copy (event->motion.history));
}
-/**
- * gdk_event_get_source_device:
- * @event: a #GdkEvent
- *
- * This function returns the hardware (slave) #GdkDevice that has
- * triggered the event, falling back to the virtual (master) device
- * (as in gdk_event_get_device()) if the event wasn’t caused by
- * interaction with a hardware device. This may happen for example
- * in synthesized crossing events after a #GdkSurface updates its
- * geometry or a grab is acquired/released.
- *
- * If the event does not contain a device field, this function will
- * return %NULL.
- *
- * Returns: (nullable) (transfer none): a #GdkDevice, or %NULL.
- **/
-GdkDevice *
-gdk_event_get_source_device (GdkEvent *event)
+GdkEvent *
+gdk_event_button_new (GdkEventType type,
+ GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ GdkDeviceTool *tool,
+ guint32 time,
+ GdkModifierType state,
+ guint button,
+ double x,
+ double y,
+ double *axes)
{
- g_return_val_if_fail (event != NULL, NULL);
+ GdkEventButton *event;
- if (event->any.source_device)
- return event->any.source_device;
+ g_return_val_if_fail (type == GDK_BUTTON_PRESS ||
+ type == GDK_BUTTON_RELEASE, NULL);
+
+ event = g_new0 (GdkEventButton, 1);
+ event->any.ref_count = 1;
+ event->any.type = type;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->tool = tool ? g_object_ref (tool) : NULL;
+ event->time = time;
+ event->axes = NULL;
+ event->state = state;
+ event->button = button;
+ event->x = x;
+ event->y = y;
+ event->axes = axes;
- /* Fallback to event device */
- return gdk_event_get_device (event);
+ return (GdkEvent *)event;
}
-/**
- * gdk_event_triggers_context_menu:
- * @event: a #GdkEvent, currently only button events are meaningful values
- *
- * This function returns whether a #GdkEventButton should trigger a
- * context menu, according to platform conventions. The right mouse
- * button always triggers context menus. Additionally, if
- * gdk_keymap_get_modifier_mask() returns a non-0 mask for
- * %GDK_MODIFIER_INTENT_CONTEXT_MENU, then the left mouse button will
- * also trigger a context menu if this modifier is pressed.
- *
- * This function should always be used instead of simply checking for
- * event->button == %GDK_BUTTON_SECONDARY.
- *
- * Returns: %TRUE if the event should trigger a context menu.
- **/
-gboolean
-gdk_event_triggers_context_menu (GdkEvent *event)
+GdkEvent *
+gdk_event_motion_new (GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ GdkDeviceTool *tool,
+ guint32 time,
+ GdkModifierType state,
+ double x,
+ double y,
+ double *axes)
{
- g_return_val_if_fail (event != NULL, FALSE);
+ GdkEventMotion *event = g_new0 (GdkEventMotion, 1);
- if (event->any.type == GDK_BUTTON_PRESS)
- {
- GdkEventButton *bevent = (GdkEventButton *) event;
- GdkDisplay *display;
- GdkModifierType modifier;
+ event->any.ref_count = 1;
+ event->any.type = GDK_MOTION_NOTIFY;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->tool = tool ? g_object_ref (tool) : NULL;
+ event->time = time;
+ event->state = state;
+ event->x = x;
+ event->y = y;
+ event->axes = axes;
+ event->state = state;
- g_return_val_if_fail (GDK_IS_SURFACE (bevent->any.surface), FALSE);
+ return (GdkEvent *)event;
+}
- if (bevent->button == GDK_BUTTON_SECONDARY &&
- ! (bevent->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK)))
- return TRUE;
+GdkEvent *
+gdk_event_crossing_new (GdkEventType type,
+ GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ guint32 time,
+ GdkModifierType state,
+ double x,
+ double y,
+ GdkCrossingMode mode,
+ GdkNotifyType detail)
+{
+ GdkEventCrossing *event;
- display = gdk_surface_get_display (bevent->any.surface);
+ g_return_val_if_fail (type == GDK_ENTER_NOTIFY ||
+ type == GDK_LEAVE_NOTIFY, NULL);
- modifier = gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
- GDK_MODIFIER_INTENT_CONTEXT_MENU);
+ event = g_new0 (GdkEventCrossing, 1);
- if (modifier != 0 &&
- bevent->button == GDK_BUTTON_PRIMARY &&
- ! (bevent->state & (GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) &&
- (bevent->state & modifier))
- return TRUE;
- }
+ event->any.ref_count = 1;
+ event->any.type = type;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->time = time;
+ event->state = state;
+ event->x = x;
+ event->y = y;
+ event->mode = mode;
+ event->detail = detail;
- return FALSE;
+ return (GdkEvent *)event;
}
-static gboolean
-gdk_events_get_axis_distances (GdkEvent *event1,
- GdkEvent *event2,
- gdouble *x_distance,
- gdouble *y_distance,
- gdouble *distance)
+GdkEvent *
+gdk_event_proximity_new (GdkEventType type,
+ GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ GdkDeviceTool *tool,
+ guint32 time)
{
- gdouble x1, x2, y1, y2;
- gdouble xd, yd;
+ GdkEventProximity *event;
- if (!gdk_event_get_coords (event1, &x1, &y1) ||
- !gdk_event_get_coords (event2, &x2, &y2))
- return FALSE;
+ g_return_val_if_fail (type == GDK_PROXIMITY_IN ||
+ type == GDK_PROXIMITY_OUT, NULL);
- xd = x2 - x1;
- yd = y2 - y1;
+ event = g_new0 (GdkEventProximity, 1);
- if (x_distance)
- *x_distance = xd;
+ event->any.ref_count = 1;
+ event->any.type = type;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->tool = tool ? g_object_ref (tool) : NULL;
+ event->time = time;
- if (y_distance)
- *y_distance = yd;
+ return (GdkEvent *)event;
+}
- if (distance)
- *distance = sqrt ((xd * xd) + (yd * yd));
+GdkEvent *
+gdk_event_key_new (GdkEventType type,
+ GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ guint32 time,
+ GdkModifierType state,
+ guint keyval,
+ guint16 keycode,
+ guint16 scancode,
+ guint8 group,
+ gboolean is_modifier)
+{
+ GdkEventKey *event;
- return TRUE;
+ g_return_val_if_fail (type == GDK_KEY_PRESS ||
+ type == GDK_KEY_RELEASE, NULL);
+
+ event = g_new0 (GdkEventKey, 1);
+
+ event->any.ref_count = 1;
+ event->any.type = type;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->time = time;
+ event->state = state;
+ event->keyval = keyval;
+ event->hardware_keycode = keycode;
+ event->key_scancode = scancode;
+ event->group = group;
+ event->is_modifier = is_modifier;
+
+ return (GdkEvent *)event;
}
-/**
- * gdk_events_get_distance:
- * @event1: first #GdkEvent
- * @event2: second #GdkEvent
- * @distance: (out): return location for the distance
- *
- * If both events have X/Y information, the distance between both coordinates
- * (as in a straight line going from @event1 to @event2) will be returned.
- *
- * Returns: %TRUE if the distance could be calculated.
- **/
-gboolean
-gdk_events_get_distance (GdkEvent *event1,
- GdkEvent *event2,
- gdouble *distance)
+GdkEvent *
+gdk_event_configure_new (GdkSurface *surface,
+ int width,
+ int height)
{
- return gdk_events_get_axis_distances (event1, event2,
- NULL, NULL,
- distance);
+ GdkEventConfigure *event = g_new0 (GdkEventConfigure, 1);
+
+ event->any.ref_count = 1;
+ event->any.type = GDK_CONFIGURE;
+ event->any.surface = g_object_ref (surface);
+ event->width = width;
+ event->height = height;
+
+ return (GdkEvent *)event;
}
-/**
- * gdk_events_get_angle:
- * @event1: first #GdkEvent
- * @event2: second #GdkEvent
- * @angle: (out): return location for the relative angle between both events
- *
- * If both events contain X/Y information, this function will return %TRUE
- * and return in @angle the relative angle from @event1 to @event2. The rotation
- * direction for positive angles is from the positive X axis towards the positive
- * Y axis.
- *
- * Returns: %TRUE if the angle could be calculated.
- **/
-gboolean
-gdk_events_get_angle (GdkEvent *event1,
- GdkEvent *event2,
- gdouble *angle)
+GdkEvent *
+gdk_event_delete_new (GdkSurface *surface)
{
- gdouble x_distance, y_distance, distance;
+ GdkEventAny *event = g_new0 (GdkEventAny, 1);
- if (!gdk_events_get_axis_distances (event1, event2,
- &x_distance, &y_distance,
- &distance))
- return FALSE;
+ event->ref_count = 1;
+ event->type = GDK_DELETE;
+ event->surface = g_object_ref (surface);
- if (angle)
- {
- *angle = atan2 (x_distance, y_distance);
-
- /* Invert angle */
- *angle = (2 * G_PI) - *angle;
-
- /* Shift it 90° */
- *angle += G_PI / 2;
-
- /* And constraint it to 0°-360° */
- *angle = fmod (*angle, 2 * G_PI);
- }
-
- return TRUE;
+ return (GdkEvent *)event;
}
-/**
- * gdk_events_get_center:
- * @event1: first #GdkEvent
- * @event2: second #GdkEvent
- * @x: (out): return location for the X coordinate of the center
- * @y: (out): return location for the Y coordinate of the center
- *
- * If both events contain X/Y information, the center of both coordinates
- * will be returned in @x and @y.
- *
- * Returns: %TRUE if the center could be calculated.
- **/
-gboolean
-gdk_events_get_center (GdkEvent *event1,
- GdkEvent *event2,
- gdouble *x,
- gdouble *y)
+GdkEvent *
+gdk_event_focus_new (GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ gboolean focus_in)
{
- gdouble x1, x2, y1, y2;
-
- if (!gdk_event_get_coords (event1, &x1, &y1) ||
- !gdk_event_get_coords (event2, &x2, &y2))
- return FALSE;
-
- if (x)
- *x = (x2 + x1) / 2;
+ GdkEventFocus *event = g_new0 (GdkEventFocus, 1);
- if (y)
- *y = (y2 + y1) / 2;
+ event->any.ref_count = 1;
+ event->any.type = GDK_FOCUS_CHANGE;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->in = focus_in;
- return TRUE;
+ return (GdkEvent *)event;
}
-/**
- * gdk_event_get_display:
- * @event: a #GdkEvent
- *
- * Retrieves the #GdkDisplay associated to the @event.
- *
- * Returns: (transfer none) (nullable): a #GdkDisplay
- */
-GdkDisplay *
-gdk_event_get_display (GdkEvent *event)
+GdkEvent *
+gdk_event_scroll_new (GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ GdkDeviceTool *tool,
+ guint32 time,
+ GdkModifierType state,
+ double delta_x,
+ double delta_y,
+ gboolean is_stop)
{
- if (event->any.display)
- return event->any.display;
+ GdkEventScroll *event = g_new0 (GdkEventScroll, 1);
- if (event->any.surface)
- return gdk_surface_get_display (event->any.surface);
+ event->any.ref_count = 1;
+ event->any.type = GDK_SCROLL;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->tool = tool ? g_object_ref (tool) : NULL;
+ event->time = time;
+ event->state = state;
+ event->x = NAN;
+ event->y = NAN;
+ event->direction = GDK_SCROLL_SMOOTH;
+ event->delta_x = delta_x;
+ event->delta_y = delta_y;
+ event->is_stop = is_stop;
- return NULL;
+ return (GdkEvent *)event;
}
-/**
- * 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: (transfer none): the event sequence that the event belongs to
- */
-GdkEventSequence *
-gdk_event_get_event_sequence (GdkEvent *event)
+GdkEvent *
+gdk_event_discrete_scroll_new (GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ GdkDeviceTool *tool,
+ guint32 time,
+ GdkModifierType state,
+ GdkScrollDirection direction,
+ gboolean emulated)
{
- if (!event)
- return NULL;
-
- if (event->any.type == GDK_TOUCH_BEGIN ||
- event->any.type == GDK_TOUCH_UPDATE ||
- event->any.type == GDK_TOUCH_END ||
- event->any.type == GDK_TOUCH_CANCEL)
- return event->touch.sequence;
-
- return NULL;
-}
+ GdkEventScroll *event = g_new0 (GdkEventScroll, 1);
-/**
- * gdk_set_show_events:
- * @show_events: %TRUE to output event debugging information.
- *
- * Sets whether a trace of received events is output.
- * Note that GTK+ must be compiled with debugging (that is,
- * configured using the `--enable-debug` option)
- * to use this option.
- **/
-void
-gdk_set_show_events (gboolean show_events)
-{
- if (show_events)
- _gdk_debug_flags |= GDK_DEBUG_EVENTS;
- else
- _gdk_debug_flags &= ~GDK_DEBUG_EVENTS;
-}
+ event->any.ref_count = 1;
+ event->any.type = GDK_SCROLL;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->tool = tool ? g_object_ref (tool) : NULL;
+ event->time = time;
+ event->state = state;
+ event->x = NAN;
+ event->y = NAN;
+ event->direction = direction;
+ if (emulated)
+ event->any.flags = GDK_EVENT_POINTER_EMULATED;
-/**
- * gdk_get_show_events:
- *
- * Gets whether event debugging output is enabled.
- *
- * Returns: %TRUE if event debugging output is enabled.
- **/
-gboolean
-gdk_get_show_events (void)
-{
- return (_gdk_debug_flags & GDK_DEBUG_EVENTS) != 0;
+ return (GdkEvent *)event;
}
-static GdkEventSequence *
-gdk_event_sequence_copy (GdkEventSequence *sequence)
+GdkEvent *
+gdk_event_touch_new (GdkEventType type,
+ GdkEventSequence *sequence,
+ GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ guint32 time,
+ GdkModifierType state,
+ double x,
+ double y,
+ double *axes,
+ gboolean emulating)
{
- return sequence;
-}
+ GdkEventTouch *event;
-static void
-gdk_event_sequence_free (GdkEventSequence *sequence)
-{
- /* Nothing to free here */
-}
+ g_return_val_if_fail (type == GDK_TOUCH_BEGIN ||
+ type == GDK_TOUCH_END ||
+ type == GDK_TOUCH_UPDATE ||
+ type == GDK_TOUCH_CANCEL, NULL);
-G_DEFINE_BOXED_TYPE (GdkEventSequence, gdk_event_sequence,
- gdk_event_sequence_copy,
- gdk_event_sequence_free)
+ event = g_new0 (GdkEventTouch, 1);
-/**
- * gdk_event_get_event_type:
- * @event: a #GdkEvent
- *
- * Retrieves the type of the event.
- *
- * Returns: a #GdkEventType
- */
-GdkEventType
-gdk_event_get_event_type (GdkEvent *event)
-{
- g_return_val_if_fail (event != NULL, 0);
+ event->any.ref_count = 1;
+ event->any.type = type;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->sequence = sequence;
+ event->time = time;
+ event->state = state;
+ event->x = x;
+ event->y = y;
+ event->axes = axes;
+ event->emulating_pointer = emulating;
+ if (emulating)
+ event->any.flags = GDK_EVENT_POINTER_EMULATED;
- return event->any.type;
+ return (GdkEvent *)event;
}
-/**
- * gdk_event_get_seat:
- * @event: a #GdkEvent
- *
- * Returns the #GdkSeat this event was generated for.
- *
- * Returns: (transfer none): The #GdkSeat of this event
- **/
-GdkSeat *
-gdk_event_get_seat (GdkEvent *event)
+GdkEvent *
+gdk_event_touchpad_swipe_new (GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ guint32 time,
+ GdkModifierType state,
+ GdkTouchpadGesturePhase phase,
+ double x,
+ double y,
+ int n_fingers,
+ double dx,
+ double dy)
{
- GdkDevice *device;
+ GdkEventTouchpadSwipe *event = g_new0 (GdkEventTouchpadSwipe, 1);
- device = gdk_event_get_device (event);
+ event->any.ref_count = 1;
+ event->any.type = GDK_TOUCHPAD_SWIPE;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->time = time;
+ event->state = state;
+ event->phase = phase;
+ event->x = x;
+ event->y = y;
+ event->dx = dx;
+ event->dy = dy;
+ event->n_fingers = n_fingers;
- return device ? gdk_device_get_seat (device) : NULL;
+ return (GdkEvent *)event;
}
-/**
- * gdk_event_get_device_tool:
- * @event: a #GdkEvent
- *
- * If the event was generated by a device that supports
- * different tools (eg. a tablet), this function will
- * return a #GdkDeviceTool representing the tool that
- * caused the event. Otherwise, %NULL will be returned.
- *
- * Note: the #GdkDeviceTool<!-- -->s will be constant during
- * the application lifetime, if settings must be stored
- * persistently across runs, see gdk_device_tool_get_serial()
- *
- * Returns: (transfer none): The current device tool, or %NULL
- **/
-GdkDeviceTool *
-gdk_event_get_device_tool (GdkEvent *event)
-{
- if (event->any.type == GDK_BUTTON_PRESS ||
- event->any.type == GDK_BUTTON_RELEASE)
- return event->button.tool;
- else if (event->any.type == GDK_MOTION_NOTIFY)
- return event->motion.tool;
- else if (event->any.type == GDK_PROXIMITY_IN ||
- event->any.type == GDK_PROXIMITY_OUT)
- return event->proximity.tool;
- else if (event->any.type == GDK_SCROLL)
- return event->scroll.tool;
+GdkEvent *
+gdk_event_touchpad_pinch_new (GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ guint32 time,
+ GdkModifierType state,
+ GdkTouchpadGesturePhase phase,
+ double x,
+ double y,
+ int n_fingers,
+ double dx,
+ double dy,
+ double scale,
+ double angle_delta)
+{
+ GdkEventTouchpadPinch *event = g_new0 (GdkEventTouchpadPinch, 1);
- return NULL;
+ event->any.ref_count = 1;
+ event->any.type = GDK_TOUCHPAD_PINCH;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->time = time;
+ event->state = state;
+ event->phase = phase;
+ event->x = x;
+ event->y = y;
+ event->dx = dx;
+ event->dy = dy;
+ event->n_fingers = n_fingers;
+ event->scale = scale;
+ event->angle_delta = angle_delta;
+
+ return (GdkEvent *)event;
}
-/**
- * gdk_event_get_scancode:
- * @event: a #GdkEvent
- *
- * Gets the keyboard low-level scancode of a key event.
- *
- * This is usually hardware_keycode. On Windows this is the high
- * word of WM_KEY{DOWN,UP} lParam which contains the scancode and
- * some extended flags.
- *
- * Returns: The associated keyboard scancode or 0
- **/
-int
-gdk_event_get_scancode (GdkEvent *event)
+GdkEvent *
+gdk_event_pad_ring_new (GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ guint32 time,
+ guint group,
+ guint index,
+ guint mode,
+ double value)
{
- if (event->any.type == GDK_KEY_PRESS ||
- event->any.type == GDK_KEY_RELEASE)
- return event->key.key_scancode;
+ GdkEventPadAxis *event = g_new0 (GdkEventPadAxis, 1);
- return 0;
+ event->any.ref_count = 1;
+ event->any.type = GDK_PAD_RING;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->time = time;
+ event->group = group;
+ event->index = index;
+ event->mode = mode;
+ event->value = value;
+
+ return (GdkEvent *)event;
}
-/**
- * gdk_event_is_sent:
- * @event: a #GdkEvent
- *
- * Returns whether the event was sent explicitly.
- *
- * Returns: %TRUE if the event was sent explicitly
- */
-gboolean
-gdk_event_is_sent (GdkEvent *event)
+GdkEvent *
+gdk_event_pad_strip_new (GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ guint32 time,
+ guint group,
+ guint index,
+ guint mode,
+ double value)
{
- if (!event)
- return FALSE;
+ GdkEventPadAxis *event = g_new0 (GdkEventPadAxis, 1);
+
+ event->any.ref_count = 1;
+ event->any.type = GDK_PAD_STRIP;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->time = time;
+ event->group = group;
+ event->index = index;
+ event->mode = mode;
+ event->value = value;
- return event->any.send_event;
+ return (GdkEvent *)event;
}
-/**
- * gdk_event_get_drop:
- * @event: a #GdkEvent
- *
- * Gets the #GdkDrop from a DND event.
- *
- * Returns: (transfer none) (nullable): the drop
- **/
-GdkDrop *
-gdk_event_get_drop (GdkEvent *event)
+GdkEvent *
+gdk_event_pad_button_new (GdkEventType type,
+ GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ guint32 time,
+ guint group,
+ guint button,
+ guint mode)
{
- if (!event)
- return FALSE;
+ GdkEventPadButton *event;
- if (event->any.type == GDK_DRAG_ENTER ||
- event->any.type == GDK_DRAG_LEAVE ||
- event->any.type == GDK_DRAG_MOTION ||
- event->any.type == GDK_DROP_START)
- {
- return event->dnd.drop;
- }
+ g_return_val_if_fail (type == GDK_PAD_BUTTON_PRESS ||
+ type == GDK_PAD_BUTTON_RELEASE, NULL);
- return NULL;
+ event = g_new0 (GdkEventPadButton, 1);
+
+ event->any.ref_count = 1;
+ event->any.type = type;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->time = time;
+ event->group = group;
+ event->button = button;
+ event->mode = mode;
+
+ return (GdkEvent *)event;
}
-/**
- * gdk_event_get_crossing_mode:
- * @event: a #GdkEvent
- * @mode: (out): return location for the crossing mode
- *
- * Extracts the crossing mode from an event.
- *
- * Returns: %TRUE on success, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_crossing_mode (GdkEvent *event,
- GdkCrossingMode *mode)
+GdkEvent *
+gdk_event_pad_group_mode_new (GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ guint32 time,
+ guint group,
+ guint mode)
{
- if (!event)
- return FALSE;
+ GdkEventPadGroupMode *event = g_new0 (GdkEventPadGroupMode, 1);
- if (event->any.type == GDK_ENTER_NOTIFY ||
- event->any.type == GDK_LEAVE_NOTIFY)
- {
- *mode = event->crossing.mode;
- return TRUE;
- }
- else if (event->any.type == GDK_FOCUS_CHANGE)
- {
- *mode = event->focus_change.mode;
- return TRUE;
- }
+ event->any.ref_count = 1;
+ event->any.type = GDK_PAD_GROUP_MODE;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->time = time;
+ event->group = group;
+ event->mode = mode;
- return FALSE;
+ return (GdkEvent *)event;
}
-/**
- * gdk_event_get_crossing_detail:
- * @event: a #GdkEvent
- * @detail: (out): return location for the crossing detail
- *
- * Extracts the crossing detail from an event.
- *
- * Returns: %TRUE on success, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_crossing_detail (GdkEvent *event,
- GdkNotifyType *detail)
+GdkEvent *
+gdk_event_drag_new (GdkEventType type,
+ GdkSurface *surface,
+ GdkDevice *device,
+ GdkDrop *drop,
+ guint32 time,
+ double x,
+ double y)
{
- if (!event)
- return FALSE;
+ GdkEventDND *event;
- if (event->any.type == GDK_ENTER_NOTIFY ||
- event->any.type == GDK_LEAVE_NOTIFY)
- {
- *detail = event->crossing.detail;
- return TRUE;
- }
- else if (event->any.type == GDK_FOCUS_CHANGE)
- {
- *detail = event->focus_change.detail;
- return TRUE;
- }
+ g_return_val_if_fail (type == GDK_DRAG_ENTER ||
+ type == GDK_DRAG_MOTION ||
+ type == GDK_DRAG_LEAVE ||
+ type == GDK_DROP_START, NULL);
- return FALSE;
+ event = g_new0 (GdkEventDND, 1);
+
+ event->any.ref_count = 1;
+ event->any.type = type;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->drop = g_object_ref (drop);
+ event->time = time;
+ event->x = x;
+ event->y = y;
+
+ return (GdkEvent *)event;
}
-/**
- * gdk_event_get_touchpad_gesture_phase:
- * @event: a #GdkEvent
- * @phase: (out): Return location for the gesture phase
- *
- * Extracts the touchpad gesture phase from a touchpad event.
- *
- * Returns: %TRUE on success, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_touchpad_gesture_phase (GdkEvent *event,
- GdkTouchpadGesturePhase *phase)
+GdkEvent *
+gdk_event_grab_broken_new (GdkSurface *surface,
+ GdkDevice *device,
+ GdkDevice *source_device,
+ GdkSurface *grab_surface,
+ gboolean implicit)
{
- if (!event)
- return FALSE;
+ GdkEventGrabBroken *event = g_new0 (GdkEventGrabBroken, 1);
- if (event->any.type == GDK_TOUCHPAD_PINCH)
- {
- *phase = event->touchpad_pinch.phase;
- return TRUE;
- }
- else if (event->any.type == GDK_TOUCHPAD_SWIPE)
- {
- *phase = event->touchpad_swipe.phase;
- return TRUE;
- }
+ event->any.ref_count = 1;
+ event->any.type = GDK_GRAB_BROKEN;
+ event->any.surface = g_object_ref (surface);
+ event->any.device = g_object_ref (device);
+ event->any.source_device = g_object_ref (source_device);
+ event->grab_surface = grab_surface;
+ event->implicit = implicit;
+ event->keyboard = gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD;
- return FALSE;
+ return (GdkEvent *)event;
}
/**
- * gdk_event_get_touchpad_gesture_n_fingers:
+ * gdk_event_get_event_type:
* @event: a #GdkEvent
- * @n_fingers: (out): return location for the number of fingers
*
- * Extracts the number of fingers from a touchpad event.
+ * Retrieves the type of the event.
*
- * Returns: %TRUE on success, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_touchpad_gesture_n_fingers (GdkEvent *event,
- guint *n_fingers)
-{
- if (!event)
- return FALSE;
-
- if (event->any.type == GDK_TOUCHPAD_PINCH)
- {
- *n_fingers = event->touchpad_pinch.n_fingers;
- return TRUE;
- }
- else if (event->any.type == GDK_TOUCHPAD_SWIPE)
- {
- *n_fingers = event->touchpad_swipe.n_fingers;
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- * gdk_event_get_touchpad_deltas:
- * @event: a #GdkEvent
- * @dx: (out): return location for x
- * @dy: (out): return location for y
- *
- * Extracts delta information from a touchpad event.
- *
- * Returns: %TRUE on success, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_touchpad_deltas (GdkEvent *event,
- double *dx,
- double *dy)
+ * Returns: a #GdkEventType
+ */
+GdkEventType
+gdk_event_get_event_type (GdkEvent *event)
{
- if (!event)
- return FALSE;
-
- if (event->any.type == GDK_TOUCHPAD_PINCH)
- {
- *dx = event->touchpad_pinch.dx;
- *dy = event->touchpad_pinch.dy;
- return TRUE;
- }
- else if (event->any.type == GDK_TOUCHPAD_SWIPE)
- {
- *dx = event->touchpad_swipe.dx;
- *dy = event->touchpad_swipe.dy;
- return TRUE;
- }
-
- return FALSE;
+ return event->any.type;
}
/**
- * gdk_event_get_touchpad_angle_delta:
+ * gdk_event_get_surface:
* @event: a #GdkEvent
- * @delta: (out): Return location for angle
*
- * Extracts the angle from a touchpad event.
+ * Extracts the #GdkSurface associated with an event.
*
- * Returns: %TRUE on success, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_touchpad_angle_delta (GdkEvent *event,
- double *delta)
+ * Returns: (transfer none): The #GdkSurface associated with the event
+ */
+GdkSurface *
+gdk_event_get_surface (GdkEvent *event)
{
- if (!event)
- return FALSE;
-
- if (event->any.type == GDK_TOUCHPAD_PINCH)
- {
- *delta = event->touchpad_pinch.angle_delta;
- return TRUE;
- }
-
- return FALSE;
+ return event->any.surface;
}
/**
- * gdk_event_get_touchpad_scale:
- * @event: a #GdkEvent
- * @scale: (out): Return location for scale
+ * gdk_event_get_device:
+ * @event: a #GdkEvent.
*
- * Extracts the scale from a touchpad event.
+ * Returns the device of an event.
*
- * Returns: %TRUE on success, otherwise %FALSE
+ * Returns: (nullable) (transfer none): a #GdkDevice, or %NULL.
**/
-gboolean
-gdk_event_get_touchpad_scale (GdkEvent *event,
- double *scale)
+GdkDevice *
+gdk_event_get_device (GdkEvent *event)
{
- if (!event)
- return FALSE;
-
- if (event->any.type == GDK_TOUCHPAD_PINCH)
- {
- *scale = event->touchpad_pinch.scale;
- return TRUE;
- }
-
- return FALSE;
+ return event->any.device;
}
/**
- * gdk_event_get_touch_emulating_pointer:
+ * gdk_event_get_source_device:
* @event: a #GdkEvent
- * @emulating: (out): Return location for information
*
- * Extracts whether a touch event is emulating a pointer event.
+ * This function returns the hardware (slave) #GdkDevice that has
+ * triggered the event, falling back to the virtual (master) device
+ * (as in gdk_event_get_device()) if the event wasn’t caused by
+ * interaction with a hardware device. This may happen for example
+ * in synthesized crossing events after a #GdkSurface updates its
+ * geometry or a grab is acquired/released.
*
- * Returns: %TRUE on success, otherwise %FALSE
+ * If the event does not contain a device field, this function will
+ * return %NULL.
+ *
+ * Returns: (nullable) (transfer none): a #GdkDevice, or %NULL.
**/
-gboolean
-gdk_event_get_touch_emulating_pointer (GdkEvent *event,
- gboolean *emulating)
+GdkDevice *
+gdk_event_get_source_device (GdkEvent *event)
{
- if (!event)
- return FALSE;
-
- if (event->any.type == GDK_TOUCH_BEGIN ||
- event->any.type == GDK_TOUCH_UPDATE ||
- event->any.type == GDK_TOUCH_END)
- {
- *emulating = event->touch.emulating_pointer;
- return TRUE;
- }
+ if (event->any.source_device)
+ return event->any.source_device;
- return FALSE;
+ return event->any.device;
}
/**
- * gdk_event_get_grab_surface:
+ * gdk_event_get_device_tool:
* @event: a #GdkEvent
- * @surface: (out) (transfer none): Return location for the grab surface
*
- * Extracts the grab surface from a grab broken event.
+ * If the event was generated by a device that supports
+ * different tools (eg. a tablet), this function will
+ * return a #GdkDeviceTool representing the tool that
+ * caused the event. Otherwise, %NULL will be returned.
*
- * Returns: %TRUE on success, otherwise %FALSE
+ * Note: the #GdkDeviceTools will be constant during
+ * the application lifetime, if settings must be stored
+ * persistently across runs, see gdk_device_tool_get_serial()
+ *
+ * Returns: (transfer none): The current device tool, or %NULL
**/
-gboolean
-gdk_event_get_grab_surface (GdkEvent *event,
- GdkSurface **surface)
+GdkDeviceTool *
+gdk_event_get_device_tool (GdkEvent *event)
{
- if (!event)
- return FALSE;
-
- if (event->any.type == GDK_GRAB_BROKEN)
- {
- *surface = event->grab_broken.grab_surface;
- return TRUE;
- }
+ if (event->any.type == GDK_BUTTON_PRESS ||
+ event->any.type == GDK_BUTTON_RELEASE)
+ return event->button.tool;
+ else if (event->any.type == GDK_MOTION_NOTIFY)
+ return event->motion.tool;
+ else if (event->any.type == GDK_PROXIMITY_IN ||
+ event->any.type == GDK_PROXIMITY_OUT)
+ return event->proximity.tool;
+ else if (event->any.type == GDK_SCROLL)
+ return event->scroll.tool;
- return FALSE;
+ return NULL;
}
/**
- * gdk_event_get_focus_in:
+ * gdk_event_get_time:
* @event: a #GdkEvent
- * @focus_in: (out): return location for focus direction
- *
- * Extracts whether this is a focus-in or focus-out event.
- *
- * Returns: %TRUE on success, otherwise %FALSE
+ *
+ * Returns the time stamp from @event, if there is one; otherwise
+ * returns #GDK_CURRENT_TIME.
+ *
+ * Returns: time stamp field from @event
**/
-gboolean
-gdk_event_get_focus_in (GdkEvent *event,
- gboolean *focus_in)
+guint32
+gdk_event_get_time (GdkEvent *event)
{
- if (!event)
- return FALSE;
-
- if (event->any.type == GDK_FOCUS_CHANGE)
+ switch (event->any.type)
{
- *focus_in = event->focus_change.in;
- return TRUE;
+ case GDK_MOTION_NOTIFY:
+ return event->motion.time;
+ case GDK_BUTTON_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_TOUCHPAD_SWIPE:
+ return event->touchpad_swipe.time;
+ case GDK_TOUCHPAD_PINCH:
+ return event->touchpad_pinch.time;
+ case GDK_SCROLL:
+ return event->scroll.time;
+ case GDK_KEY_PRESS:
+ case GDK_KEY_RELEASE:
+ return event->key.time;
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ return event->crossing.time;
+ case GDK_PROXIMITY_IN:
+ case GDK_PROXIMITY_OUT:
+ return event->proximity.time;
+ case GDK_DRAG_ENTER:
+ case GDK_DRAG_LEAVE:
+ case GDK_DRAG_MOTION:
+ case GDK_DROP_START:
+ return event->dnd.time;
+ case GDK_PAD_BUTTON_PRESS:
+ case GDK_PAD_BUTTON_RELEASE:
+ return event->pad_button.time;
+ case GDK_PAD_RING:
+ case GDK_PAD_STRIP:
+ return event->pad_axis.time;
+ case GDK_PAD_GROUP_MODE:
+ return event->pad_group_mode.time;
+ case GDK_CONFIGURE:
+ case GDK_FOCUS_CHANGE:
+ case GDK_DELETE:
+ case GDK_GRAB_BROKEN:
+ case GDK_EVENT_LAST:
+ default:
+ /* return current time */
+ break;
}
-
- return FALSE;
+
+ return GDK_CURRENT_TIME;
}
/**
- * gdk_event_get_pad_group_mode:
+ * gdk_event_get_display:
* @event: a #GdkEvent
- * @group: (out): return location for the group
- * @mode: (out): return location for the mode
*
- * Extracts group and mode information from a pad event.
+ * Retrieves the #GdkDisplay associated to the @event.
*
- * Returns: %TRUE on success, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_pad_group_mode (GdkEvent *event,
- guint *group,
- guint *mode)
+ * Returns: (transfer none) (nullable): a #GdkDisplay
+ */
+GdkDisplay *
+gdk_event_get_display (GdkEvent *event)
{
- if (!event)
- return FALSE;
-
- if (event->any.type == GDK_PAD_GROUP_MODE)
- {
- *group = event->pad_group_mode.group;
- *mode = event->pad_group_mode.mode;
- return TRUE;
- }
- else if (event->any.type == GDK_PAD_BUTTON_PRESS ||
- event->any.type == GDK_PAD_BUTTON_RELEASE)
- {
- *group = event->pad_button.group;
- *mode = event->pad_button.mode;
- return TRUE;
- }
- else if (event->any.type == GDK_PAD_RING ||
- event->any.type == GDK_PAD_STRIP)
- {
- *group = event->pad_axis.group;
- *mode = event->pad_axis.mode;
- return TRUE;
- }
+ if (event->any.surface)
+ return gdk_surface_get_display (event->any.surface);
- return FALSE;
+ return NULL;
}
/**
- * gdk_event_get_pad_button:
+ * gdk_event_get_event_sequence:
* @event: a #GdkEvent
- * @button: (out): Return location for the button
*
- * Extracts information about the pressed button from
- * a pad event.
+ * If @event is a touch event, returns the #GdkEventSequence
+ * to which the event belongs. Otherwise, return %NULL.
*
- * Returns: %TRUE on success, otherwise %FALSE
- **/
-gboolean
-gdk_event_get_pad_button (GdkEvent *event,
- guint *button)
+ * Returns: (transfer none): the event sequence that the event belongs to
+ */
+GdkEventSequence *
+gdk_event_get_event_sequence (GdkEvent *event)
{
- if (!event)
- return FALSE;
-
- if (event->any.type == GDK_PAD_BUTTON_PRESS ||
- event->any.type == GDK_PAD_BUTTON_RELEASE)
- {
- *button = event->pad_button.button;
- return TRUE;
- }
+ if (event->any.type == GDK_TOUCH_BEGIN ||
+ event->any.type == GDK_TOUCH_UPDATE ||
+ event->any.type == GDK_TOUCH_END ||
+ event->any.type == GDK_TOUCH_CANCEL)
+ return event->touch.sequence;
- return FALSE;
+ return NULL;
}
/**
- * gdk_event_get_pad_axis_value:
+ * gdk_event_get_modifier_state:
* @event: a #GdkEvent
- * @index: (out): Return location for the axis index
- * @value: (out): Return location for the axis value
*
- * Extracts the information from a pad event.
+ * Returns the modifier state field of an event.
*
- * Returns: %TRUE on success, otherwise %FALSE
+ * Returns: the modifier state of @event
**/
-gboolean
-gdk_event_get_pad_axis_value (GdkEvent *event,
- guint *index,
- gdouble *value)
-{
- if (!event)
- return FALSE;
-
- if (event->any.type == GDK_PAD_RING ||
- event->any.type == GDK_PAD_STRIP)
+GdkModifierType
+gdk_event_get_modifier_state (GdkEvent *event)
+{
+#if 0
+ g_return_val_if_fail (event->any.type == GDK_ENTER_NOTIFY ||
+ event->any.type == GDK_LEAVE_NOTIFY ||
+ event->any.type == GDK_BUTTON_PRESS ||
+ event->any.type == GDK_BUTTON_RELEASE ||
+ event->any.type == GDK_MOTION_NOTIFY ||
+ event->any.type == GDK_TOUCH_BEGIN ||
+ event->any.type == GDK_TOUCH_UPDATE ||
+ event->any.type == GDK_TOUCH_END ||
+ event->any.type == GDK_TOUCH_CANCEL ||
+ event->any.type == GDK_TOUCHPAD_SWIPE ||
+ event->any.type == GDK_TOUCHPAD_PINCH||
+ event->any.type == GDK_SCROLL ||
+ event->any.type == GDK_KEY_PRESS ||
+ event->any.type == GDK_KEY_RELEASE, 0);
+#endif
+
+ switch ((int)event->any.type)
{
- *index = event->pad_axis.index;
- *value = event->pad_axis.value;
- return TRUE;
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ return event->crossing.state;
+ case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ return event->button.state;
+ case GDK_MOTION_NOTIFY:
+ return event->motion.state;
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ return event->touch.state;
+ case GDK_TOUCHPAD_SWIPE:
+ return event->touchpad_swipe.state;
+ case GDK_TOUCHPAD_PINCH:
+ return event->touchpad_pinch.state;
+ case GDK_SCROLL:
+ return event->scroll.state;
+ case GDK_KEY_PRESS:
+ case GDK_KEY_RELEASE:
+ return event->key.state;
+ default:
+ /* no state field */
+ break;
}
- return FALSE;
+ return 0;
}
/**
- * gdk_event_get_axes:
+ * gdk_event_get_position:
* @event: a #GdkEvent
- * @axes: (transfer none) (out) (array length=n_axes): the array of values for all axes
- * @n_axes: (out): the length of array
+ * @x_win: (out): location to put event surface x coordinate
+ * @y_win: (out): location to put event surface y coordinate
*
- * Extracts all axis values from an event.
- *
- * Returns: %TRUE on success, otherwise %FALSE
+ * Extract the event surface relative x/y coordinates from an event.
**/
gboolean
-gdk_event_get_axes (GdkEvent *event,
- gdouble **axes,
- guint *n_axes)
-{
- GdkDevice *source_device;
-
- if (!event)
- return FALSE;
-
- source_device = gdk_event_get_source_device (event);
-
- if (!source_device)
- return FALSE;
-
- if (event->any.type == GDK_MOTION_NOTIFY)
+gdk_event_get_position (GdkEvent *event,
+ double *x,
+ double *y)
+{
+#if 0
+ g_return_if_fail (event->any.type == GDK_ENTER_NOTIFY ||
+ event->any.type == GDK_LEAVE_NOTIFY ||
+ event->any.type == GDK_BUTTON_PRESS ||
+ event->any.type == GDK_BUTTON_RELEASE ||
+ event->any.type == GDK_MOTION_NOTIFY ||
+ event->any.type == GDK_TOUCH_BEGIN ||
+ event->any.type == GDK_TOUCH_UPDATE ||
+ event->any.type == GDK_TOUCH_END ||
+ event->any.type == GDK_TOUCH_CANCEL ||
+ event->any.type == GDK_TOUCHPAD_SWIPE ||
+ event->any.type == GDK_TOUCHPAD_PINCH||
+ event->any.type == GDK_DRAG_ENTER ||
+ event->any.type == GDK_DRAG_LEAVE ||
+ event->any.type == GDK_DRAG_MOTION ||
+ event->any.type == GDK_DROP_START);
+#endif
+
+ switch ((int)event->any.type)
{
- *axes = event->motion.axes;
- *n_axes = gdk_device_get_n_axes (source_device);
- return TRUE;
- }
- else if (event->any.type == GDK_BUTTON_PRESS ||
- event->any.type == GDK_BUTTON_RELEASE)
- {
- *axes = event->button.axes;
- *n_axes = gdk_device_get_n_axes (source_device);
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- * gdk_event_get_motion_history:
- * @event: a #GdkEvent of type %GDK_MOTION_NOTIFY
- *
- * Retrieves the history of the @event motion, as a list of time and
- * coordinates.
- *
- * Returns: (transfer container) (element-type GdkTimeCoord) (nullable): a list
- * of time and coordinates
- */
-GList *
-gdk_event_get_motion_history (GdkEvent *event)
-{
- if (event->any.type != GDK_MOTION_NOTIFY)
- return NULL;
- return g_list_reverse (g_list_copy (event->motion.history));
-}
-
-GdkEvent *
-gdk_event_button_new (GdkEventType type,
- GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- GdkDeviceTool *tool,
- guint32 time,
- GdkModifierType state,
- guint button,
- double x,
- double y,
- double *axes)
-{
- GdkEventButton *event;
-
- g_return_val_if_fail (type == GDK_BUTTON_PRESS ||
- type == GDK_BUTTON_RELEASE, NULL);
-
- event = g_new0 (GdkEventButton, 1);
- event->any.ref_count = 1;
- event->any.type = type;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->tool = tool ? g_object_ref (tool) : NULL;
- event->time = time;
- event->axes = NULL;
- event->state = state;
- event->button = button;
- event->x = x;
- event->y = y;
- event->axes = axes;
-
- return (GdkEvent *)event;
-}
-
-GdkEvent *
-gdk_event_motion_new (GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- GdkDeviceTool *tool,
- guint32 time,
- GdkModifierType state,
- double x,
- double y,
- double *axes)
-{
- GdkEventMotion *event = g_new0 (GdkEventMotion, 1);
-
- event->any.ref_count = 1;
- event->any.type = GDK_MOTION_NOTIFY;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->tool = tool ? g_object_ref (tool) : NULL;
- event->time = time;
- event->state = state;
- event->x = x;
- event->y = y;
- event->axes = axes;
- event->state = state;
-
- return (GdkEvent *)event;
-}
-
-GdkEvent *
-gdk_event_crossing_new (GdkEventType type,
- GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- guint32 time,
- GdkModifierType state,
- double x,
- double y,
- GdkCrossingMode mode,
- GdkNotifyType detail)
-{
- GdkEventCrossing *event;
-
- g_return_val_if_fail (type == GDK_ENTER_NOTIFY ||
- type == GDK_LEAVE_NOTIFY, NULL);
-
- event = g_new0 (GdkEventCrossing, 1);
-
- event->any.ref_count = 1;
- event->any.type = type;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->time = time;
- event->state = state;
- event->x = x;
- event->y = y;
- event->mode = mode;
- event->detail = detail;
-
- return (GdkEvent *)event;
-}
-
-GdkEvent *
-gdk_event_proximity_new (GdkEventType type,
- GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- GdkDeviceTool *tool,
- guint32 time)
-{
- GdkEventProximity *event;
-
- g_return_val_if_fail (type == GDK_PROXIMITY_IN ||
- type == GDK_PROXIMITY_OUT, NULL);
-
- event = g_new0 (GdkEventProximity, 1);
-
- event->any.ref_count = 1;
- event->any.type = type;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->tool = tool ? g_object_ref (tool) : NULL;
- event->time = time;
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ *x = event->crossing.x;
+ *y = event->crossing.y;
+ break;
+ case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ *x = event->button.x;
+ *y = event->button.y;
+ break;
+ case GDK_MOTION_NOTIFY:
+ *x = event->motion.x;
+ *y = event->motion.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_TOUCHPAD_SWIPE:
+ *x = event->touchpad_swipe.x;
+ *y = event->touchpad_swipe.y;
+ break;
+ case GDK_TOUCHPAD_PINCH:
+ *x = event->touchpad_pinch.x;
+ *y = event->touchpad_pinch.y;
+ break;
+ case GDK_DRAG_ENTER:
+ case GDK_DRAG_LEAVE:
+ case GDK_DRAG_MOTION:
+ case GDK_DROP_START:
+ *x = event->dnd.x;
+ *y = event->dnd.y;
+ break;
+ default:
+ /* no position */
+ *x = NAN;
+ *y = NAN;
+ return FALSE;
+ }
- return (GdkEvent *)event;
+ return TRUE;
}
-GdkEvent *
-gdk_event_key_new (GdkEventType type,
- GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- guint32 time,
- GdkModifierType state,
- guint keyval,
- guint16 keycode,
- guint16 scancode,
- guint8 group,
- gboolean is_modifier)
+/**
+ * gdk_button_event_get_button:
+ * @event: a button event
+ *
+ * Extract the button number from a button event.
+ *
+ * Returns: the button of @event
+ **/
+guint
+gdk_button_event_get_button (GdkEvent *event)
{
- GdkEventKey *event;
-
- g_return_val_if_fail (type == GDK_KEY_PRESS ||
- type == GDK_KEY_RELEASE, NULL);
-
- event = g_new0 (GdkEventKey, 1);
+ g_return_val_if_fail (event->any.type == GDK_BUTTON_PRESS ||
+ event->any.type == GDK_BUTTON_RELEASE, 0);
- event->any.ref_count = 1;
- event->any.type = type;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->time = time;
- event->state = state;
- event->keyval = keyval;
- event->hardware_keycode = keycode;
- event->key_scancode = scancode;
- event->group = group;
- event->is_modifier = is_modifier;
-
- return (GdkEvent *)event;
+ return event->button.button;
}
-GdkEvent *
-gdk_event_configure_new (GdkSurface *surface,
- int width,
- int height)
+/**
+ * gdk_key_event_get_keyval:
+ * @event: a key event
+ *
+ * Extracts the keyval from a key event.
+ *
+ * Returns: the keyval of @event
+ */
+guint
+gdk_key_event_get_keyval (GdkEvent *event)
{
- GdkEventConfigure *event = g_new0 (GdkEventConfigure, 1);
+ g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
+ event->any.type == GDK_KEY_RELEASE, 0);
- event->any.ref_count = 1;
- event->any.type = GDK_CONFIGURE;
- event->any.surface = g_object_ref (surface);
- event->width = width;
- event->height = height;
-
- return (GdkEvent *)event;
+ return event->key.keyval;
}
-GdkEvent *
-gdk_event_delete_new (GdkSurface *surface)
+/**
+ * gdk_key_event_get_keycode:
+ * @event: a key event
+ *
+ * Extracts the keycode from a key event.
+ *
+ * Returns: the keycode of @event
+ */
+guint
+gdk_key_event_get_keycode (GdkEvent *event)
{
- GdkEventAny *event = g_new0 (GdkEventAny, 1);
-
- event->ref_count = 1;
- event->type = GDK_DELETE;
- event->surface = g_object_ref (surface);
+ g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
+ event->any.type == GDK_KEY_RELEASE, 0);
- return (GdkEvent *)event;
+ return event->key.hardware_keycode;
}
-GdkEvent *
-gdk_event_focus_new (GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- gboolean focus_in)
+/**
+ * gdk_key_event_get_scancode:
+ * @event: a key event
+ *
+ * Extracts the scancode from a key event.
+ *
+ * Returns: the scancode of @event
+ */
+guint
+gdk_key_event_get_scancode (GdkEvent *event)
{
- GdkEventFocus *event = g_new0 (GdkEventFocus, 1);
-
- event->any.ref_count = 1;
- event->any.type = GDK_FOCUS_CHANGE;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->in = focus_in;
+ g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
+ event->any.type == GDK_KEY_RELEASE, 0);
- return (GdkEvent *)event;
+ return event->key.key_scancode;
}
-GdkEvent *
-gdk_event_scroll_new (GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- GdkDeviceTool *tool,
- guint32 time,
- GdkModifierType state,
- double delta_x,
- double delta_y,
- gboolean is_stop)
+/**
+ * gdk_key_event_get_group:
+ * @event: a key event
+ *
+ * Extracts the group from a key event.
+ *
+ * Returns: the group of @event
+ */
+guint
+gdk_key_event_get_group (GdkEvent *event)
{
- GdkEventScroll *event = g_new0 (GdkEventScroll, 1);
-
- event->any.ref_count = 1;
- event->any.type = GDK_SCROLL;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->tool = tool ? g_object_ref (tool) : NULL;
- event->time = time;
- event->state = state;
- event->x = NAN;
- event->y = NAN;
- event->direction = GDK_SCROLL_SMOOTH;
- event->delta_x = delta_x;
- event->delta_y = delta_y;
- event->is_stop = is_stop;
+ g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
+ event->any.type == GDK_KEY_RELEASE, 0);
- return (GdkEvent *)event;
+ return event->key.group;
}
-GdkEvent *
-gdk_event_discrete_scroll_new (GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- GdkDeviceTool *tool,
- guint32 time,
- GdkModifierType state,
- GdkScrollDirection direction,
- gboolean emulated)
+/**
+ * gdk_key_event_is_modifier:
+ * @event: a key event
+ *
+ * Extracts whether the key event is for a modifier key.
+ *
+ * Returns: %TRUE if the @event is for a modifier key
+ */
+gboolean
+gdk_key_event_is_modifier (GdkEvent *event)
{
- GdkEventScroll *event = g_new0 (GdkEventScroll, 1);
-
- event->any.ref_count = 1;
- event->any.type = GDK_SCROLL;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->tool = tool ? g_object_ref (tool) : NULL;
- event->time = time;
- event->state = state;
- event->x = NAN;
- event->y = NAN;
- event->direction = direction;
- if (emulated)
- event->any.flags = GDK_EVENT_POINTER_EMULATED;
+ g_return_val_if_fail (event->any.type == GDK_KEY_PRESS ||
+ event->any.type == GDK_KEY_RELEASE, FALSE);
- return (GdkEvent *)event;
+ return event->key.is_modifier;
}
-GdkEvent *
-gdk_event_touch_new (GdkEventType type,
- GdkEventSequence *sequence,
- GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- guint32 time,
- GdkModifierType state,
- double x,
- double y,
- double *axes,
- gboolean emulating)
+void
+gdk_configure_event_get_size (GdkEvent *event,
+ int *width,
+ int *height)
{
- GdkEventTouch *event;
+ g_return_if_fail (event->any.type == GDK_CONFIGURE);
- g_return_val_if_fail (type == GDK_TOUCH_BEGIN ||
- type == GDK_TOUCH_END ||
- type == GDK_TOUCH_UPDATE ||
- type == GDK_TOUCH_CANCEL, NULL);
-
- event = g_new0 (GdkEventTouch, 1);
-
- event->any.ref_count = 1;
- event->any.type = type;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->sequence = sequence;
- event->time = time;
- event->state = state;
- event->x = x;
- event->y = y;
- event->axes = axes;
- event->emulating_pointer = emulating;
- if (emulating)
- event->any.flags = GDK_EVENT_POINTER_EMULATED;
-
- return (GdkEvent *)event;
+ *width = event->configure.width;
+ *height = event->configure.height;
}
-GdkEvent *
-gdk_event_touchpad_swipe_new (GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- guint32 time,
- GdkModifierType state,
- GdkTouchpadGesturePhase phase,
- double x,
- double y,
- int n_fingers,
- double dx,
- double dy)
+/**
+ * gdk_touch_event_get_emulating_pointer:
+ * @event: a touch event
+ *
+ * Extracts whether a touch event is emulating a pointer event.
+ *
+ * Returns: %TRUE if @event is emulating
+ **/
+gboolean
+gdk_touch_event_get_emulating_pointer (GdkEvent *event)
{
- GdkEventTouchpadSwipe *event = g_new0 (GdkEventTouchpadSwipe, 1);
-
- event->any.ref_count = 1;
- event->any.type = GDK_TOUCHPAD_SWIPE;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->time = time;
- event->state = state;
- event->phase = phase;
- event->x = x;
- event->y = y;
- event->dx = dx;
- event->dy = dy;
- event->n_fingers = n_fingers;
+ g_return_val_if_fail (event->any.type == GDK_TOUCH_BEGIN ||
+ event->any.type == GDK_TOUCH_UPDATE ||
+ event->any.type == GDK_TOUCH_END ||
+ event->any.type == GDK_TOUCH_CANCEL, FALSE);
- return (GdkEvent *)event;
+ return event->touch.emulating_pointer;
}
-GdkEvent *
-gdk_event_touchpad_pinch_new (GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- guint32 time,
- GdkModifierType state,
- GdkTouchpadGesturePhase phase,
- double x,
- double y,
- int n_fingers,
- double dx,
- double dy,
- double scale,
- double angle_delta)
+/**
+ * gdk_crossing_event_get_mode:
+ * @event: a crossing event
+ *
+ * Extracts the crossing mode from a crossing event.
+ *
+ * Returns: the mode of @event
+ */
+GdkCrossingMode
+gdk_crossing_event_get_mode (GdkEvent *event)
{
- GdkEventTouchpadPinch *event = g_new0 (GdkEventTouchpadPinch, 1);
+ g_return_val_if_fail (event->any.type == GDK_ENTER_NOTIFY ||
+ event->any.type == GDK_LEAVE_NOTIFY, 0);
- event->any.ref_count = 1;
- event->any.type = GDK_TOUCHPAD_PINCH;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->time = time;
- event->state = state;
- event->phase = phase;
- event->x = x;
- event->y = y;
- event->dx = dx;
- event->dy = dy;
- event->n_fingers = n_fingers;
- event->scale = scale;
- event->angle_delta = angle_delta;
+ return event->crossing.mode;
+}
+
+/**
+ * gdk_crossing_event_get_detail:
+ * @event: a crossing event
+ *
+ * Extracts the notify detail from a crossing event.
+ *
+ * Returns: the notify detail of @event
+ */
+GdkNotifyType
+gdk_crossing_event_get_detail (GdkEvent *event)
+{
+ g_return_val_if_fail (event->any.type == GDK_ENTER_NOTIFY ||
+ event->any.type == GDK_LEAVE_NOTIFY, 0);
- return (GdkEvent *)event;
+ return event->crossing.detail;
}
-GdkEvent *
-gdk_event_pad_ring_new (GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- guint32 time,
- guint group,
- guint index,
- guint mode,
- double value)
+gboolean
+gdk_focus_event_get_in (GdkEvent *event)
{
- GdkEventPadAxis *event = g_new0 (GdkEventPadAxis, 1);
+ g_return_val_if_fail (event->any.type == GDK_FOCUS_CHANGE, FALSE);
- event->any.ref_count = 1;
- event->any.type = GDK_PAD_RING;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->time = time;
- event->group = group;
- event->index = index;
- event->mode = mode;
- event->value = value;
+ return event->focus_change.in;
+}
- return (GdkEvent *)event;
+GdkScrollDirection
+gdk_scroll_event_get_direction (GdkEvent *event)
+{
+ g_return_val_if_fail (event->any.type == GDK_SCROLL, 0);
+
+ return event->scroll.direction;
}
-GdkEvent *
-gdk_event_pad_strip_new (GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- guint32 time,
- guint group,
- guint index,
- guint mode,
- double value)
+void
+gdk_scroll_event_get_deltas (GdkEvent *event,
+ double *delta_x,
+ double *delta_y)
{
- GdkEventPadAxis *event = g_new0 (GdkEventPadAxis, 1);
+ g_return_if_fail (event->any.type == GDK_SCROLL);
- event->any.ref_count = 1;
- event->any.type = GDK_PAD_STRIP;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->time = time;
- event->group = group;
- event->index = index;
- event->mode = mode;
- event->value = value;
+ *delta_x = event->scroll.delta_x;
+ *delta_y = event->scroll.delta_y;
+}
- return (GdkEvent *)event;
+/**
+ * gdk_scroll_event_is_stop:
+ * @event: a scroll event
+ *
+ * Check whether a scroll event is a stop scroll event. Scroll sequences
+ * with smooth scroll information may provide a stop scroll event once the
+ * interaction with the device finishes, e.g. by lifting a finger. This
+ * stop scroll event is the signal that a widget may trigger kinetic
+ * scrolling based on the current velocity.
+ *
+ * Stop scroll events always have a delta of 0/0.
+ *
+ * Returns: %TRUE if the event is a scroll stop event
+ */
+gboolean
+gdk_scroll_event_is_stop (GdkEvent *event)
+{
+ g_return_val_if_fail (event->any.type == GDK_SCROLL, FALSE);
+
+ return event->scroll.is_stop;
}
-GdkEvent *
-gdk_event_pad_button_new (GdkEventType type,
- GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- guint32 time,
- guint group,
- guint button,
- guint mode)
+/**
+ * gdk_touchpad_event_get_gesture_phase:
+ * @event: a touchpad #GdkEvent
+ *
+ * Extracts the touchpad gesture phase from a touchpad event.
+ *
+ * Returns: the gesture phase of @event
+ **/
+GdkTouchpadGesturePhase
+gdk_touchpad_event_get_gesture_phase (GdkEvent *event)
{
- GdkEventPadButton *event;
+ g_return_val_if_fail (event->any.type == GDK_TOUCHPAD_PINCH ||
+ event->any.type == GDK_TOUCHPAD_SWIPE, 0);
- g_return_val_if_fail (type == GDK_PAD_BUTTON_PRESS ||
- type == GDK_PAD_BUTTON_RELEASE, NULL);
+ if (event->any.type == GDK_TOUCHPAD_PINCH)
+ return event->touchpad_pinch.phase;
+ else if (event->any.type == GDK_TOUCHPAD_SWIPE)
+ return event->touchpad_swipe.phase;
- event = g_new0 (GdkEventPadButton, 1);
+ return 0;
+}
- event->any.ref_count = 1;
- event->any.type = type;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->time = time;
- event->group = group;
- event->button = button;
- event->mode = mode;
+/**
+ * gdk_touchpad_event_get_n_fingers:
+ * @event: a touchpad event
+ *
+ * Extracts the number of fingers from a touchpad event.
+ *
+ * Returns: the number of fingers for @event
+ **/
+guint
+gdk_touchpad_event_get_n_fingers (GdkEvent *event)
+{
+ g_return_val_if_fail (event->any.type == GDK_TOUCHPAD_PINCH ||
+ event->any.type == GDK_TOUCHPAD_SWIPE, 0);
- return (GdkEvent *)event;
+ if (event->any.type == GDK_TOUCHPAD_PINCH)
+ return event->touchpad_pinch.n_fingers;
+ else if (event->any.type == GDK_TOUCHPAD_SWIPE)
+ return event->touchpad_swipe.n_fingers;
+
+ return 0;
}
-GdkEvent *
-gdk_event_pad_group_mode_new (GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- guint32 time,
- guint group,
- guint mode)
+/**
+ * gdk_touchpad_event_get_deltas:
+ * @event: a touchpad event
+ * @dx: (out): return location for x
+ * @dy: (out): return location for y
+ *
+ * Extracts delta information from a touchpad event.
+ **/
+void
+gdk_touchpad_event_get_deltas (GdkEvent *event,
+ double *dx,
+ double *dy)
{
- GdkEventPadGroupMode *event = g_new0 (GdkEventPadGroupMode, 1);
+ g_return_if_fail (event->any.type == GDK_TOUCHPAD_PINCH ||
+ event->any.type == GDK_TOUCHPAD_SWIPE);
- event->any.ref_count = 1;
- event->any.type = GDK_PAD_GROUP_MODE;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->time = time;
- event->group = group;
- event->mode = mode;
+ if (event->any.type == GDK_TOUCHPAD_PINCH)
+ {
+ *dx = event->touchpad_pinch.dx;
+ *dy = event->touchpad_pinch.dy;
+ }
+ else if (event->any.type == GDK_TOUCHPAD_SWIPE)
+ {
+ *dx = event->touchpad_swipe.dx;
+ *dy = event->touchpad_swipe.dy;
+ }
+ else
+ {
+ *dx = NAN;
+ *dy = NAN;
+ }
+}
- return (GdkEvent *)event;
+/**
+ * gdk_touchpad_pinch_event_get_angle_delta:
+ * @event: a touchpad pinch event
+ *
+ * Extracts the angle delta from a touchpad pinch event.
+ *
+ * Returns: the angle delta of @event
+ */
+double
+gdk_touchpad_pinch_event_get_angle_delta (GdkEvent *event)
+{
+ g_return_val_if_fail (event->any.type == GDK_TOUCHPAD_PINCH, 0);
+
+ return event->touchpad_pinch.angle_delta;
}
-GdkEvent *
-gdk_event_drag_new (GdkEventType type,
- GdkSurface *surface,
- GdkDevice *device,
- GdkDrop *drop,
- guint32 time,
- double x,
- double y)
+/**
+ * gdk_touchpad_pinch_event_get_scale:
+ * @event: a touchpad pinch event
+ *
+ * Extracts the scale from a touchpad pinch event.
+ *
+ * Returns: the scale of @event
+ **/
+double
+gdk_touchpad_pinch_event_get_scale (GdkEvent *event)
{
- GdkEventDND *event;
+ g_return_val_if_fail (event->any.type == GDK_TOUCHPAD_PINCH, 0);
- g_return_val_if_fail (type == GDK_DRAG_ENTER ||
- type == GDK_DRAG_MOTION ||
- type == GDK_DRAG_LEAVE ||
- type == GDK_DROP_START, NULL);
+ return event->touchpad_pinch.scale;
+}
- event = g_new0 (GdkEventDND, 1);
+/**
+ * gdk_pad_button_event_get_button:
+ * @event: a pad button event
+ *
+ * Extracts information about the pressed button from
+ * a pad event.
+ *
+ * Returns: the button of @event
+ **/
+guint
+gdk_pad_button_event_get_button (GdkEvent *event)
+{
+ g_return_val_if_fail (event->any.type == GDK_PAD_BUTTON_PRESS ||
+ event->any.type == GDK_PAD_BUTTON_RELEASE, 0);
- event->any.ref_count = 1;
- event->any.type = type;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->drop = g_object_ref (drop);
- event->time = time;
- event->x = x;
- event->y = y;
+ return event->pad_button.button;
+}
- return (GdkEvent *)event;
+/**
+ * gdk_pad_axis_event_get_value:
+ * @event: a pad strip or ring event
+ * @index: (out): Return location for the axis index
+ * @value: (out): Return location for the axis value
+ *
+ * Extracts the information from a pad strip or ring event.
+ **/
+void
+gdk_pad_axis_event_get_value (GdkEvent *event,
+ guint *index,
+ gdouble *value)
+{
+ g_return_if_fail (event->any.type == GDK_PAD_RING ||
+ event->any.type == GDK_PAD_STRIP);
+
+ *index = event->pad_axis.index;
+ *value = event->pad_axis.value;
}
-GdkEvent *
-gdk_event_grab_broken_new (GdkSurface *surface,
- GdkDevice *device,
- GdkDevice *source_device,
- GdkSurface *grab_surface,
- gboolean implicit)
+/**
+ * gdk_pad_event_group_mode:
+ * @event: a pad event
+ * @group: (out): return location for the group
+ * @mode: (out): return location for the mode
+ *
+ * Extracts group and mode information from a pad event.
+ **/
+void
+gdk_pad_event_get_group_mode (GdkEvent *event,
+ guint *group,
+ guint *mode)
{
- GdkEventGrabBroken *event = g_new0 (GdkEventGrabBroken, 1);
+ g_return_if_fail (event->any.type == GDK_PAD_GROUP_MODE ||
+ event->any.type == GDK_PAD_BUTTON_PRESS ||
+ event->any.type == GDK_PAD_BUTTON_RELEASE ||
+ event->any.type == GDK_PAD_RING ||
+ event->any.type == GDK_PAD_STRIP);
- event->any.ref_count = 1;
- event->any.type = GDK_GRAB_BROKEN;
- event->any.surface = g_object_ref (surface);
- event->any.device = g_object_ref (device);
- event->any.source_device = g_object_ref (source_device);
- event->grab_surface = grab_surface;
- event->implicit = implicit;
- event->keyboard = gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD;
+ switch ((guint)event->any.type)
+ {
+ case GDK_PAD_GROUP_MODE:
+ *group = event->pad_group_mode.group;
+ *mode = event->pad_group_mode.mode;
+ break;
+ case GDK_PAD_BUTTON_PRESS:
+ case GDK_PAD_BUTTON_RELEASE:
+ *group = event->pad_button.group;
+ *mode = event->pad_button.mode;
+ break;
+ case GDK_PAD_RING:
+ case GDK_PAD_STRIP:
+ *group = event->pad_axis.group;
+ *mode = event->pad_axis.mode;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
- return (GdkEvent *)event;
+/**
+ * gdk_drag_event_get_drop:
+ * @event: a DND event
+ *
+ * Gets the #GdkDrop from a DND event.
+ *
+ * Returns: (transfer none) (nullable): the drop
+ **/
+GdkDrop *
+gdk_drag_event_get_drop (GdkEvent *event)
+{
+ g_return_val_if_fail (event->any.type == GDK_DRAG_ENTER ||
+ event->any.type == GDK_DRAG_LEAVE ||
+ event->any.type == GDK_DRAG_MOTION ||
+ event->any.type == GDK_DROP_START, NULL);
+
+ return event->dnd.drop;
+}
+
+/**
+ * gdk_grab_broken_event_get_grab_surface:
+ * @event: a grab broken event
+ *
+ * Extracts the grab surface from a grab broken event.
+ *
+ * Returns: the grab surface of @event
+ **/
+GdkSurface *
+gdk_grab_broken_event_get_grab_surface (GdkEvent *event)
+{
+ g_return_val_if_fail (event->any.type == GDK_GRAB_BROKEN, NULL);
+
+ return event->grab_broken.grab_surface;
}
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index b574044ccd..6b4baf6821 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -330,164 +330,137 @@ typedef enum
} GdkCrossingMode;
GDK_AVAILABLE_IN_ALL
-GType gdk_event_get_type (void) G_GNUC_CONST;
+GType gdk_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
-GType gdk_event_sequence_get_type (void) G_GNUC_CONST;
+GType gdk_event_sequence_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
-GdkEvent * gdk_event_ref (GdkEvent *event);
+GdkEvent * gdk_event_ref (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-void gdk_event_unref (GdkEvent *event);
+void gdk_event_unref (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-GdkSurface *gdk_event_get_surface (GdkEvent *event);
+GdkEventType gdk_event_get_event_type (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-guint32 gdk_event_get_time (GdkEvent *event);
-GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_state (GdkEvent *event,
- GdkModifierType *state);
-GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_coords (GdkEvent *event,
- gdouble *x_win,
- gdouble *y_win);
-GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_button (GdkEvent *event,
- guint *button);
-GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_click_count (GdkEvent *event,
- guint *click_count);
+GdkSurface * gdk_event_get_surface (GdkEvent *event);
+
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_keyval (GdkEvent *event,
- guint *keyval);
+GdkDevice * gdk_event_get_device (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_keycode (GdkEvent *event,
- guint16 *keycode);
+GdkDevice * gdk_event_get_source_device (GdkEvent *event);
+
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_key_is_modifier (GdkEvent *event,
- gboolean *is_modifier);
+GdkDeviceTool * gdk_event_get_device_tool (GdkEvent *event);
+
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_key_group (GdkEvent *event,
- guint *group);
+guint32 gdk_event_get_time (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_scroll_direction (GdkEvent *event,
- GdkScrollDirection *direction);
+GdkDisplay * gdk_event_get_display (GdkEvent *event);
+
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_scroll_deltas (GdkEvent *event,
- gdouble *delta_x,
- gdouble *delta_y);
+GdkEventSequence * gdk_event_get_event_sequence (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_is_scroll_stop_event (GdkEvent *event);
+GdkModifierType gdk_event_get_modifier_state (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_axis (GdkEvent *event,
- GdkAxisUse axis_use,
- gdouble *value);
+gboolean gdk_event_get_position (GdkEvent *event,
+ double *x,
+ double *y);
GDK_AVAILABLE_IN_ALL
-GdkDevice* gdk_event_get_device (GdkEvent *event);
+gboolean gdk_event_get_axes (GdkEvent *event,
+ double **axes,
+ guint *n_axes);
GDK_AVAILABLE_IN_ALL
-GdkDevice* gdk_event_get_source_device (GdkEvent *event);
+gboolean gdk_event_get_axis (GdkEvent *event,
+ GdkAxisUse axis_use,
+ double *value);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_triggers_context_menu (GdkEvent *event);
+gboolean gdk_event_get_pointer_emulated (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_events_get_distance (GdkEvent *event1,
- GdkEvent *event2,
- gdouble *distance);
+guint gdk_button_event_get_button (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_events_get_angle (GdkEvent *event1,
- GdkEvent *event2,
- gdouble *angle);
+GdkScrollDirection gdk_scroll_event_get_direction (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_events_get_center (GdkEvent *event1,
- GdkEvent *event2,
- gdouble *x,
- gdouble *y);
+void gdk_scroll_event_get_deltas (GdkEvent *event,
+ double *delta_x,
+ double *delta_y);
GDK_AVAILABLE_IN_ALL
-GdkDisplay *gdk_event_get_display (GdkEvent *event);
-
+gboolean gdk_scroll_event_is_stop (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-GdkEventSequence *gdk_event_get_event_sequence (GdkEvent *event);
-
+guint gdk_key_event_get_keyval (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-GdkEventType gdk_event_get_event_type (GdkEvent *event);
-
+guint gdk_key_event_get_keycode (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-GdkSeat *gdk_event_get_seat (GdkEvent *event);
-
+guint gdk_key_event_get_scancode (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-void gdk_set_show_events (gboolean show_events);
+guint gdk_key_event_get_group (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_get_show_events (void);
-
+gboolean gdk_key_event_is_modifier (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-GdkDeviceTool *gdk_event_get_device_tool (GdkEvent *event);
-
+gboolean gdk_focus_event_get_in (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-int gdk_event_get_scancode (GdkEvent *event);
-
+gboolean gdk_touch_event_get_emulating_pointer (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_pointer_emulated (GdkEvent *event);
-
+GdkCrossingMode gdk_crossing_event_get_mode (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_is_sent (GdkEvent *event);
-
+GdkNotifyType gdk_crossing_event_get_detail (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-GdkDrop * gdk_event_get_drop (GdkEvent *event);
-
+void gdk_configure_event_get_size (GdkEvent *event,
+ int *width,
+ int *height);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_crossing_mode (GdkEvent *event,
- GdkCrossingMode *mode);
+GdkTouchpadGesturePhase
+ gdk_touchpad_event_get_gesture_phase (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_crossing_detail (GdkEvent *event,
- GdkNotifyType *detail);
+guint gdk_touchpad_event_get_n_fingers (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_touchpad_gesture_phase (GdkEvent *event,
- GdkTouchpadGesturePhase *phase);
+void gdk_touchpad_event_get_deltas (GdkEvent *event,
+ double *dx,
+ double *dy);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_touchpad_gesture_n_fingers (GdkEvent *event,
- guint *n_fingers);
+double gdk_touchpad_pinch_event_get_angle_delta (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_touchpad_deltas (GdkEvent *event,
- double *dx,
- double *dy);
+double gdk_touchpad_pinch_event_get_scale (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_touchpad_angle_delta (GdkEvent *event,
- double *delta);
+guint gdk_pad_button_event_get_button (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_touchpad_scale (GdkEvent *event,
- double *scale);
-
+void gdk_pad_axis_event_get_value (GdkEvent *event,
+ guint *index,
+ double *value);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_touch_emulating_pointer (GdkEvent *event,
- gboolean *emulating);
+void gdk_pad_event_get_group_mode (GdkEvent *event,
+ guint *group,
+ guint *mode);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_grab_surface (GdkEvent *event,
- GdkSurface **surface);
+GdkDrop * gdk_drag_event_get_drop (GdkEvent *event);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_focus_in (GdkEvent *event,
- gboolean *focus_in);
+GdkSurface * gdk_grab_broken_event_get_grab_surface (GdkEvent *event);
+
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_pad_group_mode (GdkEvent *event,
- guint *group,
- guint *mode);
+GList * gdk_event_get_motion_history (GdkEvent *event);
+
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_pad_button (GdkEvent *event,
- guint *button);
+gboolean gdk_event_triggers_context_menu (GdkEvent *event);
+
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_pad_axis_value (GdkEvent *event,
- guint *index,
- gdouble *value);
+gboolean gdk_events_get_distance (GdkEvent *event1,
+ GdkEvent *event2,
+ double *distance);
GDK_AVAILABLE_IN_ALL
-gboolean gdk_event_get_axes (GdkEvent *event,
- gdouble **axes,
- guint *n_axes);
+gboolean gdk_events_get_angle (GdkEvent *event1,
+ GdkEvent *event2,
+ double *angle);
GDK_AVAILABLE_IN_ALL
-GList * gdk_event_get_motion_history (GdkEvent *event);
+gboolean gdk_events_get_center (GdkEvent *event1,
+ GdkEvent *event2,
+ double *x,
+ double *y);
G_END_DECLS
diff --git a/gdk/gdkeventsprivate.h b/gdk/gdkeventsprivate.h
index cb2cfea839..c8006961c2 100644
--- a/gdk/gdkeventsprivate.h
+++ b/gdk/gdkeventsprivate.h
@@ -521,55 +521,9 @@ struct _GdkEventPadGroupMode {
/*
* GdkEvent:
- * @type: the #GdkEventType
- * @any: a #GdkEventAny
- * @motion: a #GdkEventMotion
- * @button: a #GdkEventButton
- * @touch: a #GdkEventTouch
- * @scroll: a #GdkEventScroll
- * @key: a #GdkEventKey
- * @crossing: a #GdkEventCrossing
- * @focus_change: a #GdkEventFocus
- * @configure: a #GdkEventConfigure
- * @proximity: a #GdkEventProximity
- * @dnd: a #GdkEventDND
- * @grab_broken: a #GdkEventGrabBroken
- * @touchpad_swipe: a #GdkEventTouchpadSwipe
- * @touchpad_pinch: a #GdkEventTouchpadPinch
- * @pad_button: a #GdkEventPadButton
- * @pad_axis: a #GdkEventPadAxis
- * @pad_group_mode: a #GdkEventPadGroupMode
*
- * A #GdkEvent contains a union of all of the event types,
- * and allows access to the data fields in a number of ways.
- *
- * The event type is always the first field in all of the event types, and
- * can always be accessed with the following code, no matter what type of
- * event it is:
- * |[<!-- language="C" -->
- * GdkEvent *event;
- * GdkEventType type;
- *
- * type = event->type;
- * ]|
- *
- * To access other fields of the event, the pointer to the event
- * can be cast to the appropriate event type, or the union member
- * name can be used. For example if the event type is %GDK_BUTTON_PRESS
- * then the x coordinate of the button press can be accessed with:
- * |[<!-- language="C" -->
- * GdkEvent *event;
- * gdouble x;
- *
- * x = ((GdkEventButton*)event)->x;
- * ]|
- * or:
- * |[<!-- language="C" -->
- * GdkEvent *event;
- * gdouble x;
- *
- * x = event->button.x;
- * ]|
+ * The GdkEvent struct is private and should only be accessed
+ * using the accessor functions.
*/
union _GdkEvent
{
diff --git a/gdk/gdkkeys.c b/gdk/gdkkeys.c
index a60a33be3e..25e9284e3c 100644
--- a/gdk/gdkkeys.c
+++ b/gdk/gdkkeys.c
@@ -559,11 +559,14 @@ gdk_keymap_lookup_key (GdkKeymap *keymap,
* |[<!-- language="C" -->
* // We want to ignore irrelevant modifiers like ScrollLock
* #define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)
- * gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
- * event->state, event->group,
+ * state = gdk_event_get_modifier_state (event);
+ * gdk_keymap_translate_keyboard_state (keymap,
+ * gdk_key_event_get_keycode (event),
+ * state,
+ * gdk_key_event_get_group (event),
* &keyval, NULL, NULL, &consumed);
* if (keyval == GDK_PLUS &&
- * (event->state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK)
+ * (state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK)
* // Control was pressed
* ]|
*
@@ -574,7 +577,7 @@ gdk_keymap_lookup_key (GdkKeymap *keymap,
* |[<!-- language="C" -->
* // XXX Don’t do this XXX
* if (keyval == accel_keyval &&
- * (event->state & ~consumed & ALL_ACCELS_MASK) == (accel_mods & ~consumed))
+ * (state & ~consumed & ALL_ACCELS_MASK) == (accel_mods & ~consumed))
* // Accelerator was pressed
* ]|
*
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 1ad61e5ef3..976327e317 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2689,6 +2689,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
GdkDeviceGrabInfo *button_release_grab;
GdkPointerSurfaceInfo *pointer_info = NULL;
GdkDevice *device, *source_device;
+ GdkEventType type;
_gdk_display_update_last_event (display, event);
@@ -2722,21 +2723,21 @@ _gdk_windowing_got_event (GdkDisplay *display,
}
}
- event_surface = event->any.surface;
+ event_surface = gdk_event_get_surface (event);
if (!event_surface)
goto out;
- if (event->any.type == GDK_ENTER_NOTIFY)
+ type = gdk_event_get_event_type (event);
+ if (type == GDK_ENTER_NOTIFY)
_gdk_display_set_surface_under_pointer (display, device, event_surface);
- else if (event->any.type == GDK_LEAVE_NOTIFY)
+ else if (type == GDK_LEAVE_NOTIFY)
_gdk_display_set_surface_under_pointer (display, device, NULL);
- if ((event->any.type == GDK_BUTTON_RELEASE ||
- event->any.type == GDK_TOUCH_CANCEL ||
- event->any.type == GDK_TOUCH_END) &&
- !event->any.send_event)
+ if (type == GDK_BUTTON_RELEASE ||
+ type == GDK_TOUCH_CANCEL ||
+ type == GDK_TOUCH_END)
{
- if (event->any.type == GDK_BUTTON_RELEASE ||
+ if (type == GDK_BUTTON_RELEASE ||
gdk_event_get_pointer_emulated (event))
{
button_release_grab =
@@ -2744,7 +2745,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
if (button_release_grab &&
button_release_grab->implicit &&
- (event->button.state & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (event->button.button -
1))) == 0)
+ (gdk_event_get_modifier_state (event) & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK <<
(gdk_button_event_get_button (event) - 1))) == 0)
{
button_release_grab->serial_end = serial;
button_release_grab->implicit_ungrab = FALSE;
@@ -4009,16 +4010,29 @@ is_key_event (GdkEvent *event)
return FALSE;
}
-static void
+static GdkEvent *
rewrite_event_for_toplevel (GdkEvent *event)
{
GdkSurface *surface;
surface = gdk_event_get_surface (event);
+ if (!surface->parent)
+ return gdk_event_ref (event);
+
while (surface->parent)
surface = surface->parent;
- g_set_object (&event->any.surface, surface);
+ return gdk_event_key_new (gdk_event_get_event_type (event),
+ surface,
+ gdk_event_get_device (event),
+ gdk_event_get_source_device (event),
+ gdk_event_get_time (event),
+ gdk_event_get_modifier_state (event),
+ gdk_key_event_get_keyval (event),
+ gdk_key_event_get_keycode (event),
+ gdk_key_event_get_scancode (event),
+ gdk_key_event_get_group (event),
+ gdk_key_event_is_modifier (event));
}
static void
@@ -4039,49 +4053,44 @@ add_event_mark (GdkEvent *event,
{
case GDK_MOTION_NOTIFY:
{
- GdkEventMotion *motion = (GdkEventMotion *)event;
+ double x, y;
+ gdk_event_get_position (event, &x, &y);
message = g_strdup_printf ("{x=%lf, y=%lf, state=0x%x}",
- motion->x, motion->y, motion->state);
+ x, y,
+ gdk_event_get_modifier_state (event));
break;
}
case GDK_BUTTON_PRESS:
- {
- GdkEventButton *button = (GdkEventButton *)event;
- message = g_strdup_printf ("{button=%u, x=%lf, y=%lf, state=0x%x}",
- button->button, button->x, button->y, button->state);
- break;
- }
-
case GDK_BUTTON_RELEASE:
{
- GdkEventButton *button = (GdkEventButton *)event;
+ double x, y;
+ gdk_event_get_position (event, &x, &y);
message = g_strdup_printf ("{button=%u, x=%lf, y=%lf, state=0x%x}",
- button->button, button->x, button->y, button->state);
+ gdk_button_event_get_button (event),
+ x, y,
+ gdk_event_get_modifier_state (event));
break;
}
case GDK_KEY_PRESS:
- {
- GdkEventKey *key = (GdkEventKey *)event;
- message = g_strdup_printf ("{keyval=%u, state=0x%x, hardware_keycode=%u key_scancode=%u group=%u
is_modifier=%u}",
- key->keyval, key->state, key->hardware_keycode, key->key_scancode,
key->group, key->is_modifier);
- break;
- }
-
case GDK_KEY_RELEASE:
{
- GdkEventKey *key = (GdkEventKey *)event;
message = g_strdup_printf ("{keyval=%u, state=0x%x, hardware_keycode=%u key_scancode=%u group=%u
is_modifier=%u}",
- key->keyval, key->state, key->hardware_keycode, key->key_scancode,
key->group, key->is_modifier);
+ gdk_key_event_get_keyval (event),
+ gdk_event_get_modifier_state (event),
+ gdk_key_event_get_keycode (event),
+ gdk_key_event_get_scancode (event),
+ gdk_key_event_get_group (event),
+ gdk_key_event_is_modifier (event));
break;
}
case GDK_CONFIGURE:
{
- GdkEventConfigure *config = (GdkEventConfigure *)event;
- message = g_strdup_printf ("{x=%d, y=%d, width=%d, height=%d}",
- config->x, config->y, config->width, config->height);
+ int width, height;
+ gdk_configure_event_get_size (event, &width, &height);
+ message = g_strdup_printf ("{width=%d, height=%d}", width, height);
break;
}
@@ -4141,9 +4150,15 @@ gdk_surface_handle_event (GdkEvent *event)
}
else
{
+ GdkEvent *emitted;
+
if (is_key_event (event))
- rewrite_event_for_toplevel (event);
- g_signal_emit (gdk_event_get_surface (event), signals[EVENT], 0, event, &handled);
+ emitted = rewrite_event_for_toplevel (event);
+ else
+ emitted = gdk_event_ref (event);
+
+ g_signal_emit (gdk_event_get_surface (emitted), signals[EVENT], 0, emitted, &handled);
+ gdk_event_unref (emitted);
}
if (GDK_PROFILER_IS_RUNNING)
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 5935a6b9e1..a7e5ca932e 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -1474,7 +1474,7 @@ gdk_wayland_seat_set_frame_event (GdkWaylandSeat *seat,
GdkEvent *event)
{
if (seat->pointer_info.frame.event &&
- seat->pointer_info.frame.event->any.type != event->any.type)
+ gdk_event_get_event_type (seat->pointer_info.frame.event) != gdk_event_get_event_type (event))
gdk_wayland_seat_flush_frame_event (seat);
seat->pointer_info.frame.event = event;
@@ -1608,10 +1608,13 @@ pointer_handle_motion (void *data,
NULL);
gdk_wayland_seat_set_frame_event (seat, event);
- GDK_SEAT_NOTE (seat, EVENTS,
- g_message ("motion %f %f, seat %p state %d",
- event->motion.x, event->motion.y,
- seat, event->motion.state));
+ if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
+ {
+ double x, y;
+ gdk_event_get_position (event, &x, &y);
+ g_message ("motion %f %f, seat %p state %d",
+ x, y, seat, gdk_event_get_modifier_state (event));
+ }
if (display->seat_version < WL_POINTER_HAS_FRAME)
gdk_wayland_seat_flush_frame_event (seat);
@@ -1679,10 +1682,10 @@ pointer_handle_button (void *data,
GDK_SEAT_NOTE (seat, EVENTS,
g_message ("button %d %s, seat %p state %d",
- event->button.button,
+ gdk_button_event_get_button (event),
state ? "press" : "release",
seat,
- event->button.state));
+ gdk_event_get_modifier_state (event)));
if (display->seat_version < WL_POINTER_HAS_FRAME)
gdk_wayland_seat_flush_frame_event (seat);
@@ -1946,7 +1949,7 @@ keyboard_handle_leave (void *data,
GDK_SEAT_NOTE (seat, EVENTS,
g_message ("focus out, seat %p surface %p",
- seat, event->any.surface));
+ seat, gdk_event_get_surface (event)));
_gdk_wayland_display_deliver_event (seat->display, event);
}
@@ -2044,9 +2047,10 @@ deliver_key_event (GdkWaylandSeat *seat,
"mods 0x%x",
(state ? "press" : "release"),
(from_key_repeat ? " (repeat)" : ""),
- event->any.surface,
- event->key.hardware_keycode, event->key.keyval,
- event->key.state));
+ gdk_event_get_surface (event),
+ gdk_key_event_get_keycode (event),
+ gdk_key_event_get_keyval (event),
+ gdk_event_get_modifier_state (event)));
if (!xkb_keymap_key_repeats (xkb_keymap, key))
return;
@@ -2300,8 +2304,12 @@ touch_handle_down (void *data,
mimic_pointer_emulating_touch_info (seat->touch_master, touch);
}
- GDK_SEAT_NOTE (seat, EVENTS,
- g_message ("touch begin %f %f", event->touch.x, event->touch.y));
+ if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
+ {
+ double xx, yy;
+ gdk_event_get_position (event, &xx, &yy);
+ g_message ("touch begin %f %f", xx, yy);
+ }
_gdk_wayland_display_deliver_event (seat->display, event);
}
@@ -2332,8 +2340,12 @@ touch_handle_up (void *data,
NULL,
touch->initial_touch);
- GDK_SEAT_NOTE (seat, EVENTS,
- g_message ("touch end %f %f", event->touch.x, event->touch.y));
+ if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
+ {
+ double x, y;
+ gdk_event_get_position (event, &x, &y);
+ g_message ("touch end %f %f", x, y);
+ }
_gdk_wayland_display_deliver_event (seat->display, event);
@@ -2373,8 +2385,12 @@ touch_handle_motion (void *data,
NULL,
touch->initial_touch);
- GDK_SEAT_NOTE (seat, EVENTS,
- g_message ("touch update %f %f", event->touch.x, event->touch.y));
+ if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
+ {
+ double xx, yy;
+ gdk_event_get_position (event, &xx, &yy);
+ g_message ("touch update %f %f", xx, yy);
+ }
_gdk_wayland_display_deliver_event (seat->display, event);
}
@@ -2447,11 +2463,14 @@ emit_gesture_swipe_event (GdkWaylandSeat *seat,
n_fingers,
dx, dy);
- GDK_SEAT_NOTE (seat, EVENTS,
- g_message ("swipe event %d, coords: %f %f, seat %p state %d",
- event->any.type, event->touchpad_swipe.x,
- event->touchpad_swipe.y, seat,
- event->touchpad_swipe.state));
+ if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
+ {
+ double x, y;
+ gdk_event_get_position (event, &x, &y);
+ g_message ("swipe event %d, coords: %f %f, seat %p state %d",
+ gdk_event_get_event_type (event), x, y, seat,
+ gdk_event_get_modifier_state (event));
+ }
_gdk_wayland_display_deliver_event (seat->display, event);
}
@@ -2542,11 +2561,15 @@ emit_gesture_pinch_event (GdkWaylandSeat *seat,
dx, dy,
scale, angle_delta * G_PI / 180);
- GDK_SEAT_NOTE (seat, EVENTS,
- g_message ("pinch event %d, coords: %f %f, seat %p state %d",
- event->any.type, event->touchpad_pinch.x,
- event->touchpad_pinch.y, seat,
- event->touchpad_pinch.state));
+ if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
+ {
+ double x, y;
+ gdk_event_get_position (event, &x, &y);
+ g_message ("pinch event %d, coords: %f %f, seat %p state %d",
+ gdk_event_get_event_type (event),
+ x, y, seat,
+ gdk_event_get_modifier_state (event));
+ }
_gdk_wayland_display_deliver_event (seat->display, event);
}
@@ -3213,6 +3236,7 @@ gdk_wayland_tablet_flush_frame_event (GdkWaylandTabletData *tablet,
guint32 time)
{
GdkEvent *event;
+ GdkEventType type;
event = tablet->pointer_info.frame.event;
tablet->pointer_info.frame.event = NULL;
@@ -3222,16 +3246,18 @@ gdk_wayland_tablet_flush_frame_event (GdkWaylandTabletData *tablet,
gdk_event_ref (event);
- if (event->any.type == GDK_PROXIMITY_OUT)
- emulate_crossing (event->any.surface, NULL,
+ type = gdk_event_get_event_type (event);
+
+ if (type == GDK_PROXIMITY_OUT)
+ emulate_crossing (gdk_event_get_surface (event), NULL,
tablet->master, GDK_LEAVE_NOTIFY,
GDK_CROSSING_NORMAL, time);
_gdk_wayland_display_deliver_event (gdk_seat_get_display (tablet->seat),
event);
- if (event->any.type == GDK_PROXIMITY_IN)
- emulate_crossing (event->any.surface, NULL,
+ if (type == GDK_PROXIMITY_IN)
+ emulate_crossing (gdk_event_get_surface (event), NULL,
tablet->master, GDK_ENTER_NOTIFY,
GDK_CROSSING_NORMAL, time);
@@ -3243,7 +3269,7 @@ gdk_wayland_tablet_set_frame_event (GdkWaylandTabletData *tablet,
GdkEvent *event)
{
if (tablet->pointer_info.frame.event &&
- tablet->pointer_info.frame.event->any.type != event->any.type)
+ gdk_event_get_event_type (tablet->pointer_info.frame.event) != gdk_event_get_event_type (event))
gdk_wayland_tablet_flush_frame_event (tablet, GDK_CURRENT_TIME);
tablet->pointer_info.frame.event = event;
@@ -3699,7 +3725,7 @@ tablet_tool_handle_frame (void *data,
frame_event = tablet->pointer_info.frame.event;
- if (frame_event && frame_event->any.type == GDK_PROXIMITY_OUT)
+ if (frame_event && gdk_event_get_event_type (frame_event) == GDK_PROXIMITY_OUT)
{
tool->current_tablet = NULL;
tablet->current_tool = NULL;
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index b340e04c86..b0220744c1 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -3775,7 +3775,7 @@ gdk_wayland_surface_show_window_menu (GdkSurface *surface,
device = GDK_WAYLAND_DEVICE (gdk_event_get_device (event));
seat = gdk_wayland_device_get_wl_seat (GDK_DEVICE (device));
- gdk_event_get_coords (event, &x, &y);
+ gdk_event_get_position (event, &x, &y);
serial = _gdk_wayland_device_get_implicit_grab_serial (device, event);
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 1b8f4cae91..8980d0de26 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -758,13 +758,16 @@ void
_gdk_win32_print_event (GdkEvent *event)
{
const char *kvname;
+ double x, y;
+ GdkCrossingMode mode;
+ GdkNotifyType detail;
+ GdkScrollDirection direction;
g_print ("%s%*s===> ", (debug_indent > 0 ? "\n" : ""), debug_indent, "");
- switch (event->any.type)
+ switch (gdk_event_get_event_type (event))
{
#define CASE(x) case x: g_print (#x); break;
CASE (GDK_DELETE);
- CASE (GDK_DESTROY);
CASE (GDK_MOTION_NOTIFY);
CASE (GDK_BUTTON_PRESS);
CASE (GDK_BUTTON_RELEASE);
@@ -786,81 +789,72 @@ _gdk_win32_print_event (GdkEvent *event)
}
g_print (" %p @ %ums ",
- event->any.surface ? GDK_SURFACE_HWND (event->any.surface) : NULL,
+ GDK_SURFACE_HWND (gdk_event_get_surface (event)),
gdk_event_get_time (event));
- switch (event->any.type)
+ switch (gdk_event_get_event_type (event))
{
case GDK_MOTION_NOTIFY:
- g_print ("(%.4g,%.4g) (%.4g,%.4g)",
- event->motion.x, event->motion.y,
- event->motion.x_root, event->motion.y_root);
- print_event_state (event->motion.state);
+ gdk_event_get_position (event, &x, &y);
+ g_print ("(%.4g,%.4g) ", x, y);
+ print_event_state (gdk_event_get_modifier_state (event));
break;
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
- g_print ("%d (%.4g,%.4g) (%.4g,%.4g) ",
- event->button.button,
- event->button.x, event->button.y,
- event->button.x_root, event->button.y_root);
- print_event_state (event->button.state);
+ gdk_event_get_position (event, &x, &y);
+ g_print ("%d (%.4g,%.4g) ", gdk_button_event_get_button (event), x, y);
+ print_event_state (gdk_event_get_modifier_state (event));
break;
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
- kvname = gdk_keyval_name (event->key.keyval);
+ kvname = gdk_keyval_name (gdk_key_event_get_keyval (event));
g_print ("%#.02x group:%d %s",
- event->key.hardware_keycode, event->key.group,
+ gdk_key_event_get_keycode (event),
+ gdk_key_event_get_group (event),
(kvname ? kvname : "??"));
- print_event_state (event->key.state);
+ print_event_state (gdk_event_get_modifier_state (event));
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
- g_print ("%p (%.4g,%.4g) (%.4g,%.4g) %s %s%s",
- event->crossing.child_surface == NULL ? NULL : GDK_SURFACE_HWND
(event->crossing.child_surface),
- event->crossing.x, event->crossing.y,
- event->crossing.x_root, event->crossing.y_root,
- (event->crossing.mode == GDK_CROSSING_NORMAL ? "NORMAL" :
- (event->crossing.mode == GDK_CROSSING_GRAB ? "GRAB" :
- (event->crossing.mode == GDK_CROSSING_UNGRAB ? "UNGRAB" :
+ gdk_event_get_position (event, &x, &y);
+ mode = gdk_crossing_event_get_mode (event);
+ detail = gdk_crossing_event_get_detail (event);
+ g_print ("(%.4g,%.4g) %s %s",
+ x, y,
+ (mode == GDK_CROSSING_NORMAL ? "NORMAL" :
+ (mode == GDK_CROSSING_GRAB ? "GRAB" :
+ (mode == GDK_CROSSING_UNGRAB ? "UNGRAB" :
"???"))),
- (event->crossing.detail == GDK_NOTIFY_ANCESTOR ? "ANCESTOR" :
- (event->crossing.detail == GDK_NOTIFY_VIRTUAL ? "VIRTUAL" :
- (event->crossing.detail == GDK_NOTIFY_INFERIOR ? "INFERIOR" :
- (event->crossing.detail == GDK_NOTIFY_NONLINEAR ? "NONLINEAR" :
- (event->crossing.detail == GDK_NOTIFY_NONLINEAR_VIRTUAL ? "NONLINEAR_VIRTUAL" :
- (event->crossing.detail == GDK_NOTIFY_UNKNOWN ? "UNKNOWN" :
- "???")))))),
- event->crossing.focus ? " FOCUS" : "");
- print_event_state (event->crossing.state);
+ (detail == GDK_NOTIFY_ANCESTOR ? "ANCESTOR" :
+ (detail == GDK_NOTIFY_VIRTUAL ? "VIRTUAL" :
+ (detail == GDK_NOTIFY_INFERIOR ? "INFERIOR" :
+ (detail == GDK_NOTIFY_NONLINEAR ? "NONLINEAR" :
+ (detail == GDK_NOTIFY_NONLINEAR_VIRTUAL ? "NONLINEAR_VIRTUAL" :
+ (detail == GDK_NOTIFY_UNKNOWN ? "UNKNOWN" :
+ "???")))))));
+ print_event_state (gdk_event_get_modifier_state (event));
break;
case GDK_FOCUS_CHANGE:
- g_print ("%s", (event->focus_change.in ? "IN" : "OUT"));
+ g_print ("%s", (gdk_focus_event_get_in (event) ? "IN" : "OUT"));
break;
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
case GDK_DRAG_MOTION:
case GDK_DROP_START:
- if (event->dnd.drop != NULL)
- g_print ("ctx:%p: %s",
- event->dnd.drop,
- _gdk_win32_drag_protocol_to_string (GDK_WIN32_DRAG (event->dnd.drop)->protocol));
+ g_print ("DND");
break;
case GDK_SCROLL:
- g_print ("(%.4g,%.4g) (%.4g,%.4g) %s ",
- event->scroll.x, event->scroll.y,
- event->scroll.x_root, event->scroll.y_root,
- (event->scroll.direction == GDK_SCROLL_UP ? "UP" :
- (event->scroll.direction == GDK_SCROLL_DOWN ? "DOWN" :
- (event->scroll.direction == GDK_SCROLL_LEFT ? "LEFT" :
- (event->scroll.direction == GDK_SCROLL_RIGHT ? "RIGHT" :
+ direction = gdk_scroll_event_get_direction (event);
+ g_print (" %s ",
+ (direction == GDK_SCROLL_UP ? "UP" :
+ (direction == GDK_SCROLL_DOWN ? "DOWN" :
+ (direction == GDK_SCROLL_LEFT ? "LEFT" :
+ (direction == GDK_SCROLL_RIGHT ? "RIGHT" :
"???")))));
- print_event_state (event->scroll.state);
+ print_event_state (gdk_event_get_modifier_state (event));
break;
case GDK_GRAB_BROKEN:
- g_print ("%s %s %p",
- (event->grab_broken.keyboard ? "KEYBOARD" : "POINTER"),
- (event->grab_broken.implicit ? "IMPLICIT" : "EXPLICIT"),
- (event->grab_broken.grab_surface ? GDK_SURFACE_HWND (event->grab_broken.grab_surface) : 0));
+ g_print ("Grab broken");
default:
/* Nothing */
break;
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index eda9325bd5..d70101f214 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -4937,7 +4937,7 @@ gdk_win32_surface_show_window_menu (GdkSurface *window,
return FALSE;
}
- gdk_event_get_coords (event, &event_x, &event_y);
+ gdk_event_get_position (event, &event_x, &event_y);
x = round (event_x);
y = round (event_y);
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index ae3714c10a..0132f11d15 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -1183,7 +1183,7 @@ set_user_time (GdkEvent *event)
GdkSurface *surface;
guint32 time;
- surface = event->any.surface;
+ surface = gdk_event_get_surface (event);
g_return_if_fail (GDK_IS_SURFACE (surface));
time = gdk_event_get_time (event);
@@ -1656,16 +1656,16 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
GUINT_TO_POINTER (xev->sourceid));
axes = translate_axes (device,
- event->button.x,
- event->button.y,
- event->any.surface,
+ (double) xev->event_x / scale,
+ (double) xev->event_y / scale,
+ surface,
&xev->valuators);
if (gdk_device_get_mode (device) == GDK_MODE_SURFACE)
{
/* Update event coordinates from axes */
- gdk_device_get_axis (device, event->button.axes, GDK_AXIS_X, &x);
- gdk_device_get_axis (device, event->button.axes, GDK_AXIS_Y, &y);
+ gdk_device_get_axis (device, axes, GDK_AXIS_X, &x);
+ gdk_device_get_axis (device, axes, GDK_AXIS_Y, &y);
}
else
{
@@ -1741,16 +1741,16 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
}
axes = translate_axes (device,
- event->motion.x,
- event->motion.y,
- event->any.surface,
+ (double) xev->event_x / scale,
+ (double) xev->event_y / scale,
+ surface,
&xev->valuators);
if (gdk_device_get_mode (device) == GDK_MODE_SURFACE)
{
/* Update event coordinates from axes */
- gdk_device_get_axis (device, event->motion.axes, GDK_AXIS_X, &x);
- gdk_device_get_axis (device, event->motion.axes, GDK_AXIS_Y, &y);
+ gdk_device_get_axis (device, axes, GDK_AXIS_X, &x);
+ gdk_device_get_axis (device, axes, GDK_AXIS_Y, &y);
}
else
{
@@ -1798,16 +1798,16 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
state |= GDK_BUTTON1_MASK;
axes = translate_axes (device,
- event->touch.x,
- event->touch.y,
- event->any.surface,
+ (double) xev->event_x / scale,
+ (double) xev->event_y / scale,
+ surface,
&xev->valuators);
if (gdk_device_get_mode (device) == GDK_MODE_SURFACE)
{
/* Update event coordinates from axes */
- gdk_device_get_axis (device, event->touch.axes, GDK_AXIS_X, &x);
- gdk_device_get_axis (device, event->touch.axes, GDK_AXIS_Y, &y);
+ gdk_device_get_axis (device, axes, GDK_AXIS_X, &x);
+ gdk_device_get_axis (device, axes, GDK_AXIS_Y, &y);
}
else
{
@@ -1856,16 +1856,16 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
state |= GDK_BUTTON1_MASK;
axes = translate_axes (device,
- event->touch.x,
- event->touch.y,
- event->any.surface,
+ (double) xev->event_x / scale,
+ (double) xev->event_y / scale,
+ surface,
&xev->valuators);
if (gdk_device_get_mode (device) == GDK_MODE_SURFACE)
{
/* Update event coordinates from axes */
- gdk_device_get_axis (device, event->touch.axes, GDK_AXIS_X, &x);
- gdk_device_get_axis (device, event->touch.axes, GDK_AXIS_Y, &y);
+ gdk_device_get_axis (device, axes, GDK_AXIS_X, &x);
+ gdk_device_get_axis (device, axes, GDK_AXIS_Y, &y);
}
else
{
diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c
index 313aac0ed0..c29304e818 100644
--- a/gdk/x11/gdkdrag-x11.c
+++ b/gdk/x11/gdkdrag-x11.c
@@ -2244,16 +2244,15 @@ static gboolean
gdk_dnd_handle_motion_event (GdkDrag *drag,
GdkEvent *event)
{
- GdkModifierType state;
+ double x, y;
int x_root, y_root;
- if (!gdk_event_get_state ((GdkEvent *) event, &state))
- return FALSE;
-
- x_root = event->any.surface->x + event->motion.x;
- y_root = event->any.surface->y + event->motion.y;
- gdk_drag_update (drag, x_root, y_root, state,
- gdk_event_get_time ((GdkEvent *) event));
+ gdk_event_get_position (event, &x, &y);
+ x_root = event->any.surface->x + x;
+ y_root = event->any.surface->y + y;
+ gdk_drag_update (drag, x_root, y_root,
+ gdk_event_get_modifier_state (event),
+ gdk_event_get_time (event));
return TRUE;
}
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index 828313100a..1fa659d9d2 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -135,8 +135,8 @@ create_synth_crossing_event (GdkEventType evtype,
g_assert (evtype == GDK_ENTER_NOTIFY || evtype == GDK_LEAVE_NOTIFY);
- gdk_event_get_state (real_event, &state);
- gdk_event_get_coords (real_event, &x, &y);
+ state = gdk_event_get_modifier_state (real_event);
+ gdk_event_get_position (real_event, &x, &y);
event = gdk_event_crossing_new (evtype,
real_event->any.surface,
gdk_event_get_device (real_event),
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index b9e122a91a..c64d2d420f 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -4619,7 +4619,7 @@ gdk_x11_surface_show_window_menu (GdkSurface *surface,
g_intern_static_string ("_GTK_SHOW_WINDOW_MENU")))
return FALSE;
- gdk_event_get_coords (event, &x, &y);
+ gdk_event_get_position (event, &x, &y);
gdk_x11_surface_get_root_coords (surface, x, y, &x_root, &y_root);
device = gdk_event_get_device (event);
g_object_get (G_OBJECT (device),
diff --git a/gtk/a11y/gtkaccessibilityutil.c b/gtk/a11y/gtkaccessibilityutil.c
index beaae3a50e..61656857b1 100644
--- a/gtk/a11y/gtkaccessibilityutil.c
+++ b/gtk/a11y/gtkaccessibilityutil.c
@@ -118,9 +118,9 @@ atk_key_event_from_gdk_event_key (GdkEventKey *key,
guint16 keycode;
type = gdk_event_get_event_type ((GdkEvent *)key);
- gdk_event_get_state ((GdkEvent *)key, &state);
- gdk_event_get_keyval ((GdkEvent *)key, &keyval);
- gdk_event_get_keycode ((GdkEvent *)key, &keycode);
+ state = gdk_event_get_modifier_state ((GdkEvent *)key);
+ keyval = gdk_key_event_get_keyval ((GdkEvent *)key);
+ keycode = gdk_key_event_get_keycode ((GdkEvent *)key);
if (type == GDK_KEY_PRESS)
event->type = ATK_KEY_EVENT_PRESS;
diff --git a/gtk/gtkbindings.c b/gtk/gtkbindings.c
index fd4d62b0b0..949c8cf65a 100644
--- a/gtk/gtkbindings.c
+++ b/gtk/gtkbindings.c
@@ -1771,9 +1771,6 @@ gtk_bindings_activate_event (GObject *object,
GdkDisplay *display;
GtkKeyHash *key_hash;
gboolean handled = FALSE;
- guint16 keycode;
- GdkModifierType state;
- guint group;
if (!GTK_IS_WIDGET (object))
return FALSE;
@@ -1781,15 +1778,11 @@ gtk_bindings_activate_event (GObject *object,
display = gtk_widget_get_display (GTK_WIDGET (object));
key_hash = binding_key_hash_for_keymap (gdk_display_get_keymap (display));
- gdk_event_get_keycode ((GdkEvent *)event, &keycode);
- gdk_event_get_state ((GdkEvent *)event, &state);
- gdk_event_get_key_group ((GdkEvent *)event, &group);
-
entries = _gtk_key_hash_lookup (key_hash,
- keycode,
- state,
+ gdk_key_event_get_keycode ((GdkEvent *)event),
+ gdk_event_get_modifier_state ((GdkEvent *)event),
BINDING_MOD_MASK () & ~GDK_RELEASE_MASK,
- group);
+ gdk_key_event_get_group((GdkEvent *)event));
handled = gtk_bindings_activate_list (object, entries,
gdk_event_get_event_type ((GdkEvent *) event) == GDK_KEY_RELEASE);
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index b8ee4dd2f6..7da11fb7d5 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -322,7 +322,7 @@ touch_release_in_button (GtkButton *button)
return FALSE;
}
- gdk_event_get_coords (event, &x, &y);
+ gdk_event_get_position (event, &x, &y);
gdk_event_unref (event);
diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c
index b8945d6544..e9b10bd355 100644
--- a/gtk/gtkcellarea.c
+++ b/gtk/gtkcellarea.c
@@ -1024,12 +1024,9 @@ gtk_cell_area_real_event (GtkCellArea *area,
if (event_type == GDK_KEY_PRESS && (flags & GTK_CELL_RENDERER_FOCUSED) != 0)
{
- guint keyval;
-
/* Cancel any edits in progress */
if (priv->edited_cell &&
- gdk_event_get_keyval (event, &keyval) &&
- keyval == GDK_KEY_Escape)
+ gdk_key_event_get_keyval (event) == GDK_KEY_Escape)
{
gtk_cell_area_stop_editing (area, TRUE);
retval = TRUE;
@@ -1039,7 +1036,8 @@ gtk_cell_area_real_event (GtkCellArea *area,
{
guint button;
- if (gdk_event_get_button (event, &button) && button == GDK_BUTTON_PRIMARY)
+ button = gdk_button_event_get_button (event);
+ if (button == GDK_BUTTON_PRIMARY)
{
GtkCellRenderer *renderer = NULL;
GtkCellRenderer *focus_renderer;
@@ -1048,7 +1046,7 @@ gtk_cell_area_real_event (GtkCellArea *area,
/* We may need some semantics to tell us the offset of the event
* window we are handling events for (i.e. GtkTreeView has a bin_window) */
- gdk_event_get_coords (event, &event_x, &event_y);
+ gdk_event_get_position (event, &event_x, &event_y);
/* Dont try to search for an event coordinate that is not in the area, that will
* trigger a runtime warning.
diff --git a/gtk/gtkdragdest.c b/gtk/gtkdragdest.c
index 708a90b97f..7ce1680f71 100644
--- a/gtk/gtkdragdest.c
+++ b/gtk/gtkdragdest.c
@@ -758,7 +758,7 @@ gtk_drop_target_handle_event (GtkEventController *controller,
GtkDropStatus status;
gboolean found = FALSE;
- drop = gdk_event_get_drop (event);
+ drop = gdk_drag_event_get_drop (event);
status = gtk_drop_target_get_drop_status (dest, drop);
if (status == GTK_DROP_STATUS_DENIED)
@@ -810,7 +810,7 @@ gtk_drag_dest_handle_event (GtkWidget *toplevel,
g_return_if_fail (event != NULL);
event_type = gdk_event_get_event_type (event);
- drop = gdk_event_get_drop (event);
+ drop = gdk_drag_event_get_drop (event);
switch ((guint) event_type)
{
diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c
index 2de0dcc5e6..155c7cc84a 100644
--- a/gtk/gtkdragsource.c
+++ b/gtk/gtkdragsource.c
@@ -207,7 +207,7 @@ gtk_drag_source_filter_event (GtkEventController *controller,
guint n_fingers;
g_object_get (G_OBJECT (controller), "n-points", &n_points, NULL);
- gdk_event_get_touchpad_gesture_n_fingers (event, &n_fingers);
+ n_fingers = gdk_touchpad_event_get_n_fingers (event);
if (n_fingers == n_points)
return FALSE;
diff --git a/gtk/gtkeventcontrollerkey.c b/gtk/gtkeventcontrollerkey.c
index 5c6765b222..a8a5912d33 100644
--- a/gtk/gtkeventcontrollerkey.c
+++ b/gtk/gtkeventcontrollerkey.c
@@ -120,7 +120,7 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
key->current_event = event;
- gdk_event_get_state (event, &state);
+ state = gdk_event_get_modifier_state (event);
if (key->state != state)
{
gboolean unused;
@@ -129,8 +129,8 @@ gtk_event_controller_key_handle_event (GtkEventController *controller,
g_signal_emit (controller, signals[MODIFIERS], 0, state, &unused);
}
- gdk_event_get_keycode (event, &keycode);
- gdk_event_get_keyval (event, &keyval);
+ keycode = gdk_key_event_get_keycode (event);
+ keyval = gdk_key_event_get_keyval (event);
if (event_type == GDK_KEY_PRESS)
{
@@ -495,21 +495,17 @@ gtk_event_controller_key_forward (GtkEventControllerKey *controller,
* @controller: a #GtkEventControllerKey
*
* Gets the key group of the current event of this @controller.
- * See gdk_event_get_key_group().
+ * See gdk_key_event_get_group().
*
* Returns: the key group
**/
guint
gtk_event_controller_key_get_group (GtkEventControllerKey *controller)
{
- guint group;
-
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_KEY (controller), FALSE);
g_return_val_if_fail (controller->current_event != NULL, FALSE);
- gdk_event_get_key_group (controller->current_event, &group);
-
- return group;
+ return gdk_key_event_get_group (controller->current_event);
}
/**
diff --git a/gtk/gtkeventcontrollerscroll.c b/gtk/gtkeventcontrollerscroll.c
index 07d44c4b44..d1e43491de 100644
--- a/gtk/gtkeventcontrollerscroll.c
+++ b/gtk/gtkeventcontrollerscroll.c
@@ -249,17 +249,20 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
if (gdk_event_get_event_type (event) != GDK_SCROLL)
return FALSE;
+
if ((scroll->flags & (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL |
GTK_EVENT_CONTROLLER_SCROLL_HORIZONTAL)) == 0)
return FALSE;
/* FIXME: Handle device changes */
-
- if (gdk_event_get_scroll_deltas (event, &dx, &dy))
+ direction = gdk_scroll_event_get_direction (event);
+ if (direction == GDK_SCROLL_SMOOTH)
{
GdkDevice *device = gdk_event_get_source_device (event);
GdkInputSource input_source = gdk_device_get_source (device);
+ gdk_scroll_event_get_deltas (event, &dx, &dy);
+
if (!scroll->active &&
(input_source == GDK_SOURCE_TRACKPOINT ||
input_source == GDK_SOURCE_TOUCHPAD))
@@ -297,7 +300,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
}
}
}
- else if (gdk_event_get_scroll_direction (event, &direction))
+ else
{
switch (direction)
{
@@ -333,7 +336,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
scroll_history_push (scroll, dx, dy, gdk_event_get_time (event));
}
- if (scroll->active && gdk_event_is_scroll_stop_event (event))
+ if (scroll->active && gdk_scroll_event_is_stop (event))
{
g_signal_emit (controller, signals[SCROLL_END], 0);
scroll->active = FALSE;
diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c
index c92d939246..f300993343 100644
--- a/gtk/gtkgesture.c
+++ b/gtk/gtkgesture.c
@@ -236,7 +236,7 @@ _gtk_gesture_get_n_touchpad_points (GtkGesture *gesture,
GtkGesturePrivate *priv;
PointData *data;
GdkEventType event_type;
- GdkTouchpadGesturePhase phase;
+ GdkTouchpadGesturePhase phase = 0;
guint n_fingers = 0;
priv = gtk_gesture_get_instance_private (gesture);
@@ -251,7 +251,11 @@ _gtk_gesture_get_n_touchpad_points (GtkGesture *gesture,
event_type = gdk_event_get_event_type (data->event);
- gdk_event_get_touchpad_gesture_phase (data->event, &phase);
+ if (EVENT_IS_TOUCHPAD_GESTURE (data->event))
+ {
+ phase = gdk_touchpad_event_get_gesture_phase (data->event);
+ n_fingers = gdk_touchpad_event_get_n_fingers (data->event);
+ }
if (only_active &&
(data->state == GTK_EVENT_SEQUENCE_DENIED ||
@@ -259,9 +263,6 @@ _gtk_gesture_get_n_touchpad_points (GtkGesture *gesture,
(event_type == GDK_TOUCHPAD_PINCH && phase == GDK_TOUCHPAD_GESTURE_PHASE_END)))
return 0;
- if (!gdk_event_get_touchpad_gesture_n_fingers (data->event, &n_fingers))
- return 0;
-
return n_fingers;
}
@@ -390,7 +391,6 @@ static void
_update_touchpad_deltas (PointData *data)
{
GdkEvent *event = data->event;
- GdkEventType event_type;
GdkTouchpadGesturePhase phase;
double dx;
double dy;
@@ -398,13 +398,10 @@ _update_touchpad_deltas (PointData *data)
if (!event)
return;
- event_type = gdk_event_get_event_type (event);
- gdk_event_get_touchpad_gesture_phase (event, &phase);
- gdk_event_get_touchpad_deltas (event, &dx, &dy);
-
- if (event_type == GDK_TOUCHPAD_SWIPE ||
- event_type == GDK_TOUCHPAD_PINCH)
+ if (EVENT_IS_TOUCHPAD_GESTURE (event))
{
+ phase = gdk_touchpad_event_get_gesture_phase (event);
+ gdk_touchpad_event_get_deltas (event, &dx, &dy);
if (phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN)
data->accum_dx = data->accum_dy = 0;
else if (phase == GDK_TOUCHPAD_GESTURE_PHASE_UPDATE)
@@ -452,9 +449,6 @@ _gtk_gesture_update_point (GtkGesture *gesture,
gboolean existed, touchpad;
PointData *data;
- if (!gdk_event_get_coords (event, NULL, NULL))
- return FALSE;
-
device = gdk_event_get_device (event);
if (!device)
@@ -613,7 +607,7 @@ gtk_gesture_handle_event (GtkEventController *controller,
GdkDevice *source_device;
gboolean was_recognized;
GdkEventType event_type;
- GdkTouchpadGesturePhase phase;
+ GdkTouchpadGesturePhase phase = 0;
GdkModifierType state;
GtkWidget *target;
@@ -626,8 +620,9 @@ gtk_gesture_handle_event (GtkEventController *controller,
sequence = gdk_event_get_event_sequence (event);
was_recognized = gtk_gesture_is_recognized (gesture);
event_type = gdk_event_get_event_type (event);
- gdk_event_get_state (event, &state);
- gdk_event_get_touchpad_gesture_phase (event, &phase);
+ state = gdk_event_get_modifier_state (event);
+ if (EVENT_IS_TOUCHPAD_GESTURE (event))
+ phase = gdk_touchpad_event_get_gesture_phase (event);
target = gtk_event_controller_get_target (controller);
@@ -715,9 +710,9 @@ gtk_gesture_handle_event (GtkEventController *controller,
}
else if (event_type == GDK_GRAB_BROKEN)
{
- GdkSurface *surface = NULL;
+ GdkSurface *surface;
- gdk_event_get_grab_surface (event, &surface);
+ surface = gdk_grab_broken_event_get_grab_surface (event);
if (!surface || !gesture_within_surface (gesture, surface))
_gtk_gesture_cancel_all (gesture);
@@ -1299,7 +1294,7 @@ gtk_gesture_get_bounding_box (GtkGesture *gesture,
event_type == GDK_BUTTON_RELEASE)
continue;
- gdk_event_get_coords (data->event, &x, &y);
+ gdk_event_get_position (data->event, &x, &y);
n_points++;
x1 = MIN (x1, x);
y1 = MIN (y1, y);
@@ -1621,7 +1616,6 @@ _gtk_gesture_get_pointer_emulating_sequence (GtkGesture *gesture,
GdkEventSequence *seq;
GHashTableIter iter;
PointData *data;
- gboolean emulating;
g_return_val_if_fail (GTK_IS_GESTURE (gesture), FALSE);
@@ -1635,8 +1629,7 @@ _gtk_gesture_get_pointer_emulating_sequence (GtkGesture *gesture,
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_UPDATE:
case GDK_TOUCH_END:
- gdk_event_get_touch_emulating_pointer (data->event, &emulating);
- if (!emulating)
+ if (!gdk_touch_event_get_emulating_pointer (data->event))
continue;
/* Fall through */
case GDK_BUTTON_PRESS:
diff --git a/gtk/gtkgestureclick.c b/gtk/gtkgestureclick.c
index ba815e4eb8..9d8e95404f 100644
--- a/gtk/gtkgestureclick.c
+++ b/gtk/gtkgestureclick.c
@@ -213,7 +213,7 @@ gtk_gesture_click_begin (GtkGesture *gesture,
event_type = gdk_event_get_event_type (event);
if (event_type == GDK_BUTTON_PRESS)
- gdk_event_get_button (event, &button);
+ button = gdk_button_event_get_button (event);
else if (event_type == GDK_TOUCH_BEGIN)
button = 1;
else
@@ -325,7 +325,9 @@ gtk_gesture_click_handle_event (GtkEventController *controller,
(gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE ||
gdk_event_get_event_type (event) == GDK_TOUCH_END))
{
- if (!gdk_event_get_button (event, &button))
+ if (gdk_event_get_event_type (event) == GDK_BUTTON_RELEASE)
+ button = gdk_button_event_get_button (event);
+ else
button = 0;
g_signal_emit (controller, signals[UNPAIRED_RELEASE], 0,
x, y, button, sequence);
diff --git a/gtk/gtkgesturedrag.c b/gtk/gtkgesturedrag.c
index fa63ba8f45..be03a7a291 100644
--- a/gtk/gtkgesturedrag.c
+++ b/gtk/gtkgesturedrag.c
@@ -69,7 +69,7 @@ gtk_gesture_drag_filter_event (GtkEventController *controller,
guint n_fingers;
g_object_get (G_OBJECT (controller), "n-points", &n_points, NULL);
- gdk_event_get_touchpad_gesture_n_fingers (event, &n_fingers);
+ n_fingers = gdk_touchpad_event_get_n_fingers (event);
if (n_fingers == n_points)
return FALSE;
diff --git a/gtk/gtkgesturerotate.c b/gtk/gtkgesturerotate.c
index fa0568fb70..2f0541ab78 100644
--- a/gtk/gtkgesturerotate.c
+++ b/gtk/gtkgesturerotate.c
@@ -97,7 +97,7 @@ _gtk_gesture_rotate_get_angle (GtkGestureRotate *rotate,
goto out;
last_event = gtk_gesture_get_last_event (gesture, sequences->data);
- gdk_event_get_touchpad_gesture_phase (last_event, &phase);
+ phase = gdk_touchpad_event_get_gesture_phase (last_event);
if (gdk_event_get_event_type (last_event) == GDK_TOUCHPAD_PINCH &&
(phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN ||
@@ -179,7 +179,7 @@ gtk_gesture_rotate_filter_event (GtkEventController *controller,
{
guint n_fingers;
- gdk_event_get_touchpad_gesture_n_fingers (event, &n_fingers);
+ n_fingers = gdk_touchpad_event_get_n_fingers (event);
if (n_fingers == 2)
return FALSE;
@@ -203,11 +203,10 @@ gtk_gesture_rotate_handle_event (GtkEventController *controller,
priv = gtk_gesture_rotate_get_instance_private (rotate);
- gdk_event_get_touchpad_gesture_phase (event, &phase);
- gdk_event_get_touchpad_angle_delta (event, &delta);
-
if (gdk_event_get_event_type (event) == GDK_TOUCHPAD_PINCH)
{
+ phase = gdk_touchpad_event_get_gesture_phase (event);
+ delta = gdk_touchpad_pinch_event_get_angle_delta (event);
if (phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN ||
phase == GDK_TOUCHPAD_GESTURE_PHASE_END)
priv->accum_touchpad_angle = 0;
diff --git a/gtk/gtkgesturesingle.c b/gtk/gtkgesturesingle.c
index b99eee1823..6e3dd3b406 100644
--- a/gtk/gtkgesturesingle.c
+++ b/gtk/gtkgesturesingle.c
@@ -142,7 +142,6 @@ gtk_gesture_single_handle_event (GtkEventController *controller,
guint button = 0, state, i;
gboolean retval, test_touchscreen = FALSE;
GdkEventType event_type;
- gboolean emulating;
source_device = gdk_event_get_source_device (event);
@@ -162,8 +161,7 @@ gtk_gesture_single_handle_event (GtkEventController *controller,
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_END:
case GDK_TOUCH_UPDATE:
- gdk_event_get_touch_emulating_pointer (event, &emulating);
- if (priv->exclusive && !emulating)
+ if (priv->exclusive && !gdk_touch_event_get_emulating_pointer (event))
return FALSE;
sequence = gdk_event_get_event_sequence (event);
@@ -174,15 +172,14 @@ gtk_gesture_single_handle_event (GtkEventController *controller,
if (priv->touch_only && !test_touchscreen && source != GDK_SOURCE_TOUCHSCREEN)
return FALSE;
- gdk_event_get_button (event, &button);
+ button = gdk_button_event_get_button (event);
break;
case GDK_MOTION_NOTIFY:
if (!gtk_gesture_handles_sequence (GTK_GESTURE (controller), sequence))
return FALSE;
if (priv->touch_only && !test_touchscreen && source != GDK_SOURCE_TOUCHSCREEN)
return FALSE;
- if (!gdk_event_get_state (event, &state))
- return FALSE;
+ state = gdk_event_get_modifier_state (event);
if (priv->current_button > 0 && priv->current_button <= 5 &&
(state & (GDK_BUTTON1_MASK << (priv->current_button - 1))))
diff --git a/gtk/gtkgesturestylus.c b/gtk/gtkgesturestylus.c
index 610c7fb6ae..5d98a08b24 100644
--- a/gtk/gtkgesturestylus.c
+++ b/gtk/gtkgesturestylus.c
@@ -70,7 +70,7 @@ gtk_gesture_stylus_handle_event (GtkEventController *controller,
n_signal = UP;
break;
case GDK_MOTION_NOTIFY:
- gdk_event_get_state (event, &modifiers);
+ modifiers = gdk_event_get_modifier_state (event);
if (modifiers & GDK_BUTTON1_MASK)
n_signal = MOTION;
diff --git a/gtk/gtkgestureswipe.c b/gtk/gtkgestureswipe.c
index eb0a04a195..5aba66dd70 100644
--- a/gtk/gtkgestureswipe.c
+++ b/gtk/gtkgestureswipe.c
@@ -92,7 +92,7 @@ gtk_gesture_swipe_filter_event (GtkEventController *controller,
g_object_get (G_OBJECT (controller), "n-points", &n_points, NULL);
- gdk_event_get_touchpad_gesture_n_fingers (event, &n_fingers);
+ n_fingers = gdk_touchpad_event_get_n_fingers (event);
if (n_fingers == n_points)
return FALSE;
diff --git a/gtk/gtkgesturezoom.c b/gtk/gtkgesturezoom.c
index 402d313912..3eefa3f60a 100644
--- a/gtk/gtkgesturezoom.c
+++ b/gtk/gtkgesturezoom.c
@@ -94,7 +94,7 @@ _gtk_gesture_zoom_get_distance (GtkGestureZoom *zoom,
goto out;
last_event = gtk_gesture_get_last_event (gesture, sequences->data);
- gdk_event_get_touchpad_gesture_phase (last_event, &phase);
+ phase = gdk_touchpad_event_get_gesture_phase (last_event);
if (gdk_event_get_event_type (last_event) == GDK_TOUCHPAD_PINCH &&
(phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN ||
@@ -104,7 +104,7 @@ _gtk_gesture_zoom_get_distance (GtkGestureZoom *zoom,
double scale;
/* Touchpad pinch */
- gdk_event_get_touchpad_scale (last_event, &scale);
+ scale = gdk_touchpad_pinch_event_get_scale (last_event);
*distance = scale;
}
else
@@ -156,7 +156,7 @@ gtk_gesture_zoom_filter_event (GtkEventController *controller,
{
guint n_fingers;
- gdk_event_get_touchpad_gesture_n_fingers (event, &n_fingers);
+ n_fingers = gdk_touchpad_event_get_n_fingers (event);
if (n_fingers == 2)
return FALSE;
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 3f0de76ca6..520f869dec 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -2134,12 +2134,12 @@ gtk_icon_view_button_press (GtkGestureClick *gesture,
if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
- if (button == GDK_BUTTON_PRIMARY &&
- gdk_event_get_state ((GdkEvent *) event, &state))
+ if (button == GDK_BUTTON_PRIMARY)
{
GdkModifierType extend_mod_mask;
GdkModifierType modify_mod_mask;
+ state = gdk_event_get_modifier_state ((GdkEvent *)event);
extend_mod_mask =
gtk_widget_get_modifier_mask (widget, GDK_MODIFIER_INTENT_EXTEND_SELECTION);
@@ -2280,7 +2280,7 @@ button_event_modifies_selection (GdkEventButton *event)
{
guint state;
- gdk_event_get_state ((GdkEvent *) event, &state);
+ state = gdk_event_get_modifier_state ((GdkEvent *) event);
return (state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
}
diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index f2cd39d9ed..5fdcc8533d 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -893,7 +893,7 @@ beep_surface (GdkSurface *surface)
static gboolean
no_sequence_matches (GtkIMContextSimple *context_simple,
gint n_compose,
- GdkEventKey *event)
+ GdkEvent *event)
{
GtkIMContextSimplePrivate *priv = context_simple->priv;
GtkIMContext *context;
@@ -917,11 +917,11 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
{
guint tmp_keyval = priv->compose_buffer[len + i];
GdkEvent *tmp_event = gdk_event_key_new (GDK_KEY_PRESS,
- event->any.surface,
- event->any.device,
- event->any.source_device,
- event->time,
- event->state,
+ gdk_event_get_surface (event),
+ gdk_event_get_device (event),
+ gdk_event_get_source_device (event),
+ gdk_event_get_time (event),
+ gdk_event_get_modifier_state (event),
tmp_keyval,
tmp_keyval,
tmp_keyval,
@@ -932,14 +932,16 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
g_object_unref (tmp_event);
}
- return gtk_im_context_filter_keypress (context, event);
+ return gtk_im_context_filter_keypress (context, (GdkEventKey *)event);
}
- else if (gdk_event_get_keyval ((GdkEvent *) event, &keyval))
+ else
{
+ keyval = gdk_key_event_get_keyval (event);
+
priv->compose_buffer[0] = 0;
if (n_compose > 1) /* Invalid sequence */
{
- beep_surface (gdk_event_get_surface ((GdkEvent *) event));
+ beep_surface (gdk_event_get_surface (event));
return TRUE;
}
@@ -952,8 +954,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
else
return FALSE;
}
- else
- return FALSE;
+ return FALSE;
}
static gboolean
@@ -974,8 +975,7 @@ canonical_hex_keyval (GdkEventKey *event)
gint n_vals = 0;
gint i;
- if (!gdk_event_get_keyval ((GdkEvent *) event, &event_keyval))
- return 0;
+ event_keyval = gdk_key_event_get_keyval ((GdkEvent *)event);
/* See if the keyval is already a hex digit */
if (is_hex_keyval (event_keyval))
@@ -985,7 +985,7 @@ canonical_hex_keyval (GdkEventKey *event)
* any other state, and return that hex keyval if so
*/
gdk_keymap_get_entries_for_keycode (keymap,
- gdk_event_get_scancode ((GdkEvent *) event),
+ gdk_key_event_get_scancode ((GdkEvent *) event),
NULL,
&keyvals, &n_vals);
@@ -1039,9 +1039,8 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
while (priv->compose_buffer[n_compose] != 0)
n_compose++;
- if (!gdk_event_get_keyval ((GdkEvent *) event, &keyval) ||
- !gdk_event_get_state ((GdkEvent *) event, &state))
- return GDK_EVENT_PROPAGATE;
+ keyval = gdk_key_event_get_keyval ((GdkEvent *)event);
+ state = gdk_event_get_modifier_state ((GdkEvent *)event);
if (gdk_event_get_event_type ((GdkEvent *) event) == GDK_KEY_RELEASE)
{
@@ -1355,7 +1354,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
}
/* The current compose_buffer doesn't match anything */
- return no_sequence_matches (context_simple, n_compose, event);
+ return no_sequence_matches (context_simple, n_compose, (GdkEvent *)event);
}
static void
diff --git a/gtk/gtkimmulticontext.c b/gtk/gtkimmulticontext.c
index 0ab67eddf2..2818241e11 100644
--- a/gtk/gtkimmulticontext.c
+++ b/gtk/gtkimmulticontext.c
@@ -353,13 +353,14 @@ gtk_im_multicontext_filter_keypress (GtkIMContext *context,
{
return gtk_im_context_filter_keypress (slave, event);
}
- else if (gdk_event_get_keyval ((GdkEvent *) event, &keyval) &&
- gdk_event_get_state ((GdkEvent *) event, &state))
+ else
{
GdkDisplay *display;
GdkModifierType no_text_input_mask;
- display = gdk_surface_get_display (gdk_event_get_surface ((GdkEvent *) event));
+ keyval = gdk_key_event_get_keyval ((GdkEvent *) event);
+ state = gdk_event_get_modifier_state ((GdkEvent *) event);
+ display = gdk_event_get_display ((GdkEvent *) event);
no_text_input_mask =
gdk_keymap_get_modifier_mask (gdk_display_get_keymap (display),
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 60d3898c18..1c7d1ba130 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -4648,7 +4648,7 @@ gtk_label_drag_gesture_begin (GtkGestureDrag *gesture,
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
- gdk_event_get_state (event, &state_mask);
+ state_mask = gdk_event_get_modifier_state (event);
if ((info->selection_anchor != info->selection_end) &&
(state_mask & GDK_SHIFT_MASK))
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index a51b428610..c17636beff 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1078,74 +1078,92 @@ static GdkEvent *
rewrite_event_for_surface (GdkEvent *event,
GdkSurface *new_surface)
{
+ GdkEventType type;
double x, y;
+ double dx, dy;
- if (!gdk_event_get_coords (event, &x, &y) ||
- !gdk_surface_translate_coordinates (event->any.surface, new_surface, &x, &y))
+ type = gdk_event_get_event_type (event);
+
+ switch ((guint) type)
{
+ case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ case GDK_MOTION_NOTIFY:
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_TOUCH_CANCEL:
+ case GDK_TOUCHPAD_SWIPE:
+ case GDK_TOUCHPAD_PINCH:
+ gdk_event_get_position (event, &x, &y);
+ gdk_surface_translate_coordinates (gdk_event_get_surface (event), new_surface, &x, &y);
+ break;
+ default:
x = y = 0;
+ break;
}
- switch ((guint) event->any.type)
+ switch ((guint) type)
{
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
- return gdk_event_button_new (event->any.type,
+ return gdk_event_button_new (type,
new_surface,
- event->any.device,
- event->any.source_device,
- event->button.tool,
- event->button.time,
- event->button.state,
- event->button.button,
+ gdk_event_get_device (event),
+ gdk_event_get_source_device (event),
+ gdk_event_get_device_tool (event),
+ gdk_event_get_time (event),
+ gdk_event_get_modifier_state (event),
+ gdk_button_event_get_button (event),
x, y,
NULL); // FIXME copy axes
case GDK_MOTION_NOTIFY:
return gdk_event_motion_new (new_surface,
- event->any.device,
- event->any.source_device,
- event->motion.tool,
- event->motion.time,
- event->motion.state,
+ gdk_event_get_device (event),
+ gdk_event_get_source_device (event),
+ gdk_event_get_device_tool (event),
+ gdk_event_get_time (event),
+ gdk_event_get_modifier_state (event),
x, y,
NULL); // FIXME copy axes
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_UPDATE:
case GDK_TOUCH_END:
case GDK_TOUCH_CANCEL:
- return gdk_event_touch_new (event->any.type,
- event->touch.sequence,
+ return gdk_event_touch_new (type,
+ gdk_event_get_event_sequence (event),
new_surface,
- event->any.device,
- event->any.source_device,
- event->touch.time,
- event->touch.state,
+ gdk_event_get_device (event),
+ gdk_event_get_source_device (event),
+ gdk_event_get_time (event),
+ gdk_event_get_modifier_state (event),
x, y,
NULL, // FIXME copy axes
- event->touch.emulating_pointer);
+ gdk_touch_event_get_emulating_pointer (event));
case GDK_TOUCHPAD_SWIPE:
+ gdk_touchpad_event_get_deltas (event, &dx, &dy);
return gdk_event_touchpad_swipe_new (new_surface,
- event->any.device,
- event->any.source_device,
- event->touchpad_swipe.time,
- event->touchpad_swipe.state,
+ gdk_event_get_device (event),
+ gdk_event_get_source_device (event),
+ gdk_event_get_time (event),
+ gdk_event_get_modifier_state (event),
+ gdk_touchpad_event_get_gesture_phase (event),
x, y,
- event->touchpad_swipe.n_fingers,
- event->touchpad_swipe.dx,
- event->touchpad_swipe.dy);
+ gdk_touchpad_event_get_n_fingers (event),
+ dx, dy);
case GDK_TOUCHPAD_PINCH:
+ gdk_touchpad_event_get_deltas (event, &dx, &dy);
return gdk_event_touchpad_pinch_new (new_surface,
- event->any.device,
- event->any.source_device,
- event->touchpad_pinch.time,
- event->touchpad_pinch.state,
- event->touchpad_pinch.phase,
+ gdk_event_get_device (event),
+ gdk_event_get_source_device (event),
+ gdk_event_get_time (event),
+ gdk_event_get_modifier_state (event),
+ gdk_touchpad_event_get_gesture_phase (event),
x, y,
- event->touchpad_pinch.n_fingers,
- event->touchpad_pinch.dx,
- event->touchpad_pinch.dy,
- event->touchpad_pinch.scale,
- event->touchpad_pinch.angle_delta);
+ gdk_touchpad_event_get_n_fingers (event),
+ dx, dy,
+ gdk_touchpad_pinch_event_get_scale (event),
+ gdk_touchpad_pinch_event_get_angle_delta (event));
default:
break;
}
@@ -1169,7 +1187,7 @@ rewrite_event_for_grabs (GdkEvent *event)
GdkDisplay *display;
GdkDevice *device;
- switch ((guint) event->any.type)
+ switch ((guint) gdk_event_get_event_type (event))
{
case GDK_SCROLL:
case GDK_BUTTON_PRESS:
@@ -1185,7 +1203,7 @@ rewrite_event_for_grabs (GdkEvent *event)
case GDK_TOUCH_CANCEL:
case GDK_TOUCHPAD_SWIPE:
case GDK_TOUCHPAD_PINCH:
- display = gdk_surface_get_display (event->any.surface);
+ display = gdk_event_get_display (event);
device = gdk_event_get_device (event);
if (!gdk_device_grab_info (display, device, &grab_surface, &owner_events) ||
@@ -1266,7 +1284,7 @@ translate_event_coordinates (GdkEvent *event,
*x = *y = 0;
- if (!gdk_event_get_coords (event, &event_x, &event_y))
+ if (!gdk_event_get_position (event, &event_x, &event_y))
return FALSE;
event_widget = gtk_get_event_widget (event);
@@ -1348,7 +1366,7 @@ update_pointer_focus_state (GtkWindow *toplevel,
if (old_target == new_target)
return old_target;
- gdk_event_get_coords (event, &x, &y);
+ gdk_event_get_position (event, &x, &y);
gtk_window_update_pointer_focus (toplevel, device, sequence,
new_target, x, y);
@@ -1358,7 +1376,7 @@ update_pointer_focus_state (GtkWindow *toplevel,
static gboolean
is_pointing_event (GdkEvent *event)
{
- switch ((guint) event->any.type)
+ switch ((guint) gdk_event_get_event_type (event))
{
case GDK_MOTION_NOTIFY:
case GDK_ENTER_NOTIFY:
@@ -1382,7 +1400,7 @@ is_pointing_event (GdkEvent *event)
static gboolean
is_key_event (GdkEvent *event)
{
- switch ((guint) event->any.type)
+ switch ((guint) gdk_event_get_event_type (event))
{
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
@@ -1396,7 +1414,7 @@ is_key_event (GdkEvent *event)
static gboolean
is_focus_event (GdkEvent *event)
{
- switch ((guint) event->any.type)
+ switch ((guint) gdk_event_get_event_type (event))
{
case GDK_FOCUS_CHANGE:
return TRUE;
@@ -1409,7 +1427,7 @@ is_focus_event (GdkEvent *event)
static gboolean
is_dnd_event (GdkEvent *event)
{
- switch ((guint) event->any.type)
+ switch ((guint) gdk_event_get_event_type (event))
{
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
@@ -1448,21 +1466,22 @@ handle_pointing_event (GdkEvent *event)
GdkDevice *device;
gdouble x, y;
GtkWidget *native;
+ GdkEventType type;
event_widget = gtk_get_event_widget (event);
device = gdk_event_get_device (event);
- if (!device || !gdk_event_get_coords (event, &x, &y))
- return event_widget;
+ gdk_event_get_position (event, &x, &y);
toplevel = GTK_WINDOW (gtk_widget_get_root (event_widget));
native = GTK_WIDGET (gtk_widget_get_native (event_widget));
+ type = gdk_event_get_event_type (event);
sequence = gdk_event_get_event_sequence (event);
- switch ((guint) event->any.type)
+ switch ((guint) type)
{
case GDK_LEAVE_NOTIFY:
- if (event->crossing.mode == GDK_CROSSING_NORMAL &&
+ if (gdk_crossing_event_get_mode (event) == GDK_CROSSING_NORMAL &&
gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device, NULL))
{
/* We have an implicit grab, wait for the corresponding
@@ -1474,14 +1493,13 @@ handle_pointing_event (GdkEvent *event)
case GDK_TOUCH_END:
case GDK_TOUCH_CANCEL:
old_target = update_pointer_focus_state (toplevel, event, NULL);
-
- if (event->any.type == GDK_LEAVE_NOTIFY)
+ if (type == GDK_LEAVE_NOTIFY)
gtk_synthesize_crossing_events (GTK_ROOT (toplevel), old_target, NULL,
- event, event->crossing.mode);
+ event, gdk_crossing_event_get_mode (event));
break;
case GDK_ENTER_NOTIFY:
- if (event->crossing.mode == GDK_CROSSING_GRAB ||
- event->crossing.mode == GDK_CROSSING_UNGRAB)
+ if (gdk_crossing_event_get_mode (event) == GDK_CROSSING_GRAB ||
+ gdk_crossing_event_get_mode (event) == GDK_CROSSING_UNGRAB)
break;
G_GNUC_FALLTHROUGH;
case GDK_TOUCH_BEGIN:
@@ -1497,7 +1515,7 @@ handle_pointing_event (GdkEvent *event)
old_target = update_pointer_focus_state (toplevel, event, target);
- if (event->any.type == GDK_MOTION_NOTIFY || event->any.type == GDK_ENTER_NOTIFY)
+ if (type == GDK_MOTION_NOTIFY || type == GDK_ENTER_NOTIFY)
{
if (!gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device,
sequence))
@@ -1509,7 +1527,7 @@ handle_pointing_event (GdkEvent *event)
gtk_window_maybe_update_cursor (toplevel, NULL, device);
}
- if (event->any.type == GDK_TOUCH_BEGIN)
+ if (type == GDK_TOUCH_BEGIN)
gtk_window_set_pointer_focus_grab (toplevel, device, sequence, target);
/* Let it take the effective pointer focus anyway, as it may change due
@@ -1523,10 +1541,10 @@ handle_pointing_event (GdkEvent *event)
device,
sequence);
gtk_window_set_pointer_focus_grab (toplevel, device, sequence,
- event->any.type == GDK_BUTTON_PRESS ?
+ type == GDK_BUTTON_PRESS ?
target : NULL);
- if (event->any.type == GDK_BUTTON_RELEASE)
+ if (type == GDK_BUTTON_RELEASE)
{
GtkWidget *new_target;
new_target = gtk_widget_pick (GTK_WIDGET (native), x, y, GTK_PICK_DEFAULT);
@@ -1537,7 +1555,7 @@ handle_pointing_event (GdkEvent *event)
gtk_window_maybe_update_cursor (toplevel, NULL, device);
}
- set_widget_active_state (target, event->any.type == GDK_BUTTON_RELEASE);
+ set_widget_active_state (target, type == GDK_BUTTON_RELEASE);
break;
case GDK_SCROLL:
@@ -1577,9 +1595,7 @@ handle_dnd_event (GdkEvent *event)
event_widget = gtk_get_event_widget (event);
- if (!gdk_event_get_coords (event, &x, &y))
- return event_widget;
-
+ gdk_event_get_position (event, &x, &y);
native = GTK_WIDGET (gtk_widget_get_native (event_widget));
target = gtk_widget_pick (native, x, y, GTK_PICK_DEFAULT);
@@ -1629,9 +1645,9 @@ gtk_main_do_event (GdkEvent *event)
target_widget = handle_pointing_event (event);
else if (is_key_event (event))
{
- if (event->any.type == GDK_KEY_PRESS &&
+ if (gdk_event_get_event_type (event) == GDK_KEY_PRESS &&
GTK_IS_WINDOW (target_widget) &&
- gtk_window_activate_key (GTK_WINDOW (target_widget), (GdkEventKey *) event))
+ gtk_window_activate_key (GTK_WINDOW (target_widget), event))
goto cleanup;
target_widget = handle_key_event (event);
@@ -1665,7 +1681,7 @@ gtk_main_do_event (GdkEvent *event)
* This is the key to implementing modality.
*/
if (!grab_widget ||
- ((gtk_widget_is_sensitive (target_widget) || event->any.type == GDK_SCROLL) &&
+ ((gtk_widget_is_sensitive (target_widget) || gdk_event_get_event_type (event) == GDK_SCROLL) &&
gtk_widget_is_ancestor (target_widget, grab_widget)))
grab_widget = target_widget;
@@ -1694,7 +1710,7 @@ gtk_main_do_event (GdkEvent *event)
* Drag events are also not redirected, since it isn't
* clear what the semantics of that would be.
*/
- switch ((guint)event->any.type)
+ switch ((guint)gdk_event_get_event_type (event))
{
case GDK_DELETE:
g_object_ref (target_widget);
@@ -2161,7 +2177,10 @@ gtk_get_current_event_state (GdkModifierType *state)
g_return_val_if_fail (state != NULL, FALSE);
if (current_events)
- return gdk_event_get_state (current_events->data, state);
+ {
+ *state = gdk_event_get_modifier_state (current_events->data);
+ return TRUE;
+ }
else
{
*state = 0;
@@ -2197,17 +2216,16 @@ gtk_get_current_event_device (void)
* Returns: (transfer none) (nullable): the widget that originally
* received @event, or %NULL
*/
-GtkWidget*
+GtkWidget *
gtk_get_event_widget (GdkEvent *event)
{
- GtkWidget *widget;
+ GdkSurface *surface;
- widget = NULL;
- if (event && event->any.surface &&
- (!gdk_surface_is_destroyed (event->any.surface)))
- widget = gtk_native_get_for_surface (event->any.surface);
+ surface = gdk_event_get_surface (event);
+ if (surface && !gdk_surface_is_destroyed (surface))
+ return gtk_native_get_for_surface (surface);
- return widget;
+ return NULL;
}
static gboolean
@@ -2234,7 +2252,7 @@ propagate_event_up (GtkWidget *widget,
* event
*/
if (!gtk_widget_is_sensitive (widget))
- handled_event = event->any.type != GDK_SCROLL;
+ handled_event = gdk_event_get_event_type (event) != GDK_SCROLL;
else if (gtk_widget_get_realized (widget))
handled_event = gtk_widget_event (widget, event, target);
@@ -2287,7 +2305,7 @@ propagate_event_down (GtkWidget *widget,
/* stop propagating on SCROLL, but don't handle the event, so it
* can propagate up again and reach its handling widget
*/
- if (event->any.type == GDK_SCROLL)
+ if (gdk_event_get_event_type (event) == GDK_SCROLL)
break;
else
handled_event = TRUE;
diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c
index 3be232061c..a9feb8dde5 100644
--- a/gtk/gtkmountoperation.c
+++ b/gtk/gtkmountoperation.c
@@ -1424,12 +1424,12 @@ do_popup_menu_for_process_tree_view (GtkWidget *widget,
op);
gtk_container_add (GTK_CONTAINER (menu), item);
- if (event && gdk_event_triggers_context_menu (event) &&
- gdk_event_get_coords (event, &x, &y))
+ if (event && gdk_event_triggers_context_menu (event))
{
GtkTreePath *path;
GtkTreeSelection *selection;
+ gdk_event_get_position (event, &x, &y);
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (op->priv->process_tree_view),
(gint) x,
(gint) y,
diff --git a/gtk/gtkpadcontroller.c b/gtk/gtkpadcontroller.c
index 455d538982..d3efc61426 100644
--- a/gtk/gtkpadcontroller.c
+++ b/gtk/gtkpadcontroller.c
@@ -240,7 +240,7 @@ gtk_pad_controller_handle_event (GtkEventController *controller,
guint index, mode, group;
gdouble value = 0;
- gdk_event_get_pad_group_mode (event, &group, &mode);
+ gdk_pad_event_get_group_mode (event, &group, &mode);
if (event_type == GDK_PAD_GROUP_MODE)
{
gtk_pad_controller_handle_mode_switch (pad_controller,
@@ -254,13 +254,13 @@ gtk_pad_controller_handle_event (GtkEventController *controller,
{
case GDK_PAD_BUTTON_PRESS:
type = GTK_PAD_ACTION_BUTTON;
- gdk_event_get_pad_button (event, &index);
+ index = gdk_pad_button_event_get_button (event);
break;
case GDK_PAD_RING:
case GDK_PAD_STRIP:
type = event_type == GDK_PAD_RING ?
GTK_PAD_ACTION_RING : GTK_PAD_ACTION_STRIP;
- gdk_event_get_pad_axis_value (event, &index, &value);
+ gdk_pad_axis_event_get_value (event, &index, &value);
break;
default:
return GDK_EVENT_PROPAGATE;
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 4f0b3dd5f8..4c0a800030 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1868,7 +1868,7 @@ gtk_range_click_gesture_pressed (GtkGestureClick *gesture,
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
- gdk_event_get_state (event, &state_mask);
+ state_mask = gdk_event_get_modifier_state (event);
shift_pressed = (state_mask & GDK_SHIFT_MASK) != 0;
source_device = gdk_event_get_source_device ((GdkEvent *) event);
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index f9190e4a15..ca035f5c2b 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1200,7 +1200,7 @@ captured_motion (GtkScrolledWindow *sw,
if (priv->vscrollbar_visible)
indicator_start_fade (&priv->vindicator, 1.0);
- gdk_event_get_state (event, &state);
+ state = gdk_event_get_modifier_state (event);
target = gtk_widget_pick (GTK_WIDGET (sw), x, y, GTK_PICK_DEFAULT);
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 85c0f6bc37..00c07d6d3f 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -2624,7 +2624,7 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
priv->select_words = FALSE;
priv->select_lines = FALSE;
- gdk_event_get_state (event, &state);
+ state = gdk_event_get_modifier_state (event);
extend_selection =
(state &
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 4d1ef31c72..c161237831 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -5178,14 +5178,6 @@ gtk_text_view_click_gesture_pressed (GtkGestureClick *gesture,
GTK_EVENT_SEQUENCE_CLAIMED);
gtk_text_view_reset_blink_time (text_view);
-#if 0
- /* debug hack */
- if (event->button == GDK_BUTTON_SECONDARY && (event->state & GDK_CONTROL_MASK) != 0)
- _gtk_text_buffer_spew (GTK_TEXT_VIEW (widget)->buffer);
- else if (event->button == GDK_BUTTON_SECONDARY)
- gtk_text_layout_spew (GTK_TEXT_VIEW (widget)->layout);
-#endif
-
device = gdk_event_get_source_device ((GdkEvent *) event);
is_touchscreen = gtk_simulate_touchscreen () ||
gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN;
@@ -5218,7 +5210,7 @@ gtk_text_view_click_gesture_pressed (GtkGestureClick *gesture,
gboolean extends = FALSE;
GdkModifierType state;
- gdk_event_get_state (event, &state);
+ state = gdk_event_get_modifier_state (event);
if (state &
gtk_widget_get_modifier_mask (GTK_WIDGET (text_view),
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index dd04c19e4e..f611b4f562 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -851,7 +851,7 @@ tooltips_enabled (GdkEvent *event)
return FALSE;
}
- gdk_event_get_state (event, &event_state);
+ event_state = gdk_event_get_modifier_state (event);
if ((event_state &
(GDK_BUTTON1_MASK |
GDK_BUTTON2_MASK |
@@ -886,7 +886,7 @@ _gtk_tooltip_handle_event (GtkWidget *target,
event_type = gdk_event_get_event_type (event);
surface = gdk_event_get_surface (event);
- gdk_event_get_coords (event, &dx, &dy);
+ gdk_event_get_position (event, &dx, &dy);
gtk_tooltip_handle_event_internal (event_type, surface, target, dx, dy);
}
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index ed40f73377..7a0585c645 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -2947,7 +2947,7 @@ gtk_tree_view_click_gesture_pressed (GtkGestureClick *gesture,
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
- gdk_event_get_state (event, &modifiers);
+ modifiers = gdk_event_get_modifier_state (event);
/* decide if we edit */
if (button == GDK_BUTTON_PRIMARY &&
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index bc9ce587dc..7968e5ff33 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2055,70 +2055,84 @@ _gtk_widget_emulate_press (GtkWidget *widget,
if (event_widget == widget)
return;
- gdk_event_get_coords (event, &x, &y);
- if (!gtk_widget_compute_point (event_widget,
- GTK_WIDGET (gtk_widget_get_root (event_widget)),
- &GRAPHENE_POINT_INIT (x, y),
- &p))
+ switch ((guint) gdk_event_get_event_type (event))
+ {
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
+ case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ case GDK_MOTION_NOTIFY:
+ gdk_event_get_position (event, &x, &y);
+ if (!gtk_widget_compute_point (event_widget,
+ GTK_WIDGET (gtk_widget_get_root (event_widget)),
+ &GRAPHENE_POINT_INIT (x, y),
+ &p))
+ return;
+ break;
+ default:
return;
+ }
- if (event->any.type == GDK_TOUCH_BEGIN ||
- event->any.type == GDK_TOUCH_UPDATE ||
- event->any.type == GDK_TOUCH_END)
+ switch ((guint) gdk_event_get_event_type (event))
{
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_UPDATE:
+ case GDK_TOUCH_END:
press = gdk_event_touch_new (GDK_TOUCH_BEGIN,
- event->touch.sequence,
- event->any.surface,
- event->any.device,
- event->any.source_device,
- event->touch.time,
- event->touch.state,
+ gdk_event_get_event_sequence (event),
+ gdk_event_get_surface (event),
+ gdk_event_get_device (event),
+ gdk_event_get_source_device (event),
+ gdk_event_get_time (event),
+ gdk_event_get_modifier_state (event),
p.x, p.y,
NULL,
- event->touch.emulating_pointer);
- }
- else if (event->any.type == GDK_BUTTON_PRESS ||
- event->any.type == GDK_BUTTON_RELEASE)
- {
- press = gdk_event_button_new (GDK_BUTTON_PRESS,
- event->any.surface,
- event->any.device,
- event->any.source_device,
- event->button.tool,
- event->button.time,
- event->button.state,
- event->button.button,
- p.x, p.y,
- NULL);
- }
- else if (event->any.type == GDK_MOTION_NOTIFY)
- {
- int button;
- if (event->motion.state & GDK_BUTTON3_MASK)
- button = 3;
- else if (event->motion.state & GDK_BUTTON2_MASK)
- button = 2;
- else
- {
- if ((event->motion.state & GDK_BUTTON1_MASK) == 0)
- g_critical ("Guessing button number 1 on generated button press event");
-
- button = 1;
- }
-
+ gdk_touch_event_get_emulating_pointer (event));
+ break;
+ case GDK_BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
press = gdk_event_button_new (GDK_BUTTON_PRESS,
- event->any.surface,
- event->any.device,
- event->any.source_device,
- NULL,
- event->motion.time,
- event->motion.state,
- button,
+ gdk_event_get_surface (event),
+ gdk_event_get_device (event),
+ gdk_event_get_source_device (event),
+ gdk_event_get_device_tool (event),
+ gdk_event_get_time (event),
+ gdk_event_get_modifier_state (event),
+ gdk_button_event_get_button (event),
p.x, p.y,
NULL);
+ break;
+ case GDK_MOTION_NOTIFY:
+ {
+ GdkModifierType state = gdk_event_get_modifier_state (event);
+ int button;
+ if (state & GDK_BUTTON3_MASK)
+ button = 3;
+ else if (state & GDK_BUTTON2_MASK)
+ button = 2;
+ else
+ {
+ if ((state & GDK_BUTTON1_MASK) == 0)
+ g_critical ("Guessing button number 1 on generated button press event");
+ button = 1;
+ }
+
+ press = gdk_event_button_new (GDK_BUTTON_PRESS,
+ gdk_event_get_surface (event),
+ gdk_event_get_device (event),
+ gdk_event_get_source_device (event),
+ gdk_event_get_device_tool (event),
+ gdk_event_get_time (event),
+ gdk_event_get_modifier_state (event),
+ button,
+ p.x, p.y,
+ NULL);
+ }
+ break;
+ default:
+ g_assert_not_reached ();
}
- else
- return;
next_child = event_widget;
parent = _gtk_widget_get_parent (next_child);
@@ -2181,10 +2195,10 @@ _gtk_widget_get_emulating_sequence (GtkWidget *widget,
last_event = _gtk_widget_get_last_event (widget, sequence, &target);
if (last_event &&
- (last_event->any.type == GDK_TOUCH_BEGIN ||
- last_event->any.type == GDK_TOUCH_UPDATE ||
- last_event->any.type == GDK_TOUCH_END) &&
- last_event->touch.emulating_pointer)
+ (gdk_event_get_event_type (last_event) == GDK_TOUCH_BEGIN ||
+ gdk_event_get_event_type (last_event) == GDK_TOUCH_UPDATE ||
+ gdk_event_get_event_type (last_event) == GDK_TOUCH_END) &&
+ gdk_touch_event_get_emulating_pointer (last_event))
return TRUE;
}
else
@@ -4751,7 +4765,7 @@ gtk_widget_real_mnemonic_activate (GtkWidget *widget,
}
#define WIDGET_REALIZED_FOR_EVENT(widget, event) \
- (event->any.type == GDK_FOCUS_CHANGE || _gtk_widget_get_realized(widget))
+ (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE || _gtk_widget_get_realized (widget))
/**
* gtk_widget_event:
@@ -4898,7 +4912,7 @@ event_surface_is_still_viewable (GdkEvent *event)
* at the last moment, since the event may have been queued
* up behind other events, held over a recursive main loop, etc.
*/
- switch ((guint) event->any.type)
+ switch ((guint) gdk_event_get_event_type (event))
{
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
@@ -4906,7 +4920,7 @@ event_surface_is_still_viewable (GdkEvent *event)
case GDK_ENTER_NOTIFY:
case GDK_PROXIMITY_IN:
case GDK_SCROLL:
- return event->any.surface && gdk_surface_is_viewable (event->any.surface);
+ return gdk_surface_is_viewable (gdk_event_get_surface (event));
#if 0
/* The following events are the second half of paired events;
@@ -4939,7 +4953,7 @@ translate_event_coordinates (GdkEvent *event,
*x = *y = 0;
- if (!gdk_event_get_coords (event, &event_x, &event_y))
+ if (!gdk_event_get_position (event, &event_x, &event_y))
return FALSE;
event_widget = gtk_get_event_widget (event);
@@ -4984,8 +4998,8 @@ gtk_widget_event_internal (GtkWidget *widget,
return_val |= gtk_widget_run_controllers (widget, event, target, x, y, GTK_PHASE_BUBBLE);
if (return_val == FALSE &&
- (event->any.type == GDK_KEY_PRESS ||
- event->any.type == GDK_KEY_RELEASE))
+ (gdk_event_get_event_type (event) == GDK_KEY_PRESS ||
+ gdk_event_get_event_type (event) == GDK_KEY_RELEASE))
return_val |= gtk_bindings_activate_event (G_OBJECT (widget), (GdkEventKey *) event);
return return_val;
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index d2f141b5fd..204bc20221 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1430,7 +1430,7 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
double tx, ty;
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
- gdk_event_get_coords (event, &tx, &ty);
+ gdk_event_get_position (event, &tx, &ty);
gdk_surface_begin_resize_drag_for_device (priv->surface,
(GdkSurfaceEdge) region,
gdk_event_get_device ((GdkEvent *) event),
@@ -5997,7 +5997,7 @@ _gtk_window_query_nonaccels (GtkWindow *window,
/**
* gtk_window_propagate_key_event:
* @window: a #GtkWindow
- * @event: a #GdkEventKey
+ * @event: a #GdkEvent
*
* Propagate a key press or release event to the focus widget and
* up the focus container chain until a widget handles @event.
@@ -6009,8 +6009,8 @@ _gtk_window_query_nonaccels (GtkWindow *window,
* Returns: %TRUE if a widget in the focus chain handled the event.
*/
gboolean
-gtk_window_propagate_key_event (GtkWindow *window,
- GdkEventKey *event)
+gtk_window_propagate_key_event (GtkWindow *window,
+ GdkEvent *event)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
gboolean handled = FALSE;
@@ -8181,8 +8181,8 @@ _gtk_window_set_window_group (GtkWindow *window,
}
static gboolean
-gtk_window_activate_menubar (GtkWindow *window,
- GdkEventKey *event)
+gtk_window_activate_menubar (GtkWindow *window,
+ GdkEvent *event)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
guint keyval = 0;
@@ -8196,12 +8196,16 @@ gtk_window_activate_menubar (GtkWindow *window,
return FALSE;
}
+ if (!(gdk_event_get_event_type (event) == GDK_KEY_PRESS ||
+ gdk_event_get_event_type (event) == GDK_KEY_RELEASE))
+ return FALSE;
+
/* FIXME this is wrong, needs to be in the global accel resolution
* thing, to properly consider i18n etc., but that probably requires
* AccelGroup changes etc.
*/
- if (event->keyval == keyval &&
- ((event->state & gtk_accelerator_get_default_mod_mask ()) ==
+ if (gdk_key_event_get_keyval (event) == keyval &&
+ ((gdk_event_get_modifier_state (event) & gtk_accelerator_get_default_mod_mask ()) ==
(mods & gtk_accelerator_get_default_mod_mask ())))
{
GList *tmp_menubars, *l;
@@ -8385,7 +8389,7 @@ gtk_window_free_key_hash (GtkWindow *window)
/**
* gtk_window_activate_key:
* @window: a #GtkWindow
- * @event: a #GdkEventKey
+ * @event: a #GdkEvent
*
* Activates mnemonics and accelerators for this #GtkWindow. This is normally
* called by the default ::key_press_event handler for toplevel windows,
@@ -8395,8 +8399,8 @@ gtk_window_free_key_hash (GtkWindow *window)
* Returns: %TRUE if a mnemonic or accelerator was found and activated.
*/
gboolean
-gtk_window_activate_key (GtkWindow *window,
- GdkEventKey *event)
+gtk_window_activate_key (GtkWindow *window,
+ GdkEvent *event)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkKeyHash *key_hash;
@@ -8406,16 +8410,20 @@ gtk_window_activate_key (GtkWindow *window,
g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
+ if (!(gdk_event_get_event_type (event) == GDK_KEY_PRESS ||
+ gdk_event_get_event_type (event) == GDK_KEY_RELEASE))
+ return FALSE;
+
key_hash = gtk_window_get_key_hash (window);
if (key_hash)
{
GSList *tmp_list;
GSList *entries = _gtk_key_hash_lookup (key_hash,
- event->hardware_keycode,
- event->state,
+ gdk_key_event_get_keycode (event),
+ gdk_event_get_modifier_state (event),
gtk_accelerator_get_default_mod_mask (),
- event->group);
+ gdk_key_event_get_group (event));
g_object_get (gtk_widget_get_settings (GTK_WIDGET (window)),
"gtk-enable-accels", &enable_accels,
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index eedbc5df2f..a9274bbaac 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -230,10 +230,10 @@ GdkModifierType gtk_window_get_mnemonic_modifier (GtkWindow *window);
GDK_AVAILABLE_IN_ALL
gboolean gtk_window_activate_key (GtkWindow *window,
- GdkEventKey *event);
+ GdkEvent *event);
GDK_AVAILABLE_IN_ALL
gboolean gtk_window_propagate_key_event (GtkWindow *window,
- GdkEventKey *event);
+ GdkEvent *event);
GDK_AVAILABLE_IN_ALL
void gtk_window_present (GtkWindow *window);
diff --git a/gtk/inspector/inspect-button.c b/gtk/inspector/inspect-button.c
index ce74517ae9..9ecb168dd8 100644
--- a/gtk/inspector/inspect-button.c
+++ b/gtk/inspector/inspect-button.c
@@ -135,7 +135,7 @@ handle_event (GtkInspectorWindow *iw, GdkEvent *event)
{
guint keyval = 0;
- gdk_event_get_keyval (event, &keyval);
+ keyval = gdk_key_event_get_keyval (event);
if (keyval == GDK_KEY_Escape)
{
g_signal_handlers_disconnect_by_func (iw, handle_event, NULL);
diff --git a/tests/testwindowdrag.c b/tests/testwindowdrag.c
index 578462f705..90dc9766b6 100644
--- a/tests/testwindowdrag.c
+++ b/tests/testwindowdrag.c
@@ -20,7 +20,10 @@ start_resize (GtkGestureClick *gesture,
surface = gtk_native_get_surface (gtk_widget_get_native (widget));
event = gtk_get_current_event ();
- gdk_event_get_button (event, &button);
+ if (gdk_event_get_event_type (event) == GDK_BUTTON_PRESS)
+ button = gdk_button_event_get_button (event);
+ else
+ button = 0;
timestamp = gdk_event_get_time (event);
gtk_widget_translate_coordinates (widget, GTK_WIDGET (gtk_widget_get_root (widget)),
@@ -65,7 +68,10 @@ start_move (GtkGestureClick *gesture,
surface = gtk_native_get_surface (gtk_widget_get_native (widget));
event = gtk_get_current_event ();
- gdk_event_get_button (event, &button);
+ if (gdk_event_get_event_type (event) == GDK_BUTTON_PRESS)
+ button = gdk_button_event_get_button (event);
+ else
+ button = 0;
timestamp = gdk_event_get_time (event);
gtk_widget_translate_coordinates (widget, GTK_WIDGET (gtk_widget_get_root (widget)),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]