[gtk+/wip/carlosg/event-as-object: 828/844] gdk: Figure out the GdkSeat of an event from the GdkDevice



commit 347a3ff9161562b9c6e740c32b565ed61572c8d8
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 25 13:50:55 2017 +0200

    gdk: Figure out the GdkSeat of an event from the GdkDevice
    
    Removes the need for gdk_event_set_seat() and the GdkSeat field from
    GdkEventPrivate.

 gdk/gdkevents.c                 |   36 +++---------------------------------
 gdk/gdkinternals.h              |    4 ----
 gdk/wayland/gdkdevice-wayland.c |   13 -------------
 gdk/x11/gdkdevicemanager-xi2.c  |    8 --------
 4 files changed, 3 insertions(+), 58 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index ee498a2..753c914 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -525,7 +525,6 @@ gdk_event_copy (const GdkEvent *event)
       GdkEventPrivate *private = (GdkEventPrivate *)event;
 
       new_private->display = private->display;
-      new_private->seat = private->seat;
       g_set_object (&new_private->user_data, private->user_data);
     }
 
@@ -2014,40 +2013,11 @@ gdk_event_get_event_type (const GdkEvent *event)
 GdkSeat *
 gdk_event_get_seat (const GdkEvent *event)
 {
-  const GdkEventPrivate *priv;
+  GdkDevice *device;
 
-  if (!gdk_event_is_allocated (event))
-    return NULL;
-
-  priv = (const GdkEventPrivate *) event;
-
-  if (!priv->seat)
-    {
-      GdkDevice *device;
-
-      g_warning ("Event with type %d not holding a GdkSeat. "
-                 "It is most likely synthesized outside Gdk/GTK+",
-                 event->any.type);
-
-      device = gdk_event_get_device (event);
-
-      return device ? gdk_device_get_seat (device) : NULL;
-    }
+  device = gdk_event_get_device (event);
 
-  return priv->seat;
-}
-
-void
-gdk_event_set_seat (GdkEvent *event,
-                    GdkSeat  *seat)
-{
-  GdkEventPrivate *priv;
-
-  if (gdk_event_is_allocated (event))
-    {
-      priv = (GdkEventPrivate *) event;
-      priv->seat = seat;
-    }
+  return device ? gdk_device_get_seat (device) : NULL;
 }
 
 /**
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index e8ae8d2..6bba4d2 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -147,7 +147,6 @@ struct _GdkEventPrivate
 {
   GdkEvent   event;
   GdkDisplay *display;
-  GdkSeat   *seat;
   GObject *user_data;
 };
 
@@ -297,9 +296,6 @@ void     gdk_event_set_pointer_emulated (GdkEvent *event,
 void     gdk_event_set_scancode        (GdkEvent *event,
                                         guint16 scancode);
 
-void     gdk_event_set_seat              (GdkEvent *event,
-                                          GdkSeat  *seat);
-
 void   _gdk_event_emit               (GdkEvent   *event);
 GList* _gdk_event_queue_find_first   (GdkDisplay *display);
 void   _gdk_event_queue_remove_link  (GdkDisplay *display,
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 4eb4e15..5c58c25 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -603,7 +603,6 @@ emulate_crossing (GdkWindow       *window,
   event->crossing.detail = GDK_NOTIFY_NONLINEAR;
   gdk_event_set_device (event, device);
   gdk_event_set_source_device (event, device);
-  gdk_event_set_seat (event, gdk_device_get_seat (device));
 
   gdk_window_get_device_position_double (window, device,
                                          &event->crossing.x, &event->crossing.y,
@@ -634,7 +633,6 @@ emulate_touch_crossing (GdkWindow           *window,
   event->crossing.detail = GDK_NOTIFY_NONLINEAR;
   gdk_event_set_device (event, device);
   gdk_event_set_source_device (event, source);
-  gdk_event_set_seat (event, gdk_device_get_seat (device));
 
   event->crossing.x = touch->x;
   event->crossing.y = touch->y;
@@ -657,7 +655,6 @@ emulate_focus (GdkWindow *window,
   event->focus_change.in = focus_in;
   gdk_event_set_device (event, device);
   gdk_event_set_source_device (event, device);
-  gdk_event_set_seat (event, gdk_device_get_seat (device));
 
   _gdk_wayland_display_deliver_event (gdk_window_get_display (window), event);
 }
@@ -1387,7 +1384,6 @@ pointer_handle_enter (void              *data,
   event->any.window = g_object_ref (seat->pointer_info.focus);
   gdk_event_set_device (event, seat->master_pointer);
   gdk_event_set_source_device (event, seat->pointer);
-  gdk_event_set_seat (event, gdk_device_get_seat (seat->master_pointer));
   event->crossing.subwindow = NULL;
   event->crossing.time = (guint32)(g_get_monotonic_time () / 1000);
   event->crossing.mode = GDK_CROSSING_NORMAL;
@@ -1436,7 +1432,6 @@ pointer_handle_leave (void              *data,
   event->any.window = g_object_ref (seat->pointer_info.focus);
   gdk_event_set_device (event, seat->master_pointer);
   gdk_event_set_source_device (event, seat->pointer);
-  gdk_event_set_seat (event, GDK_SEAT (seat));
   event->crossing.subwindow = NULL;
   event->crossing.time = (guint32)(g_get_monotonic_time () / 1000);
   event->crossing.mode = GDK_CROSSING_NORMAL;
@@ -1487,7 +1482,6 @@ pointer_handle_motion (void              *data,
   event->any.window = g_object_ref (seat->pointer_info.focus);
   gdk_event_set_device (event, seat->master_pointer);
   gdk_event_set_source_device (event, seat->pointer);
-  gdk_event_set_seat (event, gdk_device_get_seat (seat->master_pointer));
   event->motion.time = time;
   event->motion.axes = NULL;
   event->motion.state = device_get_modifiers (seat->master_pointer);
@@ -1555,7 +1549,6 @@ pointer_handle_button (void              *data,
   event->any.window = g_object_ref (seat->pointer_info.focus);
   gdk_event_set_device (event, seat->master_pointer);
   gdk_event_set_source_device (event, seat->pointer);
-  gdk_event_set_seat (event, gdk_device_get_seat (seat->master_pointer));
   event->button.time = time;
   event->button.axes = NULL;
   event->button.state = device_get_modifiers (seat->master_pointer);
@@ -1803,7 +1796,6 @@ keyboard_handle_enter (void               *data,
   event->focus_change.in = TRUE;
   gdk_event_set_device (event, seat->master_keyboard);
   gdk_event_set_source_device (event, seat->keyboard);
-  gdk_event_set_seat (event, gdk_device_get_seat (seat->master_pointer));
 
   GDK_NOTE (EVENTS,
             g_message ("focus in, seat %p surface %p",
@@ -1841,7 +1833,6 @@ keyboard_handle_leave (void               *data,
   event->focus_change.in = FALSE;
   gdk_event_set_device (event, seat->master_keyboard);
   gdk_event_set_source_device (event, seat->keyboard);
-  gdk_event_set_seat (event, gdk_device_get_seat (seat->master_keyboard));
 
   g_object_unref (seat->keyboard_focus);
   seat->keyboard_focus = NULL;
@@ -2030,7 +2021,6 @@ deliver_key_event (GdkWaylandSeat *seat,
   event->any.window = seat->keyboard_focus ? g_object_ref (seat->keyboard_focus) : NULL;
   gdk_event_set_device (event, seat->master_keyboard);
   gdk_event_set_source_device (event, seat->keyboard);
-  gdk_event_set_seat (event, GDK_SEAT (seat));
   event->key.time = time_;
   event->key.state = device_get_modifiers (seat->master_pointer);
   event->key.group = 0;
@@ -2237,7 +2227,6 @@ _create_touch_event (GdkWaylandSeat       *seat,
   event->any.window = g_object_ref (touch->window);
   gdk_event_set_device (event, seat->touch_master);
   gdk_event_set_source_device (event, seat->touch);
-  gdk_event_set_seat (event, GDK_SEAT (seat));
   event->touch.time = time;
   event->touch.state = device_get_modifiers (seat->touch_master);
   gdk_event_set_display (event, seat->display);
@@ -2447,7 +2436,6 @@ emit_gesture_swipe_event (GdkWaylandSeat          *seat,
   event->any.window = g_object_ref (seat->pointer_info.focus);
   gdk_event_set_device (event, seat->master_pointer);
   gdk_event_set_source_device (event, seat->pointer);
-  gdk_event_set_seat (event, GDK_SEAT (seat));
   event->touchpad_swipe.time = _time;
   event->touchpad_swipe.state = device_get_modifiers (seat->master_pointer);
   gdk_event_set_display (event, seat->display);
@@ -2549,7 +2537,6 @@ emit_gesture_pinch_event (GdkWaylandSeat          *seat,
   event->any.window = g_object_ref (seat->pointer_info.focus);
   gdk_event_set_device (event, seat->master_pointer);
   gdk_event_set_source_device (event, seat->pointer);
-  gdk_event_set_seat (event, GDK_SEAT (seat));
   event->touchpad_pinch.time = _time;
   event->touchpad_pinch.state = device_get_modifiers (seat->master_pointer);
   gdk_event_set_display (event, seat->display);
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 6cb6294..3032dbc 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -1439,7 +1439,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
         source_device = g_hash_table_lookup (device_manager->id_table,
                                              GUINT_TO_POINTER (xev->sourceid));
         gdk_event_set_source_device (event, source_device);
-        gdk_event_set_seat (event, gdk_device_get_seat (device));
 
         event->key.keyval = GDK_KEY_VoidSymbol;
 
@@ -1522,7 +1521,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
             source_device = g_hash_table_lookup (device_manager->id_table,
                                                  GUINT_TO_POINTER (xev->sourceid));
             gdk_event_set_source_device (event, source_device);
-            gdk_event_set_seat (event, gdk_device_get_seat (device));
 
             event->scroll.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, 
&xev->group);
           }
@@ -1544,7 +1542,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
             source_device = g_hash_table_lookup (device_manager->id_table,
                                                  GUINT_TO_POINTER (xev->sourceid));
             gdk_event_set_source_device (event, source_device);
-            gdk_event_set_seat (event, gdk_device_get_seat (device));
             gdk_event_set_device_tool (event, source_device->last_tool);
 
             event->button.axes = translate_axes (device,
@@ -1626,7 +1623,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
 
             gdk_event_set_device (event, device);
             gdk_event_set_source_device (event, source_device);
-            gdk_event_set_seat (event, gdk_device_get_seat (device));
 
             event->scroll.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, 
&xev->group);
             break;
@@ -1642,7 +1638,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
 
         gdk_event_set_device (event, device);
         gdk_event_set_source_device (event, source_device);
-        gdk_event_set_seat (event, gdk_device_get_seat (device));
         gdk_event_set_device_tool (event, source_device->last_tool);
 
         event->motion.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
@@ -1697,7 +1692,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
         source_device = g_hash_table_lookup (device_manager->id_table,
                                              GUINT_TO_POINTER (xev->sourceid));
         gdk_event_set_source_device (event, source_device);
-        gdk_event_set_seat (event, gdk_device_get_seat (device));
 
         event->touch.axes = translate_axes (device,
                                             event->touch.x,
@@ -1761,7 +1755,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
         source_device = g_hash_table_lookup (device_manager->id_table,
                                              GUINT_TO_POINTER (xev->sourceid));
         gdk_event_set_source_device (event, source_device);
-        gdk_event_set_seat (event, gdk_device_get_seat (device));
 
         event->touch.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
 
@@ -1822,7 +1815,6 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
         source_device = g_hash_table_lookup (device_manager->id_table,
                                              GUINT_TO_POINTER (xev->sourceid));
         gdk_event_set_source_device (event, source_device);
-        gdk_event_set_seat (event, gdk_device_get_seat (device));
 
         if (ev->evtype == XI_Enter &&
             xev->detail != XINotifyInferior && xev->mode != XINotifyPassiveUngrab &&


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