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



commit 9d3689717a1ec2b9bedba1b3545973216e917242
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 98d54ed..a02a910 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -654,7 +654,6 @@ gdk_event_copy (const GdkEvent *event)
       GdkEventPrivate *private = (GdkEventPrivate *)event;
 
       new_private->screen = private->screen;
-      new_private->seat = private->seat;
       g_set_object (&new_private->user_data, private->user_data);
     }
 
@@ -2256,40 +2255,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 4b4d608..8c816a0 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -144,7 +144,6 @@ struct _GdkEventPrivate
 {
   GdkEvent   event;
   GdkScreen *screen;
-  GdkSeat   *seat;
   GObject *user_data;
 };
 
@@ -302,9 +301,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 70ccd5d..50c2f19 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -624,7 +624,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,
@@ -655,7 +654,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;
@@ -678,7 +676,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);
 }
@@ -1474,7 +1471,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;
@@ -1523,7 +1519,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;
@@ -1574,7 +1569,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);
@@ -1642,7 +1636,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);
@@ -1890,7 +1883,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",
@@ -1935,7 +1927,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;
@@ -2124,7 +2115,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;
@@ -2332,7 +2322,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_screen (event, display->screen);
@@ -2543,7 +2532,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_screen (event, display->screen);
@@ -2646,7 +2634,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_screen (event, display->screen);
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 87c14eb..632065e 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -1495,7 +1495,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;
 
@@ -1578,7 +1577,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);
           }
@@ -1600,7 +1598,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,
@@ -1686,7 +1683,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;
@@ -1702,7 +1698,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);
@@ -1757,7 +1752,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,
@@ -1825,7 +1819,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);
 
@@ -1886,7 +1879,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]