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
This commit is contained in:
Hans de Goede 2020-10-15 15:23:38 +02:00 committed by Carlos Garnacho
parent b2f2050b95
commit 3b181c6754
2 changed files with 30 additions and 0 deletions

View File

@ -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;
}

View File

@ -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 */