[mutter] clutter: Add ClutterSeat::clutter_seat_has_touchscreen() helper function



commit 3b181c6754d675656c2624103de584d2a28defb0
Author: Hans de Goede <hdegoede redhat com>
Date:   Thu Oct 15 15:23:38 2020 +0200

    clutter: Add ClutterSeat::clutter_seat_has_touchscreen() helper function
    
    Add a helper function to determine if a seat has a (physical)
    touchscreen associated with it.
    
    Currently src/backends/meta-backend.c has a private version of this
    (check_has_physical_touchscreen) and further patches in this patch-set
    need the same functionality. So add a generic helper for this to
    avoid code duplication.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1506

 clutter/clutter/clutter-seat.c | 27 +++++++++++++++++++++++++++
 clutter/clutter/clutter-seat.h |  3 +++
 2 files changed, 30 insertions(+)
---
diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c
index 13a862bf48..96bb0e9303 100644
--- a/clutter/clutter/clutter-seat.c
+++ b/clutter/clutter/clutter-seat.c
@@ -749,3 +749,30 @@ clutter_seat_get_touch_mode (ClutterSeat *seat)
 
   return touch_mode;
 }
+
+/**
+ * clutter_seat_has_touchscreen: (skip)
+ **/
+gboolean
+clutter_seat_has_touchscreen (ClutterSeat *seat)
+{
+  gboolean has_touchscreen;
+  const GList *devices, *l;
+
+  g_return_val_if_fail (CLUTTER_IS_SEAT (seat), FALSE);
+
+  devices = clutter_seat_peek_devices (seat);
+  for (l = devices; l; l = l->next)
+    {
+      ClutterInputDevice *device = l->data;
+
+      if (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_LOGICAL &&
+          clutter_input_device_get_device_type (device) == CLUTTER_TOUCHSCREEN_DEVICE)
+        {
+          has_touchscreen = TRUE;
+          break;
+        }
+    }
+
+  return has_touchscreen;
+}
diff --git a/clutter/clutter/clutter-seat.h b/clutter/clutter/clutter-seat.h
index aa88d73003..33497a43fc 100644
--- a/clutter/clutter/clutter-seat.h
+++ b/clutter/clutter/clutter-seat.h
@@ -194,4 +194,7 @@ void clutter_seat_warp_pointer (ClutterSeat *seat,
 CLUTTER_EXPORT
 gboolean clutter_seat_get_touch_mode (ClutterSeat *seat);
 
+CLUTTER_EXPORT
+gboolean clutter_seat_has_touchscreen (ClutterSeat *seat);
+
 #endif /* CLUTTER_SEAT_H */


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