diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b228e9c657..84a9e0ddca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ style-check-diff: - .gitlab-ci/run-style-check-diff.sh fedora-x86_64: - image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16 + image: registry.gitlab.gnome.org/gnome/gtk/fedora:v17 stage: build variables: EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both" @@ -47,20 +47,24 @@ fedora-x86_64: -Dprofiler=true _build - ninja -C _build - - .gitlab-ci/run-tests.sh _build + - .gitlab-ci/run-tests.sh _build x11 + - .gitlab-ci/run-tests.sh _build wayland + - .gitlab-ci/run-tests.sh _build broadway artifacts: when: always reports: junit: - - "${CI_PROJECT_DIR}/_build/report.xml" + - "${CI_PROJECT_DIR}/_build/report-x11.xml" + - "${CI_PROJECT_DIR}/_build/report-wayland.xml" + - "${CI_PROJECT_DIR}/_build/report-broadway.xml" name: "gtk-${CI_COMMIT_REF_NAME}" paths: - "${CI_PROJECT_DIR}/_build/meson-logs" - - "${CI_PROJECT_DIR}/_build/report.xml" - - "${CI_PROJECT_DIR}/_build/report.html" - - "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*.png" - - "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*.png" - - "${CI_PROJECT_DIR}/_build/testsuite/css/output/*.syscap" + - "${CI_PROJECT_DIR}/_build/report*.xml" + - "${CI_PROJECT_DIR}/_build/report*.html" + - "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.png" + - "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.png" + - "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap" cache: key: "$CI_JOB_NAME" <<: *cache-paths @@ -78,20 +82,20 @@ release-build: -Dvulkan=yes _build - ninja -C _build - - .gitlab-ci/run-tests.sh _build + - .gitlab-ci/run-tests.sh _build x11 artifacts: when: always reports: junit: - - "${CI_PROJECT_DIR}/_build/report.xml" + - "${CI_PROJECT_DIR}/_build/report-x11.xml" name: "gtk-${CI_COMMIT_REF_NAME}" paths: - "${CI_PROJECT_DIR}/_build/meson-logs" - - "${CI_PROJECT_DIR}/_build/report.xml" - - "${CI_PROJECT_DIR}/_build/report.html" - - "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*.png" - - "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*.png" - - "${CI_PROJECT_DIR}/_build/testsuite/css/output/*.syscap" + - "${CI_PROJECT_DIR}/_build/report*.xml" + - "${CI_PROJECT_DIR}/_build/report*.html" + - "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.png" + - "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.png" + - "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap" cache: key: "$CI_JOB_NAME" <<: *cache-paths diff --git a/.gitlab-ci/fedora.Dockerfile b/.gitlab-ci/fedora.Dockerfile index f5bb9ef6dd..217dd45a98 100644 --- a/.gitlab-ci/fedora.Dockerfile +++ b/.gitlab-ci/fedora.Dockerfile @@ -78,6 +78,8 @@ RUN dnf -y install \ vulkan-devel \ wayland-devel \ wayland-protocols-devel \ + weston \ + weston-libs \ which \ xorg-x11-server-Xvfb \ && dnf clean all diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh index ef0f56154e..02e5e64dc2 100755 --- a/.gitlab-ci/run-docker.sh +++ b/.gitlab-ci/run-docker.sh @@ -95,7 +95,7 @@ if [ ! -x "$(command -v docker)" ] || [ docker --help |& grep -q podman ]; then else echo "Using: Docker" format="" - CMD="sudo socker" + CMD="sudo docker" fi REGISTRY="registry.gitlab.gnome.org" diff --git a/.gitlab-ci/run-tests.sh b/.gitlab-ci/run-tests.sh index 5638fa6593..e259ec5bd2 100755 --- a/.gitlab-ci/run-tests.sh +++ b/.gitlab-ci/run-tests.sh @@ -5,30 +5,70 @@ set +e srcdir=$( pwd ) builddir=$1 +backend=$2 -export GDK_BACKEND=x11 -xvfb-run -a -s "-screen 0 1024x768x24" \ - meson test -C ${builddir} \ +case "${backend}" in + x11) + xvfb-run -a -s "-screen 0 1024x768x24" \ + meson test -C ${builddir} \ --print-errorlogs \ + --setup=${backend} \ --suite=gtk \ --no-suite=gtk:a11y -# Store the exit code for the CI run, but always -# generate the reports -exit_code=$? + # Store the exit code for the CI run, but always + # generate the reports + exit_code=$? + ;; + + wayland) + export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)" + + weston --backend=headless-backend.so --socket=wayland-5 & + compositor=$! + export WAYLAND_DISPLAY=wayland-5 + + meson test -C ${builddir} \ + --print-errorlogs \ + --setup=${backend} \ + --suite=gtk \ + --no-suite=gtk:a11y + + exit_code=$? + kill ${compositor} + ;; + + broadway) + export XDG_RUNTIME_DIR="$(mktemp -p $(pwd) -d xdg-runtime-XXXXXX)" + + ${builddir}/gdk/broadway/gtk4-broadwayd :5 & + server=$! + export BROADWAY_DISPLAY=:5 + + meson test -C ${builddir} \ + --print-errorlogs \ + --setup=${backend} \ + --suite=gtk \ + --no-suite=gtk:a11y + + # don't let Broadway failures fail the run, for now + exit_code=0 + kill ${server} + ;; +esac cd ${builddir} $srcdir/.gitlab-ci/meson-junit-report.py \ --project-name=gtk \ --job-id="${CI_JOB_NAME}" \ - --output=report.xml \ - meson-logs/testlog.json + --output=report-${backend}.xml \ + meson-logs/testlog-${backend}.json $srcdir/.gitlab-ci/meson-html-report.py \ --project-name=gtk \ --job-id="${CI_JOB_NAME}" \ - --reftest-output-dir="testsuite/reftests/output" \ - --output=report.html \ - meson-logs/testlog.json + --reftest-output-dir="testsuite/reftests/output/${backend}" \ + --output=report-${backend}.html \ + meson-logs/testlog-${backend}.json exit $exit_code diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index 9274ca1318..f99128459e 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -1497,7 +1497,10 @@ gdk_display_remove_seat (GdkDisplay *display, * * Returns the default #GdkSeat for this display. * - * Returns: (transfer none): the default seat. + * Note that a display may not have a seat. In this case, + * this function will return %NULL. + * + * Returns: (transfer none) (nullable): the default seat. **/ GdkSeat * gdk_display_get_default_seat (GdkDisplay *display) diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index b6ee8f577a..4835c7ba42 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -1746,10 +1746,14 @@ gdk_surface_hide (GdkSurface *surface) /* May need to break grabs on children */ display = surface->display; seat = gdk_display_get_default_seat (display); - - devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL); - devices = g_list_prepend (devices, gdk_seat_get_keyboard (seat)); - devices = g_list_prepend (devices, gdk_seat_get_pointer (seat)); + if (seat) + { + devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL); + devices = g_list_prepend (devices, gdk_seat_get_keyboard (seat)); + devices = g_list_prepend (devices, gdk_seat_get_pointer (seat)); + } + else + devices = NULL; for (d = devices; d; d = d->next) { diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 037af89fdb..7985f4292d 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -931,10 +931,13 @@ gdk_wayland_display_notify_startup_complete (GdkDisplay *display, static GdkKeymap * _gdk_wayland_display_get_keymap (GdkDisplay *display) { + GdkSeat *seat; GdkDevice *core_keyboard = NULL; static GdkKeymap *tmp_keymap = NULL; - core_keyboard = gdk_seat_get_keyboard (gdk_display_get_default_seat (display)); + seat = gdk_display_get_default_seat (display); + if (seat) + core_keyboard = gdk_seat_get_keyboard (seat); if (core_keyboard && tmp_keymap) { diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 451d0bb703..5411e24151 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -2686,11 +2686,13 @@ gdk_wayland_surface_hide (GdkSurface *surface) GdkSeat *seat; seat = gdk_display_get_default_seat (surface->display); + if (seat) + { + if (surface->autohide) + gdk_seat_ungrab (seat); - if (surface->autohide) - gdk_seat_ungrab (seat); - - gdk_wayland_seat_clear_touchpoints (GDK_WAYLAND_SEAT (seat), surface); + gdk_wayland_seat_clear_touchpoints (GDK_WAYLAND_SEAT (seat), surface); + } gdk_wayland_surface_hide_surface (surface); _gdk_surface_clear_update_area (surface); } @@ -2923,28 +2925,34 @@ gdk_wayland_surface_present_popup (GdkSurface *surface, { if (surface->autohide) { - GrabPrepareData data; - GdkGrabStatus result; + GdkSeat *seat; - data = (GrabPrepareData) { - .width = width, - .height = height, - .layout = layout, - }; - - result = gdk_seat_grab (gdk_display_get_default_seat (surface->display), - surface, - GDK_SEAT_CAPABILITY_ALL, - TRUE, - NULL, NULL, - show_grabbing_popup, &data); - if (result != GDK_GRAB_SUCCESS) + seat = gdk_display_get_default_seat (surface->display); + if (seat) { - const char *grab_status[] = { - "success", "already grabbed", "invalid time", - "not viewable", "frozen", "failed" + GrabPrepareData data; + GdkGrabStatus result; + + data = (GrabPrepareData) { + .width = width, + .height = height, + .layout = layout, }; - g_warning ("Grab failed: %s", grab_status[result]); + + result = gdk_seat_grab (seat, + surface, + GDK_SEAT_CAPABILITY_ALL, + TRUE, + NULL, NULL, + show_grabbing_popup, &data); + if (result != GDK_GRAB_SUCCESS) + { + const char *grab_status[] = { + "success", "already grabbed", "invalid time", + "not viewable", "frozen", "failed" + }; + g_warning ("Grab failed: %s", grab_status[result]); + } } } else diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 2aac9270d0..a66581cb48 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -4937,25 +4937,37 @@ gtk_label_get_single_line_mode (GtkLabel *self) */ static void get_better_cursor (GtkLabel *self, - gint index, - gint *x, - gint *y) + int index, + int *x, + int *y) { - GdkSeat *seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self))); - GdkDevice *device = gdk_seat_get_keyboard (seat); - PangoDirection keymap_direction = gdk_device_get_direction (device); - PangoDirection cursor_direction = get_cursor_direction (self); + GdkSeat *seat; + GdkDevice *keyboard; + PangoDirection keymap_direction; + PangoDirection cursor_direction; gboolean split_cursor; PangoRectangle strong_pos, weak_pos; - + + seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self))); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + else + keyboard = NULL; + if (keyboard) + keymap_direction = gdk_device_get_direction (keyboard); + else + keymap_direction = PANGO_DIRECTION_LTR; + + cursor_direction = get_cursor_direction (self); + g_object_get (gtk_widget_get_settings (GTK_WIDGET (self)), - "gtk-split-cursor", &split_cursor, - NULL); + "gtk-split-cursor", &split_cursor, + NULL); gtk_label_ensure_layout (self); - + pango_layout_get_cursor_pos (self->layout, index, - &strong_pos, &weak_pos); + &strong_pos, &weak_pos); if (split_cursor) { @@ -4965,15 +4977,15 @@ get_better_cursor (GtkLabel *self, else { if (keymap_direction == cursor_direction) - { - *x = strong_pos.x / PANGO_SCALE; - *y = strong_pos.y / PANGO_SCALE; - } + { + *x = strong_pos.x / PANGO_SCALE; + *y = strong_pos.y / PANGO_SCALE; + } else - { - *x = weak_pos.x / PANGO_SCALE; - *y = weak_pos.y / PANGO_SCALE; - } + { + *x = weak_pos.x / PANGO_SCALE; + *y = weak_pos.y / PANGO_SCALE; + } } } @@ -5041,16 +5053,26 @@ gtk_label_move_visually (GtkLabel *self, NULL); if (split_cursor) - strong = TRUE; + strong = TRUE; else - { - GdkSeat *seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self))); - GdkDevice *device = gdk_seat_get_keyboard (seat); - PangoDirection keymap_direction = gdk_device_get_direction (device); + { + GdkSeat *seat; + GdkDevice *keyboard; + PangoDirection keymap_direction; + + seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self))); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + else + keyboard = NULL; + if (keyboard) + keymap_direction = gdk_device_get_direction (keyboard); + else + keymap_direction = PANGO_DIRECTION_LTR; + + strong = keymap_direction == get_cursor_direction (self); + } - strong = keymap_direction == get_cursor_direction (self); - } - if (count > 0) { pango_layout_move_cursor_visually (self->layout, strong, index, 0, 1, &new_index, &new_trailing); diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c index d26bf75645..ab68a7dbd8 100644 --- a/gtk/gtkpasswordentry.c +++ b/gtk/gtkpasswordentry.c @@ -167,12 +167,20 @@ gtk_password_entry_realize (GtkWidget *widget) { GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (widget); GtkPasswordEntryPrivate *priv = gtk_password_entry_get_instance_private (entry); + GdkSeat *seat; GTK_WIDGET_CLASS (gtk_password_entry_parent_class)->realize (widget); - priv->keyboard = gdk_seat_get_keyboard (gdk_display_get_default_seat (gtk_widget_get_display (widget))); - g_signal_connect (priv->keyboard, "notify::caps-lock-state", G_CALLBACK (caps_lock_state_changed), entry); - caps_lock_state_changed (priv->keyboard, NULL, widget); + seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); + if (seat) + priv->keyboard = gdk_seat_get_keyboard (seat); + + if (priv->keyboard) + { + g_signal_connect (priv->keyboard, "notify::caps-lock-state", + G_CALLBACK (caps_lock_state_changed), entry); + caps_lock_state_changed (priv->keyboard, NULL, widget); + } } static void @@ -496,7 +504,8 @@ gtk_password_entry_set_show_peek_icon (GtkPasswordEntry *entry, entry); } - caps_lock_state_changed (priv->keyboard, NULL, GTK_WIDGET (entry)); + if (priv->keyboard) + caps_lock_state_changed (priv->keyboard, NULL, GTK_WIDGET (entry)); g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_SHOW_PEEK_ICON]); } diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 7c40e4a055..0a11c83007 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -1151,6 +1151,7 @@ gtk_render_insertion_cursor (GtkStyleContext *context, float aspect_ratio; PangoRectangle strong_pos, weak_pos; PangoRectangle *cursor1, *cursor2; + GdkSeat *seat; GdkDevice *keyboard; PangoDirection keyboard_direction; PangoDirection direction2; @@ -1165,8 +1166,15 @@ gtk_render_insertion_cursor (GtkStyleContext *context, "gtk-cursor-aspect-ratio", &aspect_ratio, NULL); - keyboard = gdk_seat_get_keyboard (gdk_display_get_default_seat (priv->display)); - keyboard_direction = gdk_device_get_direction (keyboard); + seat = gdk_display_get_default_seat (priv->display); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + else + keyboard = NULL; + if (keyboard) + keyboard_direction = gdk_device_get_direction (keyboard); + else + keyboard_direction = PANGO_DIRECTION_LTR; pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos); @@ -1240,6 +1248,7 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot, float aspect_ratio; PangoRectangle strong_pos, weak_pos; PangoRectangle *cursor1, *cursor2; + GdkSeat *seat; GdkDevice *keyboard; PangoDirection keyboard_direction; PangoDirection direction2; @@ -1254,8 +1263,15 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot, "gtk-cursor-aspect-ratio", &aspect_ratio, NULL); - keyboard = gdk_seat_get_keyboard (gdk_display_get_default_seat (priv->display)); - keyboard_direction = gdk_device_get_direction (keyboard); + seat = gdk_display_get_default_seat (priv->display); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + else + keyboard = NULL; + if (keyboard) + keyboard_direction = gdk_device_get_direction (keyboard); + else + keyboard_direction = PANGO_DIRECTION_LTR; pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos); diff --git a/gtk/gtktext.c b/gtk/gtktext.c index e12878fce9..4dc3664a0c 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -1920,7 +1920,7 @@ gtk_text_dispose (GObject *object) GtkText *self = GTK_TEXT (object); GtkTextPrivate *priv = gtk_text_get_instance_private (self); GdkSeat *seat; - GdkDevice *keyboard; + GdkDevice *keyboard = NULL; GtkWidget *chooser; priv->current_pos = priv->selection_bound = 0; @@ -1949,8 +1949,10 @@ gtk_text_dispose (GObject *object) gtk_widget_unparent (chooser); seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (object))); - keyboard = gdk_seat_get_keyboard (seat); - g_signal_handlers_disconnect_by_func (keyboard, direction_changed, self); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + if (keyboard) + g_signal_handlers_disconnect_by_func (keyboard, direction_changed, self); g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent); g_clear_pointer (&priv->popup_menu, gtk_widget_unparent); @@ -3129,13 +3131,18 @@ gtk_text_focus_in (GtkWidget *widget) { GtkText *self = GTK_TEXT (widget); GtkTextPrivate *priv = gtk_text_get_instance_private (self); - GdkSeat *seat; - GdkDevice *keyboard; + GdkSeat *seat = NULL; + GdkDevice *keyboard = NULL; gtk_widget_queue_draw (widget); seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); - keyboard = gdk_seat_get_keyboard (seat); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + if (keyboard) + g_signal_connect (keyboard, "notify::direction", + G_CALLBACK (direction_changed), self); + if (priv->editable) { @@ -3143,9 +3150,6 @@ gtk_text_focus_in (GtkWidget *widget) gtk_im_context_focus_in (priv->im_context); } - g_signal_connect (keyboard, "notify::direction", - G_CALLBACK (direction_changed), self); - gtk_text_reset_blink_time (self); gtk_text_check_cursor_blink (self); } @@ -3155,8 +3159,8 @@ gtk_text_focus_out (GtkWidget *widget) { GtkText *self = GTK_TEXT (widget); GtkTextPrivate *priv = gtk_text_get_instance_private (self); - GdkSeat *seat; - GdkDevice *keyboard; + GdkSeat *seat = NULL; + GdkDevice *keyboard = NULL; gtk_text_selection_bubble_popup_unset (self); @@ -3166,7 +3170,10 @@ gtk_text_focus_out (GtkWidget *widget) gtk_widget_queue_draw (widget); seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); - keyboard = gdk_seat_get_keyboard (seat); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + if (keyboard) + g_signal_handlers_disconnect_by_func (keyboard, direction_changed, self); if (priv->editable) { @@ -3175,8 +3182,6 @@ gtk_text_focus_out (GtkWidget *widget) } gtk_text_check_cursor_blink (self); - - g_signal_handlers_disconnect_by_func (keyboard, direction_changed, self); } static gboolean @@ -3656,15 +3661,21 @@ get_better_cursor_x (GtkText *self, int offset) { GtkTextPrivate *priv = gtk_text_get_instance_private (self); - GdkSeat *seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self))); - GdkDevice *keyboard = gdk_seat_get_keyboard (seat); - PangoDirection direction = gdk_device_get_direction (keyboard); + GdkSeat *seat; + GdkDevice *keyboard = NULL; + PangoDirection direction = PANGO_DIRECTION_LTR; gboolean split_cursor; PangoLayout *layout = gtk_text_ensure_layout (self, TRUE); const char *text = pango_layout_get_text (layout); int index = g_utf8_offset_to_pointer (text, offset) - text; PangoRectangle strong_pos, weak_pos; - + + seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self))); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + if (keyboard) + direction = gdk_device_get_direction (keyboard); + g_object_get (gtk_widget_get_settings (GTK_WIDGET (self)), "gtk-split-cursor", &split_cursor, NULL); @@ -4377,11 +4388,19 @@ gtk_text_create_layout (GtkText *self, { if (gtk_widget_has_focus (widget)) { - GdkDisplay *display = gtk_widget_get_display (widget); - GdkSeat *seat = gdk_display_get_default_seat (display); - GdkDevice *keyboard = gdk_seat_get_keyboard (seat); + GdkDisplay *display; + GdkSeat *seat; + GdkDevice *keyboard = NULL; + PangoDirection direction = PANGO_DIRECTION_LTR; - if (gdk_device_get_direction (keyboard) == PANGO_DIRECTION_RTL) + display = gtk_widget_get_display (widget); + seat = gdk_display_get_default_seat (display); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + if (keyboard) + direction = gdk_device_get_direction (keyboard); + + if (direction == PANGO_DIRECTION_RTL) pango_dir = PANGO_DIRECTION_RTL; else pango_dir = PANGO_DIRECTION_LTR; @@ -4941,14 +4960,21 @@ gtk_text_move_visually (GtkText *self, strong = TRUE; else { - GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (self)); - GdkSeat *seat = gdk_display_get_default_seat (display); - GdkDevice *keyboard = gdk_seat_get_keyboard (seat); - PangoDirection direction = gdk_device_get_direction (keyboard); + GdkDisplay *display; + GdkSeat *seat; + GdkDevice *keyboard = NULL; + PangoDirection direction = PANGO_DIRECTION_LTR; + + display = gtk_widget_get_display (GTK_WIDGET (self)); + seat = gdk_display_get_default_seat (display); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + if (keyboard) + direction = gdk_device_get_direction (keyboard); strong = direction == priv->resolved_dir; } - + if (count > 0) { pango_layout_move_cursor_visually (layout, strong, index, 0, 1, &new_index, &new_trailing); diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index c6cfcd5996..a6a02473ab 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -5524,9 +5524,14 @@ gtk_text_view_focus_in (GtkWidget *widget) } seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); - keyboard = gdk_seat_get_keyboard (seat); - g_signal_connect (keyboard, "notify::direction", - G_CALLBACK (direction_changed), text_view); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + else + keyboard = NULL; + + if (keyboard) + g_signal_connect (keyboard, "notify::direction", + G_CALLBACK (direction_changed), text_view); gtk_text_view_check_keymap_direction (text_view); if (priv->editable) @@ -5557,8 +5562,12 @@ gtk_text_view_focus_out (GtkWidget *widget) } seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); - keyboard = gdk_seat_get_keyboard (seat); - g_signal_handlers_disconnect_by_func (keyboard, direction_changed, text_view); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + else + keyboard = NULL; + if (keyboard) + g_signal_handlers_disconnect_by_func (keyboard, direction_changed, text_view); gtk_text_view_selection_bubble_popup_unset (text_view); text_view->priv->text_handles_enabled = FALSE; @@ -7492,33 +7501,44 @@ static void gtk_text_view_check_keymap_direction (GtkTextView *text_view) { GtkTextViewPrivate *priv = text_view->priv; + GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (text_view)); + GdkSeat *seat; + GdkDevice *keyboard; + PangoDirection direction; + GtkTextDirection new_cursor_dir; + GtkTextDirection new_keyboard_dir; + gboolean split_cursor; - if (priv->layout) - { - GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (text_view)); - GdkSeat *seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (text_view))); - GdkDevice *keyboard = gdk_seat_get_keyboard (seat); - GtkTextDirection new_cursor_dir; - GtkTextDirection new_keyboard_dir; - gboolean split_cursor; + if (!priv->layout) + return; - g_object_get (settings, - "gtk-split-cursor", &split_cursor, - NULL); - - if (gdk_device_get_direction (keyboard) == PANGO_DIRECTION_RTL) - new_keyboard_dir = GTK_TEXT_DIR_RTL; - else - new_keyboard_dir = GTK_TEXT_DIR_LTR; - - if (split_cursor) - new_cursor_dir = GTK_TEXT_DIR_NONE; - else - new_cursor_dir = new_keyboard_dir; - - gtk_text_layout_set_cursor_direction (priv->layout, new_cursor_dir); - gtk_text_layout_set_keyboard_direction (priv->layout, new_keyboard_dir); - } + seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (text_view))); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + else + keyboard = NULL; + + if (keyboard) + direction = gdk_device_get_direction (keyboard); + else + direction = PANGO_DIRECTION_LTR; + + g_object_get (settings, + "gtk-split-cursor", &split_cursor, + NULL); + + if (direction == PANGO_DIRECTION_RTL) + new_keyboard_dir = GTK_TEXT_DIR_RTL; + else + new_keyboard_dir = GTK_TEXT_DIR_LTR; + + if (split_cursor) + new_cursor_dir = GTK_TEXT_DIR_NONE; + else + new_cursor_dir = new_keyboard_dir; + + gtk_text_layout_set_cursor_direction (priv->layout, new_cursor_dir); + gtk_text_layout_set_keyboard_direction (priv->layout, new_keyboard_dir); } static void diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c index 4af709f19e..a6962641af 100644 --- a/gtk/gtktooltip.c +++ b/gtk/gtktooltip.c @@ -371,9 +371,10 @@ void gtk_tooltip_trigger_tooltip_query (GtkWidget *widget) { GdkDisplay *display; - double x, y; - GdkSurface *surface; + GdkSeat *seat; GdkDevice *device; + GdkSurface *surface; + double x, y; GtkWidget *toplevel; int dx, dy; @@ -382,8 +383,15 @@ gtk_tooltip_trigger_tooltip_query (GtkWidget *widget) display = gtk_widget_get_display (widget); /* Trigger logic as if the mouse moved */ - device = gdk_seat_get_pointer (gdk_display_get_default_seat (display)); - surface = gdk_device_get_surface_at_position (device, &x, &y); + seat = gdk_display_get_default_seat (display); + if (seat) + device = gdk_seat_get_pointer (seat); + else + device = NULL; + if (device) + surface = gdk_device_get_surface_at_position (device, &x, &y); + else + surface = NULL; if (!surface) return; @@ -673,6 +681,7 @@ gtk_tooltip_show_tooltip (GdkDisplay *display) gint x, y; GdkSurface *surface; GtkWidget *tooltip_widget; + GdkSeat *seat; GdkDevice *device; GtkTooltip *tooltip; gboolean return_value = FALSE; @@ -684,9 +693,17 @@ gtk_tooltip_show_tooltip (GdkDisplay *display) surface = gtk_native_get_surface (GTK_NATIVE (tooltip->native)); - device = gdk_seat_get_pointer (gdk_display_get_default_seat (display)); + seat = gdk_display_get_default_seat (display); + if (seat) + device = gdk_seat_get_pointer (seat); + else + device = NULL; + + if (device) + gdk_surface_get_device_position (surface, device, &px, &py, NULL); + else + px = py = 0; - gdk_surface_get_device_position (surface, device, &px, &py, NULL); x = round (px); y = round (py); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index c314305071..a537530b80 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -7636,13 +7636,17 @@ _gtk_widget_list_devices (GtkWidget *widget, return NULL; } - result = g_ptr_array_new (); seat = gdk_display_get_default_seat (_gtk_widget_get_display (widget)); - device = gdk_seat_get_pointer (seat); - if (is_my_surface (widget, gdk_device_get_last_event_surface (device))) + if (!seat) { - g_ptr_array_add (result, device); + *out_n_devices = 0; + return NULL; } + device = gdk_seat_get_pointer (seat); + + result = g_ptr_array_new (); + if (is_my_surface (widget, gdk_device_get_last_event_surface (device))) + g_ptr_array_add (result, device); devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL_POINTING); for (l = devices; l; l = l->next) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index c8e51c5073..ddfb38792f 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -1578,8 +1578,9 @@ gtk_window_init (GtkWindow *window) gtk_widget_add_controller (GTK_WIDGET (window), GTK_EVENT_CONTROLLER (target)); seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); - g_signal_connect (seat, "device-removed", - G_CALLBACK (device_removed_cb), window); + if (seat) + g_signal_connect (seat, "device-removed", + G_CALLBACK (device_removed_cb), window); controller = gtk_event_controller_motion_new (); gtk_event_controller_set_propagation_phase (controller, @@ -3726,6 +3727,7 @@ gtk_window_finalize (GObject *object) { GtkWindow *window = GTK_WINDOW (object); GtkWindowPrivate *priv = gtk_window_get_instance_private (window); + GdkSeat *seat; g_clear_pointer (&priv->extra_input_region, cairo_region_destroy); g_free (priv->title); @@ -3742,9 +3744,9 @@ gtk_window_finalize (GObject *object) priv->keys_changed_handler = 0; } - g_signal_handlers_disconnect_by_func (gdk_display_get_default_seat (priv->display), - device_removed_cb, - window); + seat = gdk_display_get_default_seat (priv->display); + if (seat) + g_signal_handlers_disconnect_by_func (seat, device_removed_cb, window); #ifdef GDK_WINDOWING_X11 g_signal_handlers_disconnect_by_func (gtk_settings_get_for_display (priv->display), diff --git a/gtk/inspector/inspect-button.c b/gtk/inspector/inspect-button.c index 64c198f2dc..5af4176418 100644 --- a/gtk/inspector/inspect-button.c +++ b/gtk/inspector/inspect-button.c @@ -229,11 +229,16 @@ void gtk_inspector_window_select_widget_under_pointer (GtkInspectorWindow *iw) { GdkDisplay *display; + GdkSeat *seat; GdkDevice *device; GtkWidget *widget; display = gtk_inspector_window_get_inspected_display (iw); - device = gdk_seat_get_pointer (gdk_display_get_default_seat (display)); + seat = gdk_display_get_default_seat (display); + if (!seat) + return; + + device = gdk_seat_get_pointer (seat); widget = find_widget_at_pointer (device); diff --git a/testsuite/a11y/meson.build b/testsuite/a11y/meson.build index 57daf3e72c..ec3a8a3a2a 100644 --- a/testsuite/a11y/meson.build +++ b/testsuite/a11y/meson.build @@ -54,14 +54,8 @@ foreach t: a11y_state_tests args: [ '--tap', '-k', ui_path ], protocol: 'tap', env: [ - 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir), ], suite: 'a11y', ) @@ -89,13 +83,9 @@ foreach t: a11y_tests args: [ '--tap', '-k', ], protocol: 'tap', timeout: 120, - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir), ], suite: 'a11y') endforeach diff --git a/testsuite/css/change/meson.build b/testsuite/css/change/meson.build index 1d5e6dc7c6..9de434955b 100644 --- a/testsuite/css/change/meson.build +++ b/testsuite/css/change/meson.build @@ -12,11 +12,7 @@ test_change = executable( test('change', test_change, args: [ '--tap', '-k' ], protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], diff --git a/testsuite/css/meson.build b/testsuite/css/meson.build index 18334d1ead..bac0ebd074 100644 --- a/testsuite/css/meson.build +++ b/testsuite/css/meson.build @@ -14,11 +14,7 @@ test_api = executable('api', 'api.c', test('api', test_api, args: ['--tap', '-k' ], protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], @@ -33,11 +29,7 @@ test_data = executable('data', ['data.c', '../../gtk/css/gtkcssdataurl.c'], test('data', test_data, args: ['--tap', '-k' ], protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], @@ -59,8 +51,7 @@ if false and get_option ('profiler') '--name', 'performance-adwaita', '--output', join_paths(meson.current_build_dir(), 'output'), join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ], - env: [ 'GTK_THEME=Adwaita', - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ], + env: [ 'GTK_THEME=Adwaita' ], suite: [ 'css' ]) test('performance-empty', test_performance, @@ -68,8 +59,7 @@ if false and get_option ('profiler') '--name', 'performance-empty', '--output', join_paths(meson.current_build_dir(), 'output'), join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ], - env: [ 'GTK_THEME=Empty', - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ], + env: [ 'GTK_THEME=Empty' ], suite: [ 'css' ]) endif diff --git a/testsuite/css/nodes/meson.build b/testsuite/css/nodes/meson.build index 264da09100..720ba46db8 100644 --- a/testsuite/css/nodes/meson.build +++ b/testsuite/css/nodes/meson.build @@ -9,11 +9,7 @@ test_nodes = executable('test-css-nodes', 'test-css-nodes.c', test('nodes', test_nodes, args: [ '--tap', '-k' ], protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], diff --git a/testsuite/css/parser/meson.build b/testsuite/css/parser/meson.build index d09d668f02..7ffd5d2644 100644 --- a/testsuite/css/parser/meson.build +++ b/testsuite/css/parser/meson.build @@ -463,13 +463,9 @@ foreach testname : test_data join_paths(meson.current_source_dir(), testname), ], protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), - 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) + 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], suite: 'css') endif diff --git a/testsuite/css/style/meson.build b/testsuite/css/style/meson.build index 0006359f9a..cadbf8dc16 100644 --- a/testsuite/css/style/meson.build +++ b/testsuite/css/style/meson.build @@ -19,11 +19,7 @@ test_style = executable( test('style', test_style, args: [ '--tap', '-k' ], protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], diff --git a/testsuite/gdk/meson.build b/testsuite/gdk/meson.build index 69d6481490..75b6c078a0 100644 --- a/testsuite/gdk/meson.build +++ b/testsuite/gdk/meson.build @@ -22,11 +22,7 @@ foreach t : tests test(t, test_exe, args: [ '--tap', '-k' ], protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], diff --git a/testsuite/gdk/seat.c b/testsuite/gdk/seat.c index e87c2b26a6..36a7da5d11 100644 --- a/testsuite/gdk/seat.c +++ b/testsuite/gdk/seat.c @@ -10,11 +10,12 @@ test_list_seats (void) display = gdk_display_get_default (); seat0 = gdk_display_get_default_seat (display); - - g_assert_true (GDK_IS_SEAT (seat0)); + if (seat0 != NULL) + g_assert_true (GDK_IS_SEAT (seat0)); found_default = FALSE; list = gdk_display_list_seats (display); + for (l = list; l; l = l->next) { seat = l->data; @@ -25,9 +26,13 @@ test_list_seats (void) if (seat == seat0) found_default = TRUE; } - g_list_free (list); - g_assert_true (found_default); + if (seat0 != NULL) + g_assert_true (found_default); + else + g_assert_true (list == NULL); + + g_list_free (list); } static void @@ -42,6 +47,12 @@ test_default_seat (void) display = gdk_display_get_default (); seat0 = gdk_display_get_default_seat (display); + if (seat0 == NULL) + { + g_test_skip ("Display has no seats"); + return; + } + g_assert_true (GDK_IS_SEAT (seat0)); caps = gdk_seat_get_capabilities (seat0); diff --git a/testsuite/gsk/compare-render.c b/testsuite/gsk/compare-render.c index e61fa71e66..3883ed766e 100644 --- a/testsuite/gsk/compare-render.c +++ b/testsuite/gsk/compare-render.c @@ -19,6 +19,16 @@ get_output_dir (void) if (arg_output_dir) { GFile *file = g_file_new_for_commandline_arg (arg_output_dir); + const char *subdir; + + subdir = g_getenv ("TEST_OUTPUT_SUBDIR"); + if (subdir) + { + GFile *child = g_file_get_child (file, subdir); + g_object_unref (file); + file = child; + } + output_dir = g_file_get_path (file); g_object_unref (file); } diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build index 225ce98261..0eeff8d3e8 100644 --- a/testsuite/gsk/meson.build +++ b/testsuite/gsk/meson.build @@ -90,14 +90,10 @@ foreach renderer : renderers args: ['--output', join_paths(meson.current_build_dir(), 'compare', renderer[0]), join_paths(meson.current_source_dir(), 'compare', test + '.node'), join_paths(meson.current_source_dir(), 'compare', test + '.png')], - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ + 'GSK_RENDERER=' + renderer[0], 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), - 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), - 'GSK_RENDERER=' + renderer[0] + 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], suite: [ 'gsk', 'gsk-compare', 'gsk-' + renderer[0], 'gsk-compare-' + renderer[0] ]) endif @@ -171,14 +167,10 @@ foreach test : node_parser_tests test('parser ' + test, node_parser, args: [ join_paths(meson.current_source_dir(), 'nodeparser', test) ], - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ + 'GSK_RENDERER=opengl', 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), - 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), - 'GSK_RENDERER=opengl' + 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], suite: 'gsk') endif @@ -207,15 +199,10 @@ foreach t : tests test(test_name, test_exe, args: [ '--tap', '-k' ], protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'GSK_RENDERER=cairo', 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), - 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir), + 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], suite: 'gsk') endforeach diff --git a/testsuite/gtk/displayclose.c b/testsuite/gtk/displayclose.c index 55da35c0f8..5c1c2fee8a 100644 --- a/testsuite/gtk/displayclose.c +++ b/testsuite/gtk/displayclose.c @@ -19,7 +19,7 @@ main (int argc, char **argv) display = gdk_display_open (display_name); if (!display) - return 1; + return 0; gdk_display_manager_set_default_display (gdk_display_manager_get (), display); @@ -27,7 +27,7 @@ main (int argc, char **argv) but = gtk_button_new_with_label ("Try to Exit"); g_signal_connect_swapped (but, "clicked", - G_CALLBACK (gtk_window_destroy), win); + G_CALLBACK (gtk_window_destroy), win); gtk_window_set_child (GTK_WINDOW (win), but); gtk_widget_show (win); diff --git a/testsuite/gtk/meson.build b/testsuite/gtk/meson.build index df05b51b64..faf853a380 100644 --- a/testsuite/gtk/meson.build +++ b/testsuite/gtk/meson.build @@ -111,16 +111,11 @@ foreach t : tests test(test_name, test_exe, args: [ '--tap', '-k' ], protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'NO_AT_BRIDGE=1', 'GSK_RENDERER=cairo', 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir), ], suite: 'gtk', should_fail: expect_fail, @@ -138,14 +133,9 @@ if add_languages('cpp', required: false) test('c++ keywords', test_exe, args: [ '--tap', '-k' ], #protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir), ], suite: 'gtk') if get_option('install-tests') @@ -192,12 +182,7 @@ foreach test : focus_chain_tests test(test[0] + ' ' + test[1], focus_chain, args: [ join_paths(meson.current_source_dir(), 'focus-chain', test[0] + '.ui'), join_paths(meson.current_source_dir(), 'focus-chain', test[0] + '.' + test[1]) ], - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir), + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()) ], @@ -226,14 +211,12 @@ if false and get_option ('profiler') test('performance-layout', test_performance, args: [ '--mark', 'size allocation', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ], - env: [ 'GTK_THEME=Empty', - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ], + env: [ 'GTK_THEME=Empty' ], suite: [ 'gtk' ]) test('performance-snapshot', test_performance, args: [ '--mark', 'widget snapshot', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ], - env: [ 'GTK_THEME=Empty', - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ], + env: [ 'GTK_THEME=Empty' ], suite: [ 'gtk' ]) endif diff --git a/testsuite/gtk/shortcuts.c b/testsuite/gtk/shortcuts.c index 9b24b907bc..207970e6ea 100644 --- a/testsuite/gtk/shortcuts.c +++ b/testsuite/gtk/shortcuts.c @@ -289,6 +289,7 @@ test_trigger_trigger (void) { GtkShortcutTrigger *trigger[4]; GdkDisplay *display; + GdkSeat *seat; GdkSurface *surface; GdkDevice *device; GdkEvent *event; @@ -307,14 +308,21 @@ test_trigger_trigger (void) }; int i, j; + display = gdk_display_get_default (); + seat = gdk_display_get_default_seat (display); + if (!seat) + { + g_test_skip ("Display has no seat"); + return; + } + trigger[0] = g_object_ref (gtk_never_trigger_get ()); trigger[1] = gtk_keyval_trigger_new (GDK_KEY_a, GDK_CONTROL_MASK); trigger[2] = gtk_mnemonic_trigger_new (GDK_KEY_u); trigger[3] = gtk_alternative_trigger_new (g_object_ref (trigger[1]), g_object_ref (trigger[2])); - display = gdk_display_get_default (); - device = gdk_seat_get_keyboard (gdk_display_get_default_seat (display)); + device = gdk_seat_get_keyboard (seat); surface = gdk_surface_new_toplevel (display, 100, 100); for (i = 0; i < G_N_ELEMENTS (tests); i++) diff --git a/testsuite/meson.build b/testsuite/meson.build index e5c0abe398..3c725a530c 100644 --- a/testsuite/meson.build +++ b/testsuite/meson.build @@ -6,6 +6,34 @@ installed_test_datadir = join_paths(gtk_datadir, 'installed-tests', 'gtk-4.0') # otherwise we're going to have failures down the line diff = find_program('diff', required: true) +common_env = [ + 'GIO_USE_VOLUME_MONITOR=unix', + 'GSETTINGS_BACKEND=memory', + 'GDK_DEBUG=default-settings:misc', + 'GTK_CSD=1', + 'G_ENABLE_DIAGNOSTIC=0', + 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir), +] + +add_test_setup ('x11', + is_default: true, + env: common_env + [ + 'GDK_BACKEND=x11', + 'TEST_OUTPUT_SUBDIR=x11', + ]) + +add_test_setup ('wayland', + env: common_env + [ + 'GDK_BACKEND=wayland', + 'TEST_OUTPUT_SUBDIR=wayland', + ]) + +add_test_setup ('broadway', + env: common_env + [ + 'GDK_BACKEND=broadway', + 'TEST_OUTPUT_SUBDIR=broadway', + ]) + subdir('performance') subdir('gdk') subdir('gsk') diff --git a/testsuite/performance/test-performance.c b/testsuite/performance/test-performance.c index 9e7d8a710b..506763a751 100644 --- a/testsuite/performance/test-performance.c +++ b/testsuite/performance/test-performance.c @@ -89,8 +89,18 @@ main (int argc, char *argv[]) { GError *err = NULL; GFile *file; + const char *subdir; file = g_file_new_for_commandline_arg (opt_output); + + subdir = g_getenv ("TEST_OUTPUT_SUBDIR"); + if (subdir) + { + GFile *child = g_file_get_child (file, subdir); + g_object_unref (file); + file = child; + } + if (!g_file_make_directory_with_parents (file, NULL, &err)) { if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_EXISTS)) @@ -134,7 +144,7 @@ main (int argc, char *argv[]) if (!g_subprocess_get_successful (subprocess)) g_error ("Child process failed"); - + g_object_unref (subprocess); g_object_unref (launcher); diff --git a/testsuite/reftests/gtk-reftest.c b/testsuite/reftests/gtk-reftest.c index cf07fcc27f..41e28c05b9 100644 --- a/testsuite/reftests/gtk-reftest.c +++ b/testsuite/reftests/gtk-reftest.c @@ -109,8 +109,18 @@ get_output_dir (GError **error) { GError *err = NULL; GFile *file; + const char *subdir; file = g_file_new_for_commandline_arg (arg_output_dir); + + subdir = g_getenv ("TEST_OUTPUT_SUBDIR"); + if (subdir) + { + GFile *child = g_file_get_child (file, subdir); + g_object_unref (file); + file = child; + } + if (!g_file_make_directory_with_parents (file, NULL, &err)) { if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_EXISTS)) diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build index cb8451798e..e85699f0f7 100644 --- a/testsuite/reftests/meson.build +++ b/testsuite/reftests/meson.build @@ -438,16 +438,11 @@ foreach testname : testdata join_paths(meson.current_source_dir(), testname), ], protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir), - 'GTK_CSD=1', - 'GDK_DEBUG=default-settings', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ + 'GSK_RENDERER=opengl', 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), - 'GSK_RENDERER=opengl', - 'REFTEST_MODULE_DIR=@0@'.format(meson.current_build_dir()), + 'REFTEST_MODULE_DIR=@0@'.format(meson.current_build_dir()) ], suite: 'reftest', should_fail: xfails.contains(testname)) diff --git a/testsuite/tools/meson.build b/testsuite/tools/meson.build index fd385ba174..85fc54aac4 100644 --- a/testsuite/tools/meson.build +++ b/testsuite/tools/meson.build @@ -20,11 +20,7 @@ if bash.found() args: t, workdir: meson.current_build_dir(), protocol: 'tap', - env: [ 'GIO_USE_VOLUME_MONITOR=unix', - 'GSETTINGS_BACKEND=memory', - 'GDK_DEBUG=default-settings', - 'GTK_CSD=1', - 'G_ENABLE_DIAGNOSTIC=0', + env: [ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), 'GTK_BUILDER_TOOL=@0@'.format(get_variable('gtk4_builder_tool').full_path()),