diff options
author | Olivier Fourdan <ofourdan@redhat.com> | 2020-03-30 16:55:05 +0200 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2020-03-30 18:25:36 +0200 |
commit | a07a69e24e7522e53edaa895d4e363a92150eaf4 (patch) | |
tree | 7ffd26763327f35c97c67298fd515fe1d2482f6f | |
parent | 3e1f59af61e339cfa990c2f776aa0c625b3377f2 (diff) | |
download | gtk+-a07a69e24e7522e53edaa895d4e363a92150eaf4.tar.gz |
gdk: add internal `gdk_surface_get_seat_from_event()`
This can come handy to get the seat from a surface/event.
-rw-r--r-- | gdk/gdkinternals.h | 2 | ||||
-rw-r--r-- | gdk/gdksurface.c | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 2af0cf36ca..21f75d7dc5 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -181,6 +181,8 @@ void gdk_surface_get_unscaled_size (GdkSurface *surface, int *unscaled_width, int *unscaled_height); gboolean gdk_surface_handle_event (GdkEvent *event); +GdkSeat * gdk_surface_get_seat_from_event (GdkSurface *surface, + GdkEvent *event); /***************************************** * Interfaces provided by windowing code * diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 25d6efc7a8..7432a9b348 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -3015,3 +3015,22 @@ gdk_surface_translate_coordinates (GdkSurface *from, return TRUE; } + +GdkSeat * +gdk_surface_get_seat_from_event (GdkSurface *surface, + GdkEvent *event) +{ + if (event) + { + GdkDevice *device = gdk_event_get_device (event); + GdkSeat *seat = NULL; + + device = gdk_event_get_device (event); + if (device) + seat = gdk_device_get_seat (device); + + if (seat) + return seat; + } + return gdk_display_get_default_seat (surface->display); +} |