[gtk/wip/carlosg/input-cleanups: 8/26] gdk: Depend less on gdk_event_get_device()



commit 7be6afe84dffbc23ac7aa842bf543d38d348953a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jun 23 11:00:46 2020 +0200

    gdk: Depend less on gdk_event_get_device()
    
    For the most part, we are interested in seats here.

 gdk/gdksurface.c                 |  4 +---
 gdk/wayland/gdkdevice-wayland.c  |  5 ++---
 gdk/wayland/gdkprivate-wayland.h |  4 ++--
 gdk/wayland/gdksurface-wayland.c | 14 +++++++-------
 gdk/x11/gdkeventsource.c         |  5 ++---
 5 files changed, 14 insertions(+), 18 deletions(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 6eac19ac37..96302ea630 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2947,11 +2947,9 @@ gdk_surface_get_seat_from_event (GdkSurface *surface,
 {
   if (event)
     {
-      GdkDevice *device = gdk_event_get_device (event);
       GdkSeat *seat = NULL;
 
-      if (device)
-        seat = gdk_device_get_seat (device);
+      seat = gdk_event_get_seat (event);
 
       if (seat)
         return seat;
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index fe4d767e48..524f17e277 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -4886,10 +4886,9 @@ _gdk_wayland_display_remove_seat (GdkWaylandDisplay *display_wayland,
 }
 
 uint32_t
-_gdk_wayland_device_get_implicit_grab_serial (GdkWaylandDevice *device,
-                                              GdkEvent         *event)
+_gdk_wayland_seat_get_implicit_grab_serial (GdkSeat  *seat,
+                                            GdkEvent *event)
 {
-  GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (device));
   GdkEventSequence *sequence = NULL;
   GdkWaylandTouchData *touch = NULL;
 
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index a824f7bb7d..c38f9b7f68 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -134,8 +134,8 @@ void        _gdk_wayland_display_remove_seat    (GdkWaylandDisplay       *displa
                                                  guint32                  id);
 
 GdkKeymap *_gdk_wayland_device_get_keymap (GdkDevice *device);
-uint32_t _gdk_wayland_device_get_implicit_grab_serial(GdkWaylandDevice *device,
-                                                      GdkEvent   *event);
+uint32_t _gdk_wayland_seat_get_implicit_grab_serial(GdkSeat  *seat,
+                                                    GdkEvent *event);
 uint32_t _gdk_wayland_seat_get_last_implicit_grab_serial (GdkWaylandSeat     *seat,
                                                           GdkEventSequence **seqence);
 struct wl_data_device * gdk_wayland_device_get_data_device (GdkDevice *gdk_device);
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 60bfa9147d..8f8b791f88 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -3830,8 +3830,8 @@ gdk_wayland_surface_show_window_menu (GdkSurface *surface,
   GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
   GdkWaylandDisplay *display_wayland =
     GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
-  struct wl_seat *seat;
-  GdkWaylandDevice *device;
+  GdkSeat *seat;
+  struct wl_seat *wl_seat;
   double x, y;
   uint32_t serial;
 
@@ -3850,21 +3850,21 @@ gdk_wayland_surface_show_window_menu (GdkSurface *surface,
   if (!is_realized_toplevel (surface))
     return FALSE;
 
-  device = GDK_WAYLAND_DEVICE (gdk_event_get_device (event));
-  seat = gdk_wayland_device_get_wl_seat (GDK_DEVICE (device));
+  seat = gdk_event_get_seat (event);
+  wl_seat = gdk_wayland_seat_get_wl_seat (seat);
   gdk_event_get_position (event, &x, &y);
 
-  serial = _gdk_wayland_device_get_implicit_grab_serial (device, event);
+  serial = _gdk_wayland_seat_get_implicit_grab_serial (seat, event);
 
   switch (display_wayland->shell_variant)
     {
     case GDK_WAYLAND_SHELL_VARIANT_XDG_SHELL:
       xdg_toplevel_show_window_menu (impl->display_server.xdg_toplevel,
-                                     seat, serial, x, y);
+                                     wl_seat, serial, x, y);
       break;
     case GDK_WAYLAND_SHELL_VARIANT_ZXDG_SHELL_V6:
       zxdg_toplevel_v6_show_window_menu (impl->display_server.zxdg_toplevel_v6,
-                                         seat, serial, x, y);
+                                         wl_seat, serial, x, y);
       break;
     default:
       g_assert_not_reached ();
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index 25338b4581..ad0d6e05ee 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -152,9 +152,8 @@ static void
 handle_touch_synthetic_crossing (GdkEvent *event)
 {
   GdkEventType evtype = gdk_event_get_event_type (event);
-  GdkDevice *device = gdk_event_get_device (event);
   GdkEvent *crossing = NULL;
-  GdkSeat *seat = gdk_device_get_seat (device);
+  GdkSeat *seat = gdk_event_get_seat (event);
   gboolean needs_enter, set_needs_enter = FALSE;
 
   if (quark_needs_enter == 0)
@@ -208,7 +207,7 @@ handle_touch_synthetic_crossing (GdkEvent *event)
 
   if (crossing)
     {
-      gdk_display_put_event (gdk_device_get_display (device), crossing);
+      gdk_display_put_event (gdk_seat_get_display (seat), crossing);
       gdk_event_unref (crossing);
     }
 }


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