2016-12-28 13:53:22 +00:00
|
|
|
#include <gtk/gtk.h>
|
2016-03-28 23:22:36 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
test_list_seats (void)
|
|
|
|
{
|
|
|
|
GdkDisplay *display;
|
|
|
|
GdkSeat *seat0, *seat;
|
|
|
|
GList *list, *l;
|
|
|
|
gboolean found_default;
|
|
|
|
|
|
|
|
display = gdk_display_get_default ();
|
|
|
|
seat0 = gdk_display_get_default_seat (display);
|
2020-05-15 01:27:45 +00:00
|
|
|
if (seat0 != NULL)
|
|
|
|
g_assert_true (GDK_IS_SEAT (seat0));
|
2016-03-28 23:22:36 +00:00
|
|
|
|
|
|
|
found_default = FALSE;
|
|
|
|
list = gdk_display_list_seats (display);
|
2020-05-15 01:27:45 +00:00
|
|
|
|
2016-03-28 23:22:36 +00:00
|
|
|
for (l = list; l; l = l->next)
|
|
|
|
{
|
|
|
|
seat = l->data;
|
|
|
|
|
|
|
|
g_assert_true (GDK_IS_SEAT (seat));
|
2021-04-12 12:16:45 +00:00
|
|
|
g_assert_true (gdk_seat_get_display (seat) == display);
|
2016-03-28 23:22:36 +00:00
|
|
|
|
|
|
|
if (seat == seat0)
|
|
|
|
found_default = TRUE;
|
|
|
|
}
|
|
|
|
|
2020-05-15 01:27:45 +00:00
|
|
|
if (seat0 != NULL)
|
|
|
|
g_assert_true (found_default);
|
|
|
|
else
|
|
|
|
g_assert_true (list == NULL);
|
|
|
|
|
|
|
|
g_list_free (list);
|
2016-03-28 23:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_default_seat (void)
|
|
|
|
{
|
2020-10-31 18:57:43 +00:00
|
|
|
GdkDisplay *display, *d;
|
2016-03-28 23:22:36 +00:00
|
|
|
GdkSeat *seat0;
|
|
|
|
GdkSeatCapabilities caps;
|
|
|
|
GdkDevice *pointer0, *keyboard0, *device;
|
2020-10-31 18:57:43 +00:00
|
|
|
GList *physical_devices, *tools, *l;
|
|
|
|
GdkDeviceTool *tool;
|
2016-03-28 23:22:36 +00:00
|
|
|
|
|
|
|
display = gdk_display_get_default ();
|
|
|
|
seat0 = gdk_display_get_default_seat (display);
|
|
|
|
|
2020-05-15 01:27:45 +00:00
|
|
|
if (seat0 == NULL)
|
|
|
|
{
|
|
|
|
g_test_skip ("Display has no seats");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-28 23:22:36 +00:00
|
|
|
g_assert_true (GDK_IS_SEAT (seat0));
|
|
|
|
|
2020-10-31 18:57:43 +00:00
|
|
|
g_assert_true (gdk_seat_get_display (seat0) == display);
|
|
|
|
g_object_get (seat0, "display", &d, NULL);
|
|
|
|
g_assert_true (display == d);
|
|
|
|
g_object_unref (d);
|
|
|
|
|
2016-03-28 23:22:36 +00:00
|
|
|
caps = gdk_seat_get_capabilities (seat0);
|
|
|
|
|
2020-10-31 18:57:43 +00:00
|
|
|
g_assert_true (caps != GDK_SEAT_CAPABILITY_NONE);
|
2016-03-28 23:22:36 +00:00
|
|
|
|
|
|
|
pointer0 = gdk_seat_get_pointer (seat0);
|
2020-07-30 15:52:28 +00:00
|
|
|
physical_devices = gdk_seat_get_devices (seat0, GDK_SEAT_CAPABILITY_POINTER);
|
2016-03-28 23:22:36 +00:00
|
|
|
|
|
|
|
if ((caps & GDK_SEAT_CAPABILITY_POINTER) != 0)
|
|
|
|
{
|
|
|
|
g_assert_nonnull (pointer0);
|
2020-10-31 18:57:43 +00:00
|
|
|
g_assert_true (gdk_device_get_display (pointer0) == display);
|
|
|
|
g_assert_true (gdk_device_get_seat (pointer0) == seat0);
|
2016-03-28 23:22:36 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
g_assert_nonnull (physical_devices);
|
|
|
|
for (l = physical_devices; l; l = l->next)
|
2016-03-28 23:22:36 +00:00
|
|
|
{
|
|
|
|
device = l->data;
|
2020-10-31 18:57:43 +00:00
|
|
|
g_assert_true (gdk_device_get_display (device) == display);
|
|
|
|
g_assert_true (gdk_device_get_seat (device) == seat0);
|
2016-03-28 23:22:36 +00:00
|
|
|
}
|
2020-06-18 18:22:20 +00:00
|
|
|
g_list_free (physical_devices);
|
2016-03-28 23:22:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_assert_null (pointer0);
|
2020-06-18 18:22:20 +00:00
|
|
|
g_assert_null (physical_devices);
|
2016-03-28 23:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
keyboard0 = gdk_seat_get_keyboard (seat0);
|
2020-07-30 15:52:28 +00:00
|
|
|
physical_devices = gdk_seat_get_devices (seat0, GDK_SEAT_CAPABILITY_KEYBOARD);
|
2016-03-28 23:22:36 +00:00
|
|
|
|
|
|
|
if ((caps & GDK_SEAT_CAPABILITY_KEYBOARD) != 0)
|
|
|
|
{
|
|
|
|
g_assert_nonnull (keyboard0);
|
2020-10-31 18:57:43 +00:00
|
|
|
g_assert_true (gdk_device_get_display (keyboard0) == display);
|
|
|
|
g_assert_true (gdk_device_get_seat (keyboard0) == seat0);
|
|
|
|
g_assert_true (gdk_device_get_source (keyboard0) == GDK_SOURCE_KEYBOARD);
|
2016-03-28 23:22:36 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
g_assert_nonnull (physical_devices);
|
|
|
|
for (l = physical_devices; l; l = l->next)
|
2016-03-28 23:22:36 +00:00
|
|
|
{
|
|
|
|
device = l->data;
|
2020-10-31 18:57:43 +00:00
|
|
|
g_assert_true (gdk_device_get_display (device) == display);
|
|
|
|
g_assert_true (gdk_device_get_seat (device) == seat0);
|
|
|
|
g_assert_true (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD);
|
2016-03-28 23:22:36 +00:00
|
|
|
}
|
2020-06-18 18:22:20 +00:00
|
|
|
g_list_free (physical_devices);
|
2016-03-28 23:22:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_assert_null (keyboard0);
|
2020-06-18 18:22:20 +00:00
|
|
|
g_assert_null (physical_devices);
|
2016-03-28 23:22:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-31 18:57:43 +00:00
|
|
|
tools = gdk_seat_get_tools (seat0);
|
|
|
|
for (l = tools; l; l = l->next)
|
|
|
|
{
|
|
|
|
tool = l->data;
|
|
|
|
g_assert_true (GDK_IS_DEVICE_TOOL (tool));
|
|
|
|
}
|
|
|
|
g_list_free (tools);
|
2016-03-28 23:22:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
2021-04-13 01:22:04 +00:00
|
|
|
(g_test_init) (&argc, &argv, NULL);
|
2016-03-28 23:22:36 +00:00
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2016-03-28 23:22:36 +00:00
|
|
|
|
|
|
|
g_test_add_func ("/seat/list", test_list_seats);
|
|
|
|
g_test_add_func ("/seat/default", test_default_seat);
|
|
|
|
|
|
|
|
return g_test_run ();
|
|
|
|
}
|