summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2017-11-27 20:21:42 +0100
committerMatthias Clasen <mclasen@redhat.com>2017-12-07 21:27:14 -0500
commit4c45022ed0bfeb0219613744c2453c949c254382 (patch)
tree7cea157db8d71c264e7abd3139faeea2ffd668a8 /gdk
parent62f1695cb3e6c5b54ff1248e6f3904f35cb6a2d1 (diff)
downloadgtk+-4c45022ed0bfeb0219613744c2453c949c254382.tar.gz
gdk: Add gdk_seat_get_master_pointers()
Traditionally (and on most backends) there's a single master pointer driven by all pointing devices. The notable exception is Wayland though, where master pointing devices are created per capability in the case of pointer/touch, and one for each drawing tablet. This function call makes it easy to access all these. https://bugzilla.gnome.org/show_bug.cgi?id=790920
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdkseat.c26
-rw-r--r--gdk/gdkseat.h4
-rw-r--r--gdk/gdkseatdefault.c13
-rw-r--r--gdk/gdkseatprivate.h2
-rw-r--r--gdk/wayland/gdkdevice-wayland.c27
5 files changed, 72 insertions, 0 deletions
diff --git a/gdk/gdkseat.c b/gdk/gdkseat.c
index a507d451bd..c22400324a 100644
--- a/gdk/gdkseat.c
+++ b/gdk/gdkseat.c
@@ -458,3 +458,29 @@ gdk_seat_get_tool (GdkSeat *seat,
seat_class = GDK_SEAT_GET_CLASS (seat);
return seat_class->get_tool (seat, serial);
}
+
+/**
+ * gdk_seat_get_master_pointers:
+ * @seat: The #GdkSeat
+ * @capabilities: Queried capabilities
+ *
+ * Returns all master pointers with the given capabilities driven by this @seat.
+ * On most backends this function will return a list with a single element (meaning
+ * that all input devices drive the same onscreen cursor).
+ *
+ * In other backends where there can possibly be multiple foci (eg. wayland),
+ * this function will return all master #GdkDevices that represent these.
+ *
+ * Returns: (transfer container) (element-type GdkDevice): A list
+ * of master pointing devices
+ *
+ * Since: 3.93.
+ */
+GList *
+gdk_seat_get_master_pointers (GdkSeat *seat,
+ GdkSeatCapabilities capabilities)
+{
+ g_return_val_if_fail (GDK_IS_SEAT (seat), NULL);
+
+ return GDK_SEAT_GET_CLASS (seat)->get_master_pointers (seat, capabilities);
+}
diff --git a/gdk/gdkseat.h b/gdk/gdkseat.h
index b4ce279b76..f60b93dd66 100644
--- a/gdk/gdkseat.h
+++ b/gdk/gdkseat.h
@@ -112,6 +112,10 @@ GdkDevice * gdk_seat_get_pointer (GdkSeat *seat);
GDK_AVAILABLE_IN_3_20
GdkDevice * gdk_seat_get_keyboard (GdkSeat *seat);
+GDK_AVAILABLE_IN_3_93
+GList * gdk_seat_get_master_pointers (GdkSeat *seat,
+ GdkSeatCapabilities capabilities);
+
G_END_DECLS
#endif /* __GDK_SEAT_H__ */
diff --git a/gdk/gdkseatdefault.c b/gdk/gdkseatdefault.c
index 32a441f708..bf3f41098b 100644
--- a/gdk/gdkseatdefault.c
+++ b/gdk/gdkseatdefault.c
@@ -299,6 +299,18 @@ gdk_seat_default_get_tool (GdkSeat *seat,
return NULL;
}
+static GList *
+gdk_seat_default_get_master_pointers (GdkSeat *seat,
+ GdkSeatCapabilities capabilities)
+{
+ GList *masters = NULL;
+
+ if (capabilities & GDK_SEAT_CAPABILITY_ALL_POINTING)
+ masters = g_list_prepend (masters, gdk_seat_get_pointer (seat));
+
+ return masters;
+}
+
static void
gdk_seat_default_class_init (GdkSeatDefaultClass *klass)
{
@@ -314,6 +326,7 @@ gdk_seat_default_class_init (GdkSeatDefaultClass *klass)
seat_class->get_master = gdk_seat_default_get_master;
seat_class->get_slaves = gdk_seat_default_get_slaves;
+ seat_class->get_master_pointers = gdk_seat_default_get_master_pointers;
seat_class->get_tool = gdk_seat_default_get_tool;
}
diff --git a/gdk/gdkseatprivate.h b/gdk/gdkseatprivate.h
index bd66f68bf5..22cdd08189 100644
--- a/gdk/gdkseatprivate.h
+++ b/gdk/gdkseatprivate.h
@@ -58,6 +58,8 @@ struct _GdkSeatClass
GdkDeviceTool * (* get_tool) (GdkSeat *seat,
guint64 serial);
+ GList * (* get_master_pointers) (GdkSeat *seat,
+ GdkSeatCapabilities capabilities);
};
void gdk_seat_device_added (GdkSeat *seat,
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 5b067bfa77..02f9418a7e 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -4714,6 +4714,32 @@ gdk_wayland_seat_get_slaves (GdkSeat *seat,
return slaves;
}
+static GList *
+gdk_wayland_seat_get_master_pointers (GdkSeat *seat,
+ GdkSeatCapabilities capabilities)
+{
+ GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
+ GList *masters = NULL;
+
+ if (capabilities & GDK_SEAT_CAPABILITY_POINTER)
+ masters = g_list_prepend (masters, wayland_seat->master_pointer);
+ if (capabilities & GDK_SEAT_CAPABILITY_TOUCH)
+ masters = g_list_prepend (masters, wayland_seat->touch_master);
+ if (capabilities & GDK_SEAT_CAPABILITY_TABLET_STYLUS)
+ {
+ GList *l;
+
+ for (l = wayland_seat->tablets; l; l = l->next)
+ {
+ GdkWaylandTabletData *tablet = l->data;
+
+ masters = g_list_prepend (masters, tablet->master);
+ }
+ }
+
+ return masters;
+}
+
static void
gdk_wayland_seat_class_init (GdkWaylandSeatClass *klass)
{
@@ -4727,6 +4753,7 @@ gdk_wayland_seat_class_init (GdkWaylandSeatClass *klass)
seat_class->ungrab = gdk_wayland_seat_ungrab;
seat_class->get_master = gdk_wayland_seat_get_master;
seat_class->get_slaves = gdk_wayland_seat_get_slaves;
+ seat_class->get_master_pointers = gdk_wayland_seat_get_master_pointers;
}
static void