[gtk+/wip/carlosg/event-as-object: 2/23] gdk: Remove GdkEventType argument from GdkEvent union



commit 2dce0eef9c00896f179d78d83127ead178c9e60e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 11 15:55:19 2017 +0200

    gdk: Remove GdkEventType argument from GdkEvent union
    
    It won't stand true anymore that the GdkEventType argument is the
    first field of the GdkEvent* structs. All callers have been updated
    to use event->any.type instead.

 gdk/gdkdnd.c                        |    2 +-
 gdk/gdkevents.c                     |  180 +++++++++++++++++++----------------
 gdk/gdkeventsprivate.h              |    1 -
 gdk/gdkwindow.c                     |   16 ++--
 gdk/wayland/gdkdevice-wayland.c     |   16 ++--
 gdk/wayland/gdkwindow-wayland.c     |    2 +-
 gdk/x11/gdkdevicemanager-core-x11.c |    2 +-
 gdk/x11/gdkdnd-x11.c                |    4 +-
 gdk/x11/gdkeventsource.c            |   14 ++--
 gdk/x11/gdkwindow-x11.c             |    2 +-
 gtk/gtkmain.c                       |   54 +++++-----
 gtk/gtkwidget.c                     |   40 ++++----
 12 files changed, 173 insertions(+), 160 deletions(-)
---
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
index f6cddd5..b249e7a 100644
--- a/gdk/gdkdnd.c
+++ b/gdk/gdkdnd.c
@@ -789,7 +789,7 @@ gdk_drag_context_handle_dest_event (GdkEvent *event)
   GdkDragContext *context = NULL;
   GList *l;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_DRAG_MOTION:
     case GDK_DROP_START:
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 20b7f56..00cbc84 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -111,7 +111,7 @@ _gdk_event_queue_find_first (GdkDisplay *display)
           if (pending_motion)
             return pending_motion;
 
-          if (event->event.type == GDK_MOTION_NOTIFY && (event->flags & GDK_EVENT_FLUSHED) == 0)
+          if (event->event.any.type == GDK_MOTION_NOTIFY && (event->flags & GDK_EVENT_FLUSHED) == 0)
             pending_motion = tmp_list;
           else
             return tmp_list;
@@ -273,7 +273,7 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
       if (event->flags & GDK_EVENT_PENDING)
         break;
 
-      if (event->event.type != GDK_MOTION_NOTIFY)
+      if (event->event.any.type != GDK_MOTION_NOTIFY)
         break;
 
       if (pending_motion_window != NULL &&
@@ -288,7 +288,7 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
         break;
 
       pending_motion_window = event->event.any.window;
-      pending_motion_device = event->motion.device;
+      pending_motion_device = event->event.motion.device;
       pending_motions = tmp_list;
 
       tmp_list = tmp_list->prev;
@@ -868,7 +868,7 @@ guint32
 gdk_event_get_time (const GdkEvent *event)
 {
   if (event)
-    switch (event->type)
+    switch (event->any.type)
       {
       case GDK_MOTION_NOTIFY:
        return event->motion.time;
@@ -958,7 +958,7 @@ gdk_event_get_state (const GdkEvent        *event,
   g_return_val_if_fail (state != NULL, FALSE);
   
   if (event)
-    switch (event->type)
+    switch (event->any.type)
       {
       case GDK_MOTION_NOTIFY:
        *state = event->motion.state;
@@ -1051,7 +1051,7 @@ gdk_event_get_coords (const GdkEvent *event,
   
   g_return_val_if_fail (event != NULL, FALSE);
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_CONFIGURE:
       x = event->configure.x;
@@ -1123,7 +1123,7 @@ gdk_event_get_root_coords (const GdkEvent *event,
   
   g_return_val_if_fail (event != NULL, FALSE);
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_MOTION_NOTIFY:
       x = event->motion.x_root;
@@ -1187,7 +1187,7 @@ gdk_event_set_coords (GdkEvent *event,
 {
   g_return_if_fail (event != NULL);
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_CONFIGURE:
       event->configure.x = x;
@@ -1251,7 +1251,7 @@ gdk_event_get_button (const GdkEvent *event,
 
   g_return_val_if_fail (event != NULL, FALSE);
   
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_BUTTON_PRESS:
     case GDK_BUTTON_RELEASE:
@@ -1292,7 +1292,7 @@ gdk_event_get_click_count (const GdkEvent *event,
 
   g_return_val_if_fail (event != NULL, FALSE);
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_BUTTON_PRESS:
     case GDK_BUTTON_RELEASE:
@@ -1327,7 +1327,7 @@ gdk_event_get_keyval (const GdkEvent *event,
   gboolean fetched = TRUE;
   guint number = 0;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_KEY_PRESS:
     case GDK_KEY_RELEASE:
@@ -1348,8 +1348,8 @@ void
 gdk_event_set_keyval (GdkEvent *event,
                       guint     keyval)
 {
-  if (event->type == GDK_KEY_PRESS ||
-      event->type == GDK_KEY_RELEASE)
+  if (event->any.type == GDK_KEY_PRESS ||
+      event->any.type == GDK_KEY_RELEASE)
     event->key.keyval = keyval;
 }
 
@@ -1373,7 +1373,7 @@ gdk_event_get_keycode (const GdkEvent *event,
   gboolean fetched = TRUE;
   guint16 number = 0;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_KEY_PRESS:
     case GDK_KEY_RELEASE:
@@ -1403,7 +1403,7 @@ gdk_event_get_key_group (const GdkEvent *event,
 {
   gboolean fetched = TRUE;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_KEY_PRESS:
     case GDK_KEY_RELEASE:
@@ -1431,7 +1431,7 @@ gdk_event_get_string (const GdkEvent  *event,
 {
   gboolean fetched = TRUE;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_KEY_PRESS:
     case GDK_KEY_RELEASE:
@@ -1459,7 +1459,7 @@ gdk_event_get_key_is_modifier (const GdkEvent *event,
 {
   gboolean fetched = TRUE;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_KEY_PRESS:
     case GDK_KEY_RELEASE:
@@ -1492,7 +1492,7 @@ gdk_event_get_scroll_direction (const GdkEvent *event,
   gboolean fetched = TRUE;
   GdkScrollDirection dir = 0;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_SCROLL:
       if (event->scroll.direction == GDK_SCROLL_SMOOTH)
@@ -1532,7 +1532,7 @@ gdk_event_get_scroll_deltas (const GdkEvent *event,
   gdouble dx = 0.0;
   gdouble dy = 0.0;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_SCROLL:
       if (event->scroll.direction == GDK_SCROLL_SMOOTH)
@@ -1604,7 +1604,7 @@ gdk_event_get_axis (const GdkEvent *event,
     {
       gdouble x, y;
       
-      switch ((guint) event->type)
+      switch ((guint) event->any.type)
        {
         case GDK_MOTION_NOTIFY:
          x = event->motion.x;
@@ -1643,21 +1643,21 @@ gdk_event_get_axis (const GdkEvent *event,
 
       return TRUE;
     }
-  else if (event->type == GDK_BUTTON_PRESS ||
-          event->type == GDK_BUTTON_RELEASE)
+  else if (event->any.type == GDK_BUTTON_PRESS ||
+          event->any.type == GDK_BUTTON_RELEASE)
     {
       device = event->button.device;
       axes = event->button.axes;
     }
-  else if (event->type == GDK_TOUCH_BEGIN ||
-           event->type == GDK_TOUCH_UPDATE ||
-           event->type == GDK_TOUCH_END ||
-           event->type == GDK_TOUCH_CANCEL)
+  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)
     {
       device = event->touch.device;
       axes = event->touch.axes;
     }
-  else if (event->type == GDK_MOTION_NOTIFY)
+  else if (event->any.type == GDK_MOTION_NOTIFY)
     {
       device = event->motion.device;
       axes = event->motion.axes;
@@ -1691,7 +1691,7 @@ gdk_event_set_device (GdkEvent  *event,
 
   g_set_object (&private->device, device);
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_MOTION_NOTIFY:
       event->motion.device = device;
@@ -1742,7 +1742,7 @@ gdk_event_get_device (const GdkEvent *event)
         return private->device;
     }
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_MOTION_NOTIFY:
       return event->motion.device;
@@ -1759,6 +1759,20 @@ gdk_event_get_device (const GdkEvent *event)
     case GDK_PROXIMITY_IN:
     case GDK_PROXIMITY_OUT:
       return event->proximity.device;
+    default:
+      break;
+    }
+
+  /* Fallback if event has no device set */
+  switch (event->any.type)
+    {
+    case GDK_MOTION_NOTIFY:
+    case GDK_BUTTON_PRESS:
+    case GDK_BUTTON_RELEASE:
+    case GDK_TOUCH_BEGIN:
+    case GDK_TOUCH_UPDATE:
+    case GDK_TOUCH_END:
+    case GDK_TOUCH_CANCEL:
     case GDK_ENTER_NOTIFY:
     case GDK_LEAVE_NOTIFY:
     case GDK_FOCUS_CHANGE:
@@ -1777,13 +1791,13 @@ gdk_event_get_device (const GdkEvent *event)
 
         g_warning ("Event with type %d not holding a GdkDevice. "
                    "It is most likely synthesized outside Gdk/GTK+",
-                   event->type);
+                   event->any.type);
 
         display = gdk_window_get_display (event->any.window);
         seat = gdk_display_get_default_seat (display);
 
-        if (event->type == GDK_KEY_PRESS ||
-            event->type == GDK_KEY_RELEASE)
+        if (event->any.type == GDK_KEY_PRESS ||
+            event->any.type == GDK_KEY_RELEASE)
           return gdk_seat_get_keyboard (seat);
         else
           return gdk_seat_get_pointer (seat);
@@ -1880,7 +1894,7 @@ gdk_event_triggers_context_menu (const GdkEvent *event)
 {
   g_return_val_if_fail (event != NULL, FALSE);
 
-  if (event->type == GDK_BUTTON_PRESS)
+  if (event->any.type == GDK_BUTTON_PRESS)
     {
       const GdkEventButton *bevent = (const GdkEventButton *) event;
       GdkDisplay *display;
@@ -2113,10 +2127,10 @@ gdk_event_get_event_sequence (const GdkEvent *event)
   if (!event)
     return NULL;
 
-  if (event->type == GDK_TOUCH_BEGIN ||
-      event->type == GDK_TOUCH_UPDATE ||
-      event->type == GDK_TOUCH_END ||
-      event->type == GDK_TOUCH_CANCEL)
+  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;
@@ -2351,7 +2365,7 @@ gdk_event_get_event_type (const GdkEvent *event)
 {
   g_return_val_if_fail (event != NULL, GDK_NOTHING);
 
-  return event->type;
+  return event->any.type;
 }
 
 /**
@@ -2380,7 +2394,7 @@ gdk_event_get_seat (const GdkEvent *event)
 
       g_warning ("Event with type %d not holding a GdkSeat. "
                  "It is most likely synthesized outside Gdk/GTK+",
-                 event->type);
+                 event->any.type);
 
       device = gdk_event_get_device (event);
 
@@ -2537,12 +2551,12 @@ gdk_event_get_drag_context (const GdkEvent  *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_DRAG_ENTER ||
-      event->type == GDK_DRAG_LEAVE ||
-      event->type == GDK_DRAG_MOTION ||
-      event->type == GDK_DRAG_STATUS ||
-      event->type == GDK_DROP_START ||
-      event->type == GDK_DROP_FINISHED)
+  if (event->any.type == GDK_DRAG_ENTER ||
+      event->any.type == GDK_DRAG_LEAVE ||
+      event->any.type == GDK_DRAG_MOTION ||
+      event->any.type == GDK_DRAG_STATUS ||
+      event->any.type == GDK_DROP_START ||
+      event->any.type == GDK_DROP_FINISHED)
     {
       *context = event->dnd.context;
       return TRUE;
@@ -2565,8 +2579,8 @@ gdk_event_get_crossing_mode (const GdkEvent  *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_ENTER_NOTIFY ||
-      event->type == GDK_LEAVE_NOTIFY)
+  if (event->any.type == GDK_ENTER_NOTIFY ||
+      event->any.type == GDK_LEAVE_NOTIFY)
     {
       *mode = event->crossing.mode;
       return TRUE;
@@ -2589,8 +2603,8 @@ gdk_event_get_crossing_detail (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_ENTER_NOTIFY ||
-      event->type == GDK_LEAVE_NOTIFY)
+  if (event->any.type == GDK_ENTER_NOTIFY ||
+      event->any.type == GDK_LEAVE_NOTIFY)
     {
       *detail = event->crossing.detail;
       return TRUE;
@@ -2613,12 +2627,12 @@ gdk_event_get_touchpad_gesture_phase (const GdkEvent          *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_TOUCHPAD_PINCH)
+  if (event->any.type == GDK_TOUCHPAD_PINCH)
     {
       *phase = event->touchpad_pinch.phase;
       return TRUE;
     }
-  else if (event->type == GDK_TOUCHPAD_SWIPE)
+  else if (event->any.type == GDK_TOUCHPAD_SWIPE)
     {
       *phase = event->touchpad_swipe.phase;
       return TRUE;
@@ -2641,12 +2655,12 @@ gdk_event_get_touchpad_gesture_n_fingers (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_TOUCHPAD_PINCH)
+  if (event->any.type == GDK_TOUCHPAD_PINCH)
     {
       *n_fingers = event->touchpad_pinch.n_fingers;
       return TRUE;
     }
-  else if (event->type == GDK_TOUCHPAD_SWIPE)
+  else if (event->any.type == GDK_TOUCHPAD_SWIPE)
     {
       *n_fingers = event->touchpad_swipe.n_fingers;
       return TRUE;
@@ -2671,13 +2685,13 @@ gdk_event_get_touchpad_deltas (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_TOUCHPAD_PINCH)
+  if (event->any.type == GDK_TOUCHPAD_PINCH)
     {
       *dx = event->touchpad_pinch.dx;
       *dy = event->touchpad_pinch.dy;
       return TRUE;
     }
-  else if (event->type == GDK_TOUCHPAD_SWIPE)
+  else if (event->any.type == GDK_TOUCHPAD_SWIPE)
     {
       *dx = event->touchpad_swipe.dx;
       *dy = event->touchpad_swipe.dy;
@@ -2701,7 +2715,7 @@ gdk_event_get_touchpad_angle_delta (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_TOUCHPAD_PINCH)
+  if (event->any.type == GDK_TOUCHPAD_PINCH)
     {
       *delta = event->touchpad_pinch.angle_delta;
       return TRUE;
@@ -2724,7 +2738,7 @@ gdk_event_get_touchpad_scale (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_TOUCHPAD_PINCH)
+  if (event->any.type == GDK_TOUCHPAD_PINCH)
     {
       *scale = event->touchpad_pinch.scale;
       return TRUE;
@@ -2747,9 +2761,9 @@ gdk_event_get_touch_emulating_pointer (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_TOUCH_BEGIN ||
-      event->type == GDK_TOUCH_UPDATE ||
-      event->type == GDK_TOUCH_END)
+  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;
@@ -2772,7 +2786,7 @@ gdk_event_get_grab_window (const GdkEvent  *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_GRAB_BROKEN)
+  if (event->any.type == GDK_GRAB_BROKEN)
     {
       *window = event->grab_broken.grab_window;
       return TRUE;
@@ -2798,7 +2812,7 @@ gdk_event_get_window_state (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_WINDOW_STATE)
+  if (event->any.type == GDK_WINDOW_STATE)
     {
       *changed = event->window_state.changed_mask;
       *new_state = event->window_state.new_window_state;
@@ -2822,7 +2836,7 @@ gdk_event_get_focus_in (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_FOCUS_CHANGE)
+  if (event->any.type == GDK_FOCUS_CHANGE)
     {
       *focus_in = event->focus_change.in;
       return TRUE;
@@ -2847,21 +2861,21 @@ gdk_event_get_pad_group_mode (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_PAD_GROUP_MODE)
+  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->type == GDK_PAD_BUTTON_PRESS ||
-           event->type == GDK_PAD_BUTTON_RELEASE)
+  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->type == GDK_PAD_RING ||
-           event->type == GDK_PAD_STRIP)
+  else if (event->any.type == GDK_PAD_RING ||
+           event->any.type == GDK_PAD_STRIP)
     {
       *group = event->pad_axis.group;
       *mode = event->pad_axis.mode;
@@ -2885,8 +2899,8 @@ gdk_event_get_pad_button (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_PAD_BUTTON_PRESS ||
-      event->type == GDK_PAD_BUTTON_RELEASE)
+  if (event->any.type == GDK_PAD_BUTTON_PRESS ||
+      event->any.type == GDK_PAD_BUTTON_RELEASE)
     {
       *button = event->pad_button.button;
       return TRUE;
@@ -2911,8 +2925,8 @@ gdk_event_get_pad_axis_value (const GdkEvent *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_PAD_RING ||
-      event->type == GDK_PAD_STRIP)
+  if (event->any.type == GDK_PAD_RING ||
+      event->any.type == GDK_PAD_STRIP)
     {
       *index = event->pad_axis.index;
       *value = event->pad_axis.value;
@@ -2938,7 +2952,7 @@ gdk_event_get_property (const GdkEvent   *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_PROPERTY_NOTIFY)
+  if (event->any.type == GDK_PROPERTY_NOTIFY)
     {
       *property = event->property.atom;
       *state = event->property.state;
@@ -2962,10 +2976,10 @@ gdk_event_get_selection (const GdkEvent   *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_SELECTION_CLEAR ||
-      event->type == GDK_SELECTION_NOTIFY ||
-      event->type == GDK_SELECTION_REQUEST ||
-      event->type == GDK_OWNER_CHANGE)
+  if (event->any.type == GDK_SELECTION_CLEAR ||
+      event->any.type == GDK_SELECTION_NOTIFY ||
+      event->any.type == GDK_SELECTION_REQUEST ||
+      event->any.type == GDK_OWNER_CHANGE)
     {
       *selection = event->selection.selection;
       return TRUE;
@@ -3015,9 +3029,9 @@ gdk_event_get_selection_property (const GdkEvent  *event,
   if (!event)
     return FALSE;
 
-  if (event->type == GDK_SELECTION_CLEAR ||
-      event->type == GDK_SELECTION_NOTIFY ||
-      event->type == GDK_SELECTION_REQUEST)
+  if (event->any.type == GDK_SELECTION_CLEAR ||
+      event->any.type == GDK_SELECTION_NOTIFY ||
+      event->any.type == GDK_SELECTION_REQUEST)
     {
       if (property)
         *property = event->selection.property;
@@ -3065,14 +3079,14 @@ gdk_event_get_axes (GdkEvent  *event,
   if (!source_device)
     return FALSE;
 
-  if (event->type == GDK_MOTION_NOTIFY)
+  if (event->any.type == GDK_MOTION_NOTIFY)
     {
       *axes = event->motion.axes;
       *n_axes = gdk_device_get_n_axes (source_device);
       return TRUE;
     }
-  else if (event->type == GDK_BUTTON_PRESS ||
-           event->type == GDK_BUTTON_RELEASE)
+  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);
diff --git a/gdk/gdkeventsprivate.h b/gdk/gdkeventsprivate.h
index 188f197..7db71bb 100644
--- a/gdk/gdkeventsprivate.h
+++ b/gdk/gdkeventsprivate.h
@@ -764,7 +764,6 @@ struct _GdkEventPadGroupMode {
  */
 union _GdkEvent
 {
-  GdkEventType             type;
   GdkEventAny              any;
   GdkEventExpose           expose;
   GdkEventVisibility       visibility;
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index b15dc84..295c4a6 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -6031,7 +6031,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
     goto out;
 
 #ifdef DEBUG_WINDOW_PRINTING
-  if (event->type == GDK_KEY_PRESS &&
+  if (event->any.type == GDK_KEY_PRESS &&
       (event->key.keyval == 0xa7 ||
        event->key.keyval == 0xbd))
     {
@@ -6039,7 +6039,7 @@ _gdk_windowing_got_event (GdkDisplay *display,
     }
 #endif
 
-  if (event->type == GDK_VISIBILITY_NOTIFY)
+  if (event->any.type == GDK_VISIBILITY_NOTIFY)
     {
       event_window->native_visibility = event->visibility.state;
       gdk_window_update_visibility_recursively (event_window, event_window);
@@ -6049,17 +6049,17 @@ _gdk_windowing_got_event (GdkDisplay *display,
   if (event_window->window_type == GDK_WINDOW_ROOT)
     goto out;
 
-  if (event->type == GDK_ENTER_NOTIFY)
+  if (event->any.type == GDK_ENTER_NOTIFY)
     _gdk_display_set_window_under_pointer (display, device, event_window);
-  else if (event->type == GDK_LEAVE_NOTIFY)
+  else if (event->any.type == GDK_LEAVE_NOTIFY)
     _gdk_display_set_window_under_pointer (display, device, NULL);
 
-  if ((event->type == GDK_BUTTON_RELEASE ||
-       event->type == GDK_TOUCH_CANCEL ||
-       event->type == GDK_TOUCH_END) &&
+  if ((event->any.type == GDK_BUTTON_RELEASE ||
+       event->any.type == GDK_TOUCH_CANCEL ||
+       event->any.type == GDK_TOUCH_END) &&
       !event->any.send_event)
     {
-      if (event->type == GDK_BUTTON_RELEASE ||
+      if (event->any.type == GDK_BUTTON_RELEASE ||
           gdk_event_get_pointer_emulated (event))
         {
           button_release_grab =
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 98f44c3..70ccd5d 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -1433,7 +1433,7 @@ gdk_wayland_seat_get_frame_event (GdkWaylandSeat *seat,
                                   GdkEventType    evtype)
 {
   if (seat->pointer_info.frame.event &&
-      seat->pointer_info.frame.event->type != evtype)
+      seat->pointer_info.frame.event->any.type != evtype)
     gdk_wayland_seat_flush_frame_event (seat);
 
   seat->pointer_info.frame.event = gdk_event_new (evtype);
@@ -2559,7 +2559,7 @@ emit_gesture_swipe_event (GdkWaylandSeat          *seat,
 
   GDK_NOTE (EVENTS,
             g_message ("swipe event %d, coords: %f %f, seat %p state %d",
-                       event->type, event->touchpad_swipe.x,
+                       event->any.type, event->touchpad_swipe.x,
                        event->touchpad_swipe.y, seat,
                        event->touchpad_swipe.state));
 
@@ -2664,7 +2664,7 @@ emit_gesture_pinch_event (GdkWaylandSeat          *seat,
 
   GDK_NOTE (EVENTS,
             g_message ("pinch event %d, coords: %f %f, seat %p state %d",
-                       event->type, event->touchpad_pinch.x,
+                       event->any.type, event->touchpad_pinch.x,
                        event->touchpad_pinch.y, seat,
                        event->touchpad_pinch.state));
 
@@ -3431,7 +3431,7 @@ gdk_wayland_tablet_flush_frame_event (GdkWaylandTabletData *tablet,
   if (!event)
     return;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_MOTION_NOTIFY:
       event->motion.time = time;
@@ -3459,7 +3459,7 @@ gdk_wayland_tablet_flush_frame_event (GdkWaylandTabletData *tablet,
       return;
     }
 
-  if (event->type == GDK_PROXIMITY_OUT)
+  if (event->any.type == GDK_PROXIMITY_OUT)
     emulate_crossing (event->any.window, NULL,
                       tablet->master, GDK_LEAVE_NOTIFY,
                       GDK_CROSSING_NORMAL, time);
@@ -3467,7 +3467,7 @@ gdk_wayland_tablet_flush_frame_event (GdkWaylandTabletData *tablet,
   _gdk_wayland_display_deliver_event (gdk_seat_get_display (tablet->seat),
                                       event);
 
-  if (event->type == GDK_PROXIMITY_IN)
+  if (event->any.type == GDK_PROXIMITY_IN)
     emulate_crossing (event->any.window, NULL,
                       tablet->master, GDK_ENTER_NOTIFY,
                       GDK_CROSSING_NORMAL, time);
@@ -3478,7 +3478,7 @@ gdk_wayland_tablet_get_frame_event (GdkWaylandTabletData *tablet,
                                     GdkEventType          evtype)
 {
   if (tablet->pointer_info.frame.event &&
-      tablet->pointer_info.frame.event->type != evtype)
+      tablet->pointer_info.frame.event->any.type != evtype)
     gdk_wayland_tablet_flush_frame_event (tablet, GDK_CURRENT_TIME);
 
   tablet->pointer_info.frame.event = gdk_event_new (evtype);
@@ -3915,7 +3915,7 @@ tablet_tool_handle_frame (void                      *data,
 
   frame_event = tablet->pointer_info.frame.event;
 
-  if (frame_event && frame_event->type == GDK_PROXIMITY_OUT)
+  if (frame_event && frame_event->any.type == GDK_PROXIMITY_OUT)
     {
       tool->current_tablet = NULL;
       tablet->current_tool = NULL;
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index c2af118..f539cf7 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -3647,7 +3647,7 @@ gdk_wayland_window_show_window_menu (GdkWindow *window,
   double x, y;
   uint32_t serial;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_BUTTON_PRESS:
     case GDK_BUTTON_RELEASE:
diff --git a/gdk/x11/gdkdevicemanager-core-x11.c b/gdk/x11/gdkdevicemanager-core-x11.c
index 004db03..c4b7602 100644
--- a/gdk/x11/gdkdevicemanager-core-x11.c
+++ b/gdk/x11/gdkdevicemanager-core-x11.c
@@ -183,7 +183,7 @@ translate_key_event (GdkDisplay              *display,
   if (GDK_DEBUG_CHECK (EVENTS))
     {
       g_message ("%s:\t\twindow: %ld     key: %12s  %d",
-                 event->type == GDK_KEY_PRESS ? "key press  " : "key release",
+                 event->any.type == GDK_KEY_PRESS ? "key press  " : "key release",
                  xevent->xkey.window,
                  event->key.keyval ? gdk_keyval_name (event->key.keyval) : "(none)",
                  event->key.keyval);
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index a7ca704..b5352b8 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -3151,10 +3151,10 @@ gdk_x11_drag_context_handle_event (GdkDragContext *context,
 
   if (!context->is_source)
     return FALSE;
-  if (!x11_context->grab_seat && event->type != GDK_DROP_FINISHED)
+  if (!x11_context->grab_seat && event->any.type != GDK_DROP_FINISHED)
     return FALSE;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_MOTION_NOTIFY:
       return gdk_dnd_handle_motion_event (context, &event->motion);
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index 586b8c6..f404cc0 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -343,8 +343,8 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
     }
 
   if (event &&
-      (event->type == GDK_ENTER_NOTIFY ||
-       event->type == GDK_LEAVE_NOTIFY) &&
+      (event->any.type == GDK_ENTER_NOTIFY ||
+       event->any.type == GDK_LEAVE_NOTIFY) &&
       event->any.window != NULL)
     {
       /* Handle focusing (in the case where no window manager is running */
@@ -352,11 +352,11 @@ gdk_event_source_translate_event (GdkEventSource *event_source,
     }
 
   if (event &&
-      (event->type == GDK_TOUCH_BEGIN ||
-       event->type == GDK_TOUCH_END ||
-       event->type == GDK_MOTION_NOTIFY ||
-       event->type == GDK_ENTER_NOTIFY ||
-       event->type == GDK_LEAVE_NOTIFY))
+      (event->any.type == GDK_TOUCH_BEGIN ||
+       event->any.type == GDK_TOUCH_END ||
+       event->any.type == GDK_MOTION_NOTIFY ||
+       event->any.type == GDK_ENTER_NOTIFY ||
+       event->any.type == GDK_LEAVE_NOTIFY))
     {
       handle_touch_synthetic_crossing (event);
     }
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index ad27a45..a2b170d 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -4980,7 +4980,7 @@ gdk_x11_window_show_window_menu (GdkWindow *window,
   double x_root, y_root;
   XClientMessageEvent xclient = { 0 };
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_BUTTON_PRESS:
     case GDK_BUTTON_RELEASE:
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index ae46512..a64dd44 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1140,7 +1140,7 @@ rewrite_event_for_window (GdkEvent  *event,
 {
   event = gdk_event_copy (event);
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_SCROLL:
       rewrite_events_translate (event->any.window,
@@ -1211,7 +1211,7 @@ rewrite_event_for_grabs (GdkEvent *event)
   GdkDisplay *display;
   GdkDevice *device;
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_SCROLL:
     case GDK_BUTTON_PRESS:
@@ -1444,7 +1444,7 @@ gtk_synthesize_crossing_events (GtkWindow       *toplevel,
 static gboolean
 is_pointing_event (GdkEvent *event)
 {
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_MOTION_NOTIFY:
     case GDK_ENTER_NOTIFY:
@@ -1488,7 +1488,7 @@ handle_pointing_event (GdkEvent *event)
 
   sequence = gdk_event_get_event_sequence (event);
 
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_LEAVE_NOTIFY:
       if (event->crossing.mode == GDK_CROSSING_GRAB ||
@@ -1498,7 +1498,7 @@ handle_pointing_event (GdkEvent *event)
     case GDK_TOUCH_CANCEL:
       old_target = update_pointer_focus_state (toplevel, event, NULL);
 
-      if (event->type == GDK_LEAVE_NOTIFY)
+      if (event->any.type == GDK_LEAVE_NOTIFY)
         gtk_synthesize_crossing_events (toplevel, old_target, NULL,
                                         event, event->crossing.mode);
       break;
@@ -1512,7 +1512,7 @@ handle_pointing_event (GdkEvent *event)
       target = _gtk_toplevel_pick (toplevel, x, y, NULL, NULL);
       old_target = update_pointer_focus_state (toplevel, event, target);
 
-      if (event->type == GDK_MOTION_NOTIFY || event->type == GDK_ENTER_NOTIFY)
+      if (event->any.type == GDK_MOTION_NOTIFY || event->any.type == GDK_ENTER_NOTIFY)
         {
           if (!gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device,
                                                               sequence))
@@ -1524,7 +1524,7 @@ handle_pointing_event (GdkEvent *event)
           gtk_window_maybe_update_cursor (toplevel, NULL, device);
         }
 
-      if (event->type == GDK_TOUCH_BEGIN)
+      if (event->any.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
@@ -1538,10 +1538,10 @@ handle_pointing_event (GdkEvent *event)
                                                                  device,
                                                                  sequence);
       gtk_window_set_pointer_focus_grab (toplevel, device, sequence,
-                                         event->type == GDK_BUTTON_PRESS ?
+                                         event->any.type == GDK_BUTTON_PRESS ?
                                          target : NULL);
 
-      if (event->type == GDK_BUTTON_RELEASE)
+      if (event->any.type == GDK_BUTTON_RELEASE)
         {
           old_target = target;
           target = _gtk_toplevel_pick (toplevel, x, y, NULL, NULL);
@@ -1613,7 +1613,7 @@ gtk_main_do_event (GdkEvent *event)
   GdkDevice *device;
   GList *tmp_list;
 
-  if (event->type == GDK_OWNER_CHANGE)
+  if (event->any.type == GDK_OWNER_CHANGE)
     {
       _gtk_clipboard_handle_event (&event->owner_change);
       return;
@@ -1634,7 +1634,7 @@ gtk_main_do_event (GdkEvent *event)
        * There won't be a widget though, so we have to handle
        * them specially
        */
-      if (event->type == GDK_PROPERTY_NOTIFY)
+      if (event->any.type == GDK_PROPERTY_NOTIFY)
         _gtk_selection_incr_event (event->any.window,
                                    &event->property);
 
@@ -1690,7 +1690,7 @@ gtk_main_do_event (GdkEvent *event)
    * This is the key to implementing modality.
    */
   if (!grab_widget ||
-      ((gtk_widget_is_sensitive (event_widget) || event->type == GDK_SCROLL) &&
+      ((gtk_widget_is_sensitive (event_widget) || event->any.type == GDK_SCROLL) &&
        gtk_widget_is_ancestor (event_widget, grab_widget)))
     grab_widget = event_widget;
 
@@ -1721,7 +1721,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 (event->type)
+  switch (event->any.type)
     {
     case GDK_NOTHING:
       break;
@@ -1792,7 +1792,7 @@ gtk_main_do_event (GdkEvent *event)
           gboolean mnemonics_visible;
           GtkWidget *window;
 
-          mnemonics_visible = (event->type == GDK_KEY_PRESS);
+          mnemonics_visible = (event->any.type == GDK_KEY_PRESS);
 
           window = gtk_widget_get_toplevel (grab_widget);
           if (GTK_IS_WINDOW (window))
@@ -1846,15 +1846,15 @@ gtk_main_do_event (GdkEvent *event)
       break;
     }
 
-  if (event->type == GDK_ENTER_NOTIFY
-      || event->type == GDK_LEAVE_NOTIFY
-      || event->type == GDK_BUTTON_PRESS
-      || event->type == GDK_KEY_PRESS
-      || event->type == GDK_DRAG_ENTER
-      || event->type == GDK_GRAB_BROKEN
-      || event->type == GDK_MOTION_NOTIFY
-      || event->type == GDK_TOUCH_UPDATE
-      || event->type == GDK_SCROLL)
+  if (event->any.type == GDK_ENTER_NOTIFY
+      || event->any.type == GDK_LEAVE_NOTIFY
+      || event->any.type == GDK_BUTTON_PRESS
+      || event->any.type == GDK_KEY_PRESS
+      || event->any.type == GDK_DRAG_ENTER
+      || event->any.type == GDK_GRAB_BROKEN
+      || event->any.type == GDK_MOTION_NOTIFY
+      || event->any.type == GDK_TOUCH_UPDATE
+      || event->any.type == GDK_SCROLL)
     {
       _gtk_tooltip_handle_event (event);
     }
@@ -2375,7 +2375,7 @@ gtk_get_event_widget (const GdkEvent *event)
 
   widget = NULL;
   if (event && event->any.window &&
-      (event->type == GDK_DESTROY || !gdk_window_is_destroyed (event->any.window)))
+      (event->any.type == GDK_DESTROY || !gdk_window_is_destroyed (event->any.window)))
     {
       gdk_window_get_user_data (event->any.window, &widget_ptr);
       widget = widget_ptr;
@@ -2452,7 +2452,7 @@ propagate_event_up (GtkWidget *widget,
        * event
        */
       if (!gtk_widget_is_sensitive (widget))
-        handled_event = event->type != GDK_SCROLL;
+        handled_event = event->any.type != GDK_SCROLL;
       else
         handled_event = gtk_widget_event (widget, event);
 
@@ -2502,7 +2502,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->type == GDK_SCROLL)
+          if (event->any.type == GDK_SCROLL)
             break;
           else
             handled_event = TRUE;
@@ -2526,7 +2526,7 @@ propagate_event (GtkWidget *widget,
 
   propagate_func = captured ? _gtk_widget_captured_event : gtk_widget_event;
 
-  if (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE)
+  if (event->any.type == GDK_KEY_PRESS || event->any.type == GDK_KEY_RELEASE)
     {
       /* Only send key events within Window widgets to the Window
        * The Window widget will in turn pass the
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index bd0f635..0e7f949 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3456,20 +3456,20 @@ _gtk_widget_emulate_press (GtkWidget      *widget,
   if (event_widget == widget)
     return;
 
-  if (event->type == GDK_TOUCH_BEGIN ||
-      event->type == GDK_TOUCH_UPDATE ||
-      event->type == GDK_TOUCH_END)
+  if (event->any.type == GDK_TOUCH_BEGIN ||
+      event->any.type == GDK_TOUCH_UPDATE ||
+      event->any.type == GDK_TOUCH_END)
     {
       press = gdk_event_copy (event);
-      press->type = GDK_TOUCH_BEGIN;
+      press->any.type = GDK_TOUCH_BEGIN;
     }
-  else if (event->type == GDK_BUTTON_PRESS ||
-           event->type == GDK_BUTTON_RELEASE)
+  else if (event->any.type == GDK_BUTTON_PRESS ||
+           event->any.type == GDK_BUTTON_RELEASE)
     {
       press = gdk_event_copy (event);
-      press->type = GDK_BUTTON_PRESS;
+      press->any.type = GDK_BUTTON_PRESS;
     }
-  else if (event->type == GDK_MOTION_NOTIFY)
+  else if (event->any.type == GDK_MOTION_NOTIFY)
     {
       press = gdk_event_new (GDK_BUTTON_PRESS);
       press->any.window = g_object_ref (event->any.window);
@@ -3559,9 +3559,9 @@ _gtk_widget_get_emulating_sequence (GtkWidget         *widget,
       last_event = _gtk_widget_get_last_event (widget, sequence);
 
       if (last_event &&
-          (last_event->type == GDK_TOUCH_BEGIN ||
-           last_event->type == GDK_TOUCH_UPDATE ||
-           last_event->type == GDK_TOUCH_END) &&
+          (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)
         return TRUE;
     }
@@ -6508,7 +6508,7 @@ gtk_widget_real_grab_broken_event (GtkWidget          *widget,
 }
 
 #define WIDGET_REALIZED_FOR_EVENT(widget, event) \
-     (event->type == GDK_FOCUS_CHANGE || _gtk_widget_get_realized(widget))
+     (event->any.type == GDK_FOCUS_CHANGE || _gtk_widget_get_realized(widget))
 
 /**
  * gtk_widget_event:
@@ -6534,7 +6534,7 @@ gtk_widget_event (GtkWidget       *widget,
   g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
   g_return_val_if_fail (WIDGET_REALIZED_FOR_EVENT (widget, event), TRUE);
 
-  if (event->type == GDK_EXPOSE)
+  if (event->any.type == GDK_EXPOSE)
     {
       g_warning ("Events of type GDK_EXPOSE cannot be synthesized. To get "
                 "the same effect, call gdk_window_invalidate_rect/region(), "
@@ -6634,7 +6634,7 @@ _gtk_widget_captured_event (GtkWidget      *widget,
   g_return_val_if_fail (GTK_IS_WIDGET (widget), TRUE);
   g_return_val_if_fail (WIDGET_REALIZED_FOR_EVENT (widget, event), TRUE);
 
-  if (event->type == GDK_EXPOSE)
+  if (event->any.type == GDK_EXPOSE)
     {
       g_warning ("Events of type GDK_EXPOSE cannot be synthesized. To get "
                 "the same effect, call gdk_window_invalidate_rect/region(), "
@@ -6675,7 +6675,7 @@ event_window_is_still_viewable (const 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->type)
+  switch ((guint) event->any.type)
     {
     case GDK_EXPOSE:
     case GDK_MOTION_NOTIFY:
@@ -6742,7 +6742,7 @@ gtk_widget_event_internal (GtkWidget      *widget,
     return TRUE;
 
   /* Non input events get handled right away */
-  switch ((guint) event->type)
+  switch ((guint) event->any.type)
     {
     case GDK_VISIBILITY_NOTIFY:
     case GDK_EXPOSE:
@@ -6770,7 +6770,7 @@ gtk_widget_event_internal (GtkWidget      *widget,
     return_val |= _gtk_widget_run_controllers (widget, event_copy, GTK_PHASE_TARGET);
 
   /* XXX: Tooltips should be handled through captured events in the toplevel */
-  if (event_copy->type == GDK_FOCUS_CHANGE)
+  if (event_copy->any.type == GDK_FOCUS_CHANGE)
     {
       if (event_copy->focus_change.in)
         _gtk_tooltip_focus_in (widget);
@@ -6799,7 +6799,7 @@ gtk_widget_emit_event_signals (GtkWidget      *widget,
     {
       gint signal_num;
 
-      switch (event->type)
+      switch (event->any.type)
        {
         case GDK_DRAG_ENTER:
         case GDK_DRAG_LEAVE:
@@ -6897,7 +6897,7 @@ gtk_widget_emit_event_signals (GtkWidget      *widget,
          signal_num = GRAB_BROKEN_EVENT;
          break;
        default:
-         g_warning ("gtk_widget_event(): unhandled event type: %d", event->type);
+         g_warning ("gtk_widget_event(): unhandled event type: %d", event->any.type);
          signal_num = -1;
          break;
        }
@@ -13585,7 +13585,7 @@ gtk_widget_send_focus_change (GtkWidget *widget,
   gboolean res;
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
-  g_return_val_if_fail (event != NULL && event->type == GDK_FOCUS_CHANGE, FALSE);
+  g_return_val_if_fail (event != NULL && event->any.type == GDK_FOCUS_CHANGE, FALSE);
 
   g_object_ref (widget);
 



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