Merge branch 'headless-seatless' into 'master'

gtk: Handle seatless displays

See merge request GNOME/gtk!1905
This commit is contained in:
Matthias Clasen 2020-05-15 21:13:01 +00:00
commit 5870f1c90a
35 changed files with 464 additions and 281 deletions

View File

@ -34,7 +34,7 @@ style-check-diff:
- .gitlab-ci/run-style-check-diff.sh - .gitlab-ci/run-style-check-diff.sh
fedora-x86_64: fedora-x86_64:
image: registry.gitlab.gnome.org/gnome/gtk/fedora:v16 image: registry.gitlab.gnome.org/gnome/gtk/fedora:v17
stage: build stage: build
variables: variables:
EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both" EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both"
@ -47,20 +47,24 @@ fedora-x86_64:
-Dprofiler=true -Dprofiler=true
_build _build
- ninja -C _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: artifacts:
when: always when: always
reports: reports:
junit: 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}" name: "gtk-${CI_COMMIT_REF_NAME}"
paths: paths:
- "${CI_PROJECT_DIR}/_build/meson-logs" - "${CI_PROJECT_DIR}/_build/meson-logs"
- "${CI_PROJECT_DIR}/_build/report.xml" - "${CI_PROJECT_DIR}/_build/report*.xml"
- "${CI_PROJECT_DIR}/_build/report.html" - "${CI_PROJECT_DIR}/_build/report*.html"
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*.png" - "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*.png" - "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*.syscap" - "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap"
cache: cache:
key: "$CI_JOB_NAME" key: "$CI_JOB_NAME"
<<: *cache-paths <<: *cache-paths
@ -78,20 +82,20 @@ release-build:
-Dvulkan=yes -Dvulkan=yes
_build _build
- ninja -C _build - ninja -C _build
- .gitlab-ci/run-tests.sh _build - .gitlab-ci/run-tests.sh _build x11
artifacts: artifacts:
when: always when: always
reports: reports:
junit: junit:
- "${CI_PROJECT_DIR}/_build/report.xml" - "${CI_PROJECT_DIR}/_build/report-x11.xml"
name: "gtk-${CI_COMMIT_REF_NAME}" name: "gtk-${CI_COMMIT_REF_NAME}"
paths: paths:
- "${CI_PROJECT_DIR}/_build/meson-logs" - "${CI_PROJECT_DIR}/_build/meson-logs"
- "${CI_PROJECT_DIR}/_build/report.xml" - "${CI_PROJECT_DIR}/_build/report*.xml"
- "${CI_PROJECT_DIR}/_build/report.html" - "${CI_PROJECT_DIR}/_build/report*.html"
- "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*.png" - "${CI_PROJECT_DIR}/_build/testsuite/reftests/output/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*.png" - "${CI_PROJECT_DIR}/_build/testsuite/gsk/compare/*/*/*.png"
- "${CI_PROJECT_DIR}/_build/testsuite/css/output/*.syscap" - "${CI_PROJECT_DIR}/_build/testsuite/css/output/*/*.syscap"
cache: cache:
key: "$CI_JOB_NAME" key: "$CI_JOB_NAME"
<<: *cache-paths <<: *cache-paths

View File

@ -78,6 +78,8 @@ RUN dnf -y install \
vulkan-devel \ vulkan-devel \
wayland-devel \ wayland-devel \
wayland-protocols-devel \ wayland-protocols-devel \
weston \
weston-libs \
which \ which \
xorg-x11-server-Xvfb \ xorg-x11-server-Xvfb \
&& dnf clean all && dnf clean all

View File

@ -95,7 +95,7 @@ if [ ! -x "$(command -v docker)" ] || [ docker --help |& grep -q podman ]; then
else else
echo "Using: Docker" echo "Using: Docker"
format="" format=""
CMD="sudo socker" CMD="sudo docker"
fi fi
REGISTRY="registry.gitlab.gnome.org" REGISTRY="registry.gitlab.gnome.org"

View File

@ -5,30 +5,70 @@ set +e
srcdir=$( pwd ) srcdir=$( pwd )
builddir=$1 builddir=$1
backend=$2
export GDK_BACKEND=x11 case "${backend}" in
xvfb-run -a -s "-screen 0 1024x768x24" \ x11)
meson test -C ${builddir} \ xvfb-run -a -s "-screen 0 1024x768x24" \
meson test -C ${builddir} \
--print-errorlogs \ --print-errorlogs \
--setup=${backend} \
--suite=gtk \ --suite=gtk \
--no-suite=gtk:a11y --no-suite=gtk:a11y
# Store the exit code for the CI run, but always # Store the exit code for the CI run, but always
# generate the reports # generate the reports
exit_code=$? 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} cd ${builddir}
$srcdir/.gitlab-ci/meson-junit-report.py \ $srcdir/.gitlab-ci/meson-junit-report.py \
--project-name=gtk \ --project-name=gtk \
--job-id="${CI_JOB_NAME}" \ --job-id="${CI_JOB_NAME}" \
--output=report.xml \ --output=report-${backend}.xml \
meson-logs/testlog.json meson-logs/testlog-${backend}.json
$srcdir/.gitlab-ci/meson-html-report.py \ $srcdir/.gitlab-ci/meson-html-report.py \
--project-name=gtk \ --project-name=gtk \
--job-id="${CI_JOB_NAME}" \ --job-id="${CI_JOB_NAME}" \
--reftest-output-dir="testsuite/reftests/output" \ --reftest-output-dir="testsuite/reftests/output/${backend}" \
--output=report.html \ --output=report-${backend}.html \
meson-logs/testlog.json meson-logs/testlog-${backend}.json
exit $exit_code exit $exit_code

View File

@ -1497,7 +1497,10 @@ gdk_display_remove_seat (GdkDisplay *display,
* *
* Returns the default #GdkSeat for this 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 * GdkSeat *
gdk_display_get_default_seat (GdkDisplay *display) gdk_display_get_default_seat (GdkDisplay *display)

View File

@ -1746,10 +1746,14 @@ gdk_surface_hide (GdkSurface *surface)
/* May need to break grabs on children */ /* May need to break grabs on children */
display = surface->display; display = surface->display;
seat = gdk_display_get_default_seat (display); seat = gdk_display_get_default_seat (display);
if (seat)
devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL); {
devices = g_list_prepend (devices, gdk_seat_get_keyboard (seat)); devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL);
devices = g_list_prepend (devices, gdk_seat_get_pointer (seat)); 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) for (d = devices; d; d = d->next)
{ {

View File

@ -931,10 +931,13 @@ gdk_wayland_display_notify_startup_complete (GdkDisplay *display,
static GdkKeymap * static GdkKeymap *
_gdk_wayland_display_get_keymap (GdkDisplay *display) _gdk_wayland_display_get_keymap (GdkDisplay *display)
{ {
GdkSeat *seat;
GdkDevice *core_keyboard = NULL; GdkDevice *core_keyboard = NULL;
static GdkKeymap *tmp_keymap = 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) if (core_keyboard && tmp_keymap)
{ {

View File

@ -2686,11 +2686,13 @@ gdk_wayland_surface_hide (GdkSurface *surface)
GdkSeat *seat; GdkSeat *seat;
seat = gdk_display_get_default_seat (surface->display); seat = gdk_display_get_default_seat (surface->display);
if (seat)
{
if (surface->autohide)
gdk_seat_ungrab (seat);
if (surface->autohide) gdk_wayland_seat_clear_touchpoints (GDK_WAYLAND_SEAT (seat), surface);
gdk_seat_ungrab (seat); }
gdk_wayland_seat_clear_touchpoints (GDK_WAYLAND_SEAT (seat), surface);
gdk_wayland_surface_hide_surface (surface); gdk_wayland_surface_hide_surface (surface);
_gdk_surface_clear_update_area (surface); _gdk_surface_clear_update_area (surface);
} }
@ -2923,28 +2925,34 @@ gdk_wayland_surface_present_popup (GdkSurface *surface,
{ {
if (surface->autohide) if (surface->autohide)
{ {
GrabPrepareData data; GdkSeat *seat;
GdkGrabStatus result;
data = (GrabPrepareData) { seat = gdk_display_get_default_seat (surface->display);
.width = width, if (seat)
.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)
{ {
const char *grab_status[] = { GrabPrepareData data;
"success", "already grabbed", "invalid time", GdkGrabStatus result;
"not viewable", "frozen", "failed"
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 else

View File

@ -4937,25 +4937,37 @@ gtk_label_get_single_line_mode (GtkLabel *self)
*/ */
static void static void
get_better_cursor (GtkLabel *self, get_better_cursor (GtkLabel *self,
gint index, int index,
gint *x, int *x,
gint *y) int *y)
{ {
GdkSeat *seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self))); GdkSeat *seat;
GdkDevice *device = gdk_seat_get_keyboard (seat); GdkDevice *keyboard;
PangoDirection keymap_direction = gdk_device_get_direction (device); PangoDirection keymap_direction;
PangoDirection cursor_direction = get_cursor_direction (self); PangoDirection cursor_direction;
gboolean split_cursor; gboolean split_cursor;
PangoRectangle strong_pos, weak_pos; 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)), g_object_get (gtk_widget_get_settings (GTK_WIDGET (self)),
"gtk-split-cursor", &split_cursor, "gtk-split-cursor", &split_cursor,
NULL); NULL);
gtk_label_ensure_layout (self); gtk_label_ensure_layout (self);
pango_layout_get_cursor_pos (self->layout, index, pango_layout_get_cursor_pos (self->layout, index,
&strong_pos, &weak_pos); &strong_pos, &weak_pos);
if (split_cursor) if (split_cursor)
{ {
@ -4965,15 +4977,15 @@ get_better_cursor (GtkLabel *self,
else else
{ {
if (keymap_direction == cursor_direction) if (keymap_direction == cursor_direction)
{ {
*x = strong_pos.x / PANGO_SCALE; *x = strong_pos.x / PANGO_SCALE;
*y = strong_pos.y / PANGO_SCALE; *y = strong_pos.y / PANGO_SCALE;
} }
else else
{ {
*x = weak_pos.x / PANGO_SCALE; *x = weak_pos.x / PANGO_SCALE;
*y = weak_pos.y / PANGO_SCALE; *y = weak_pos.y / PANGO_SCALE;
} }
} }
} }
@ -5041,16 +5053,26 @@ gtk_label_move_visually (GtkLabel *self,
NULL); NULL);
if (split_cursor) if (split_cursor)
strong = TRUE; strong = TRUE;
else else
{ {
GdkSeat *seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self))); GdkSeat *seat;
GdkDevice *device = gdk_seat_get_keyboard (seat); GdkDevice *keyboard;
PangoDirection keymap_direction = gdk_device_get_direction (device); 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) if (count > 0)
{ {
pango_layout_move_cursor_visually (self->layout, strong, index, 0, 1, &new_index, &new_trailing); pango_layout_move_cursor_visually (self->layout, strong, index, 0, 1, &new_index, &new_trailing);

View File

@ -167,12 +167,20 @@ gtk_password_entry_realize (GtkWidget *widget)
{ {
GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (widget); GtkPasswordEntry *entry = GTK_PASSWORD_ENTRY (widget);
GtkPasswordEntryPrivate *priv = gtk_password_entry_get_instance_private (entry); GtkPasswordEntryPrivate *priv = gtk_password_entry_get_instance_private (entry);
GdkSeat *seat;
GTK_WIDGET_CLASS (gtk_password_entry_parent_class)->realize (widget); 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))); seat = 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); if (seat)
caps_lock_state_changed (priv->keyboard, NULL, widget); 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 static void
@ -496,7 +504,8 @@ gtk_password_entry_set_show_peek_icon (GtkPasswordEntry *entry,
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]); g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_SHOW_PEEK_ICON]);
} }

View File

@ -1151,6 +1151,7 @@ gtk_render_insertion_cursor (GtkStyleContext *context,
float aspect_ratio; float aspect_ratio;
PangoRectangle strong_pos, weak_pos; PangoRectangle strong_pos, weak_pos;
PangoRectangle *cursor1, *cursor2; PangoRectangle *cursor1, *cursor2;
GdkSeat *seat;
GdkDevice *keyboard; GdkDevice *keyboard;
PangoDirection keyboard_direction; PangoDirection keyboard_direction;
PangoDirection direction2; PangoDirection direction2;
@ -1165,8 +1166,15 @@ gtk_render_insertion_cursor (GtkStyleContext *context,
"gtk-cursor-aspect-ratio", &aspect_ratio, "gtk-cursor-aspect-ratio", &aspect_ratio,
NULL); NULL);
keyboard = gdk_seat_get_keyboard (gdk_display_get_default_seat (priv->display)); seat = gdk_display_get_default_seat (priv->display);
keyboard_direction = gdk_device_get_direction (keyboard); 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); 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; float aspect_ratio;
PangoRectangle strong_pos, weak_pos; PangoRectangle strong_pos, weak_pos;
PangoRectangle *cursor1, *cursor2; PangoRectangle *cursor1, *cursor2;
GdkSeat *seat;
GdkDevice *keyboard; GdkDevice *keyboard;
PangoDirection keyboard_direction; PangoDirection keyboard_direction;
PangoDirection direction2; PangoDirection direction2;
@ -1254,8 +1263,15 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot,
"gtk-cursor-aspect-ratio", &aspect_ratio, "gtk-cursor-aspect-ratio", &aspect_ratio,
NULL); NULL);
keyboard = gdk_seat_get_keyboard (gdk_display_get_default_seat (priv->display)); seat = gdk_display_get_default_seat (priv->display);
keyboard_direction = gdk_device_get_direction (keyboard); 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); pango_layout_get_cursor_pos (layout, index, &strong_pos, &weak_pos);

View File

@ -1920,7 +1920,7 @@ gtk_text_dispose (GObject *object)
GtkText *self = GTK_TEXT (object); GtkText *self = GTK_TEXT (object);
GtkTextPrivate *priv = gtk_text_get_instance_private (self); GtkTextPrivate *priv = gtk_text_get_instance_private (self);
GdkSeat *seat; GdkSeat *seat;
GdkDevice *keyboard; GdkDevice *keyboard = NULL;
GtkWidget *chooser; GtkWidget *chooser;
priv->current_pos = priv->selection_bound = 0; priv->current_pos = priv->selection_bound = 0;
@ -1949,8 +1949,10 @@ gtk_text_dispose (GObject *object)
gtk_widget_unparent (chooser); gtk_widget_unparent (chooser);
seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (object))); seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (object)));
keyboard = gdk_seat_get_keyboard (seat); if (seat)
g_signal_handlers_disconnect_by_func (keyboard, direction_changed, self); 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->selection_bubble, gtk_widget_unparent);
g_clear_pointer (&priv->popup_menu, 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); GtkText *self = GTK_TEXT (widget);
GtkTextPrivate *priv = gtk_text_get_instance_private (self); GtkTextPrivate *priv = gtk_text_get_instance_private (self);
GdkSeat *seat; GdkSeat *seat = NULL;
GdkDevice *keyboard; GdkDevice *keyboard = NULL;
gtk_widget_queue_draw (widget); gtk_widget_queue_draw (widget);
seat = gdk_display_get_default_seat (gtk_widget_get_display (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) if (priv->editable)
{ {
@ -3143,9 +3150,6 @@ gtk_text_focus_in (GtkWidget *widget)
gtk_im_context_focus_in (priv->im_context); 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_reset_blink_time (self);
gtk_text_check_cursor_blink (self); gtk_text_check_cursor_blink (self);
} }
@ -3155,8 +3159,8 @@ gtk_text_focus_out (GtkWidget *widget)
{ {
GtkText *self = GTK_TEXT (widget); GtkText *self = GTK_TEXT (widget);
GtkTextPrivate *priv = gtk_text_get_instance_private (self); GtkTextPrivate *priv = gtk_text_get_instance_private (self);
GdkSeat *seat; GdkSeat *seat = NULL;
GdkDevice *keyboard; GdkDevice *keyboard = NULL;
gtk_text_selection_bubble_popup_unset (self); gtk_text_selection_bubble_popup_unset (self);
@ -3166,7 +3170,10 @@ gtk_text_focus_out (GtkWidget *widget)
gtk_widget_queue_draw (widget); gtk_widget_queue_draw (widget);
seat = gdk_display_get_default_seat (gtk_widget_get_display (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) if (priv->editable)
{ {
@ -3175,8 +3182,6 @@ gtk_text_focus_out (GtkWidget *widget)
} }
gtk_text_check_cursor_blink (self); gtk_text_check_cursor_blink (self);
g_signal_handlers_disconnect_by_func (keyboard, direction_changed, self);
} }
static gboolean static gboolean
@ -3656,15 +3661,21 @@ get_better_cursor_x (GtkText *self,
int offset) int offset)
{ {
GtkTextPrivate *priv = gtk_text_get_instance_private (self); GtkTextPrivate *priv = gtk_text_get_instance_private (self);
GdkSeat *seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (self))); GdkSeat *seat;
GdkDevice *keyboard = gdk_seat_get_keyboard (seat); GdkDevice *keyboard = NULL;
PangoDirection direction = gdk_device_get_direction (keyboard); PangoDirection direction = PANGO_DIRECTION_LTR;
gboolean split_cursor; gboolean split_cursor;
PangoLayout *layout = gtk_text_ensure_layout (self, TRUE); PangoLayout *layout = gtk_text_ensure_layout (self, TRUE);
const char *text = pango_layout_get_text (layout); const char *text = pango_layout_get_text (layout);
int index = g_utf8_offset_to_pointer (text, offset) - text; int index = g_utf8_offset_to_pointer (text, offset) - text;
PangoRectangle strong_pos, weak_pos; 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)), g_object_get (gtk_widget_get_settings (GTK_WIDGET (self)),
"gtk-split-cursor", &split_cursor, "gtk-split-cursor", &split_cursor,
NULL); NULL);
@ -4377,11 +4388,19 @@ gtk_text_create_layout (GtkText *self,
{ {
if (gtk_widget_has_focus (widget)) if (gtk_widget_has_focus (widget))
{ {
GdkDisplay *display = gtk_widget_get_display (widget); GdkDisplay *display;
GdkSeat *seat = gdk_display_get_default_seat (display); GdkSeat *seat;
GdkDevice *keyboard = gdk_seat_get_keyboard (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; pango_dir = PANGO_DIRECTION_RTL;
else else
pango_dir = PANGO_DIRECTION_LTR; pango_dir = PANGO_DIRECTION_LTR;
@ -4941,14 +4960,21 @@ gtk_text_move_visually (GtkText *self,
strong = TRUE; strong = TRUE;
else else
{ {
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (self)); GdkDisplay *display;
GdkSeat *seat = gdk_display_get_default_seat (display); GdkSeat *seat;
GdkDevice *keyboard = gdk_seat_get_keyboard (seat); GdkDevice *keyboard = NULL;
PangoDirection direction = gdk_device_get_direction (keyboard); 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; strong = direction == priv->resolved_dir;
} }
if (count > 0) if (count > 0)
{ {
pango_layout_move_cursor_visually (layout, strong, index, 0, 1, &new_index, &new_trailing); pango_layout_move_cursor_visually (layout, strong, index, 0, 1, &new_index, &new_trailing);

View File

@ -5524,9 +5524,14 @@ gtk_text_view_focus_in (GtkWidget *widget)
} }
seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
keyboard = gdk_seat_get_keyboard (seat); if (seat)
g_signal_connect (keyboard, "notify::direction", keyboard = gdk_seat_get_keyboard (seat);
G_CALLBACK (direction_changed), text_view); 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); gtk_text_view_check_keymap_direction (text_view);
if (priv->editable) 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)); seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
keyboard = gdk_seat_get_keyboard (seat); if (seat)
g_signal_handlers_disconnect_by_func (keyboard, direction_changed, text_view); 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); gtk_text_view_selection_bubble_popup_unset (text_view);
text_view->priv->text_handles_enabled = FALSE; text_view->priv->text_handles_enabled = FALSE;
@ -7492,33 +7501,44 @@ static void
gtk_text_view_check_keymap_direction (GtkTextView *text_view) gtk_text_view_check_keymap_direction (GtkTextView *text_view)
{ {
GtkTextViewPrivate *priv = text_view->priv; 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) if (!priv->layout)
{ return;
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;
g_object_get (settings, seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (text_view)));
"gtk-split-cursor", &split_cursor, if (seat)
NULL); keyboard = gdk_seat_get_keyboard (seat);
else
if (gdk_device_get_direction (keyboard) == PANGO_DIRECTION_RTL) keyboard = NULL;
new_keyboard_dir = GTK_TEXT_DIR_RTL;
else if (keyboard)
new_keyboard_dir = GTK_TEXT_DIR_LTR; direction = gdk_device_get_direction (keyboard);
else
if (split_cursor) direction = PANGO_DIRECTION_LTR;
new_cursor_dir = GTK_TEXT_DIR_NONE;
else g_object_get (settings,
new_cursor_dir = new_keyboard_dir; "gtk-split-cursor", &split_cursor,
NULL);
gtk_text_layout_set_cursor_direction (priv->layout, new_cursor_dir);
gtk_text_layout_set_keyboard_direction (priv->layout, new_keyboard_dir); 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 static void

View File

@ -371,9 +371,10 @@ void
gtk_tooltip_trigger_tooltip_query (GtkWidget *widget) gtk_tooltip_trigger_tooltip_query (GtkWidget *widget)
{ {
GdkDisplay *display; GdkDisplay *display;
double x, y; GdkSeat *seat;
GdkSurface *surface;
GdkDevice *device; GdkDevice *device;
GdkSurface *surface;
double x, y;
GtkWidget *toplevel; GtkWidget *toplevel;
int dx, dy; int dx, dy;
@ -382,8 +383,15 @@ gtk_tooltip_trigger_tooltip_query (GtkWidget *widget)
display = gtk_widget_get_display (widget); display = gtk_widget_get_display (widget);
/* Trigger logic as if the mouse moved */ /* Trigger logic as if the mouse moved */
device = gdk_seat_get_pointer (gdk_display_get_default_seat (display)); seat = gdk_display_get_default_seat (display);
surface = gdk_device_get_surface_at_position (device, &x, &y); 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) if (!surface)
return; return;
@ -673,6 +681,7 @@ gtk_tooltip_show_tooltip (GdkDisplay *display)
gint x, y; gint x, y;
GdkSurface *surface; GdkSurface *surface;
GtkWidget *tooltip_widget; GtkWidget *tooltip_widget;
GdkSeat *seat;
GdkDevice *device; GdkDevice *device;
GtkTooltip *tooltip; GtkTooltip *tooltip;
gboolean return_value = FALSE; gboolean return_value = FALSE;
@ -684,9 +693,17 @@ gtk_tooltip_show_tooltip (GdkDisplay *display)
surface = gtk_native_get_surface (GTK_NATIVE (tooltip->native)); 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); x = round (px);
y = round (py); y = round (py);

View File

@ -7636,13 +7636,17 @@ _gtk_widget_list_devices (GtkWidget *widget,
return NULL; return NULL;
} }
result = g_ptr_array_new ();
seat = gdk_display_get_default_seat (_gtk_widget_get_display (widget)); seat = gdk_display_get_default_seat (_gtk_widget_get_display (widget));
device = gdk_seat_get_pointer (seat); if (!seat)
if (is_my_surface (widget, gdk_device_get_last_event_surface (device)))
{ {
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); devices = gdk_seat_get_slaves (seat, GDK_SEAT_CAPABILITY_ALL_POINTING);
for (l = devices; l; l = l->next) for (l = devices; l; l = l->next)

View File

@ -1578,8 +1578,9 @@ gtk_window_init (GtkWindow *window)
gtk_widget_add_controller (GTK_WIDGET (window), GTK_EVENT_CONTROLLER (target)); gtk_widget_add_controller (GTK_WIDGET (window), GTK_EVENT_CONTROLLER (target));
seat = gdk_display_get_default_seat (gtk_widget_get_display (widget)); seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
g_signal_connect (seat, "device-removed", if (seat)
G_CALLBACK (device_removed_cb), window); g_signal_connect (seat, "device-removed",
G_CALLBACK (device_removed_cb), window);
controller = gtk_event_controller_motion_new (); controller = gtk_event_controller_motion_new ();
gtk_event_controller_set_propagation_phase (controller, gtk_event_controller_set_propagation_phase (controller,
@ -3726,6 +3727,7 @@ gtk_window_finalize (GObject *object)
{ {
GtkWindow *window = GTK_WINDOW (object); GtkWindow *window = GTK_WINDOW (object);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window); GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GdkSeat *seat;
g_clear_pointer (&priv->extra_input_region, cairo_region_destroy); g_clear_pointer (&priv->extra_input_region, cairo_region_destroy);
g_free (priv->title); g_free (priv->title);
@ -3742,9 +3744,9 @@ gtk_window_finalize (GObject *object)
priv->keys_changed_handler = 0; priv->keys_changed_handler = 0;
} }
g_signal_handlers_disconnect_by_func (gdk_display_get_default_seat (priv->display), seat = gdk_display_get_default_seat (priv->display);
device_removed_cb, if (seat)
window); g_signal_handlers_disconnect_by_func (seat, device_removed_cb, window);
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
g_signal_handlers_disconnect_by_func (gtk_settings_get_for_display (priv->display), g_signal_handlers_disconnect_by_func (gtk_settings_get_for_display (priv->display),

View File

@ -229,11 +229,16 @@ void
gtk_inspector_window_select_widget_under_pointer (GtkInspectorWindow *iw) gtk_inspector_window_select_widget_under_pointer (GtkInspectorWindow *iw)
{ {
GdkDisplay *display; GdkDisplay *display;
GdkSeat *seat;
GdkDevice *device; GdkDevice *device;
GtkWidget *widget; GtkWidget *widget;
display = gtk_inspector_window_get_inspected_display (iw); 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); widget = find_widget_at_pointer (device);

View File

@ -54,14 +54,8 @@ foreach t: a11y_state_tests
args: [ '--tap', '-k', ui_path ], args: [ '--tap', '-k', ui_path ],
protocol: 'tap', protocol: 'tap',
env: [ 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_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()),
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
], ],
suite: 'a11y', suite: 'a11y',
) )
@ -89,13 +83,9 @@ foreach t: a11y_tests
args: [ '--tap', '-k', ], args: [ '--tap', '-k', ],
protocol: 'tap', protocol: 'tap',
timeout: 120, timeout: 120,
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'GSETTINGS_BACKEND=memory',
'GTK_CSD=1',
'G_ENABLE_DIAGNOSTIC=0',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), '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()),
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
], ],
suite: 'a11y') suite: 'a11y')
endforeach endforeach

View File

@ -12,11 +12,7 @@ test_change = executable(
test('change', test_change, test('change', test_change,
args: [ '--tap', '-k' ], args: [ '--tap', '-k' ],
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'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_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())
], ],

View File

@ -14,11 +14,7 @@ test_api = executable('api', 'api.c',
test('api', test_api, test('api', test_api,
args: ['--tap', '-k' ], args: ['--tap', '-k' ],
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'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_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())
], ],
@ -33,11 +29,7 @@ test_data = executable('data', ['data.c', '../../gtk/css/gtkcssdataurl.c'],
test('data', test_data, test('data', test_data,
args: ['--tap', '-k' ], args: ['--tap', '-k' ],
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'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_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())
], ],
@ -59,8 +51,7 @@ if false and get_option ('profiler')
'--name', 'performance-adwaita', '--name', 'performance-adwaita',
'--output', join_paths(meson.current_build_dir(), 'output'), '--output', join_paths(meson.current_build_dir(), 'output'),
join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ], join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
env: [ 'GTK_THEME=Adwaita', env: [ 'GTK_THEME=Adwaita' ],
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ],
suite: [ 'css' ]) suite: [ 'css' ])
test('performance-empty', test_performance, test('performance-empty', test_performance,
@ -68,8 +59,7 @@ if false and get_option ('profiler')
'--name', 'performance-empty', '--name', 'performance-empty',
'--output', join_paths(meson.current_build_dir(), 'output'), '--output', join_paths(meson.current_build_dir(), 'output'),
join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ], join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
env: [ 'GTK_THEME=Empty', env: [ 'GTK_THEME=Empty' ],
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ],
suite: [ 'css' ]) suite: [ 'css' ])
endif endif

View File

@ -9,11 +9,7 @@ test_nodes = executable('test-css-nodes', 'test-css-nodes.c',
test('nodes', test_nodes, test('nodes', test_nodes,
args: [ '--tap', '-k' ], args: [ '--tap', '-k' ],
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'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_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())
], ],

View File

@ -463,13 +463,9 @@ foreach testname : test_data
join_paths(meson.current_source_dir(), testname), join_paths(meson.current_source_dir(), testname),
], ],
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'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_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') suite: 'css')
endif endif

View File

@ -19,11 +19,7 @@ test_style = executable(
test('style', test_style, test('style', test_style,
args: [ '--tap', '-k' ], args: [ '--tap', '-k' ],
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'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_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())
], ],

View File

@ -22,11 +22,7 @@ foreach t : tests
test(t, test_exe, test(t, test_exe,
args: [ '--tap', '-k' ], args: [ '--tap', '-k' ],
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'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_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())
], ],

View File

@ -10,11 +10,12 @@ test_list_seats (void)
display = gdk_display_get_default (); display = gdk_display_get_default ();
seat0 = gdk_display_get_default_seat (display); seat0 = gdk_display_get_default_seat (display);
if (seat0 != NULL)
g_assert_true (GDK_IS_SEAT (seat0)); g_assert_true (GDK_IS_SEAT (seat0));
found_default = FALSE; found_default = FALSE;
list = gdk_display_list_seats (display); list = gdk_display_list_seats (display);
for (l = list; l; l = l->next) for (l = list; l; l = l->next)
{ {
seat = l->data; seat = l->data;
@ -25,9 +26,13 @@ test_list_seats (void)
if (seat == seat0) if (seat == seat0)
found_default = TRUE; 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 static void
@ -42,6 +47,12 @@ test_default_seat (void)
display = gdk_display_get_default (); display = gdk_display_get_default ();
seat0 = gdk_display_get_default_seat (display); 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)); g_assert_true (GDK_IS_SEAT (seat0));
caps = gdk_seat_get_capabilities (seat0); caps = gdk_seat_get_capabilities (seat0);

View File

@ -19,6 +19,16 @@ get_output_dir (void)
if (arg_output_dir) if (arg_output_dir)
{ {
GFile *file = g_file_new_for_commandline_arg (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); output_dir = g_file_get_path (file);
g_object_unref (file); g_object_unref (file);
} }

View File

@ -90,14 +90,10 @@ foreach renderer : renderers
args: ['--output', join_paths(meson.current_build_dir(), 'compare', renderer[0]), 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 + '.node'),
join_paths(meson.current_source_dir(), 'compare', test + '.png')], join_paths(meson.current_source_dir(), 'compare', test + '.png')],
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'GSETTINGS_BACKEND=memory', 'GSK_RENDERER=' + renderer[0],
'GDK_DEBUG=default-settings',
'GTK_CSD=1',
'G_ENABLE_DIAGNOSTIC=0',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), '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())
'GSK_RENDERER=' + renderer[0]
], ],
suite: [ 'gsk', 'gsk-compare', 'gsk-' + renderer[0], 'gsk-compare-' + renderer[0] ]) suite: [ 'gsk', 'gsk-compare', 'gsk-' + renderer[0], 'gsk-compare-' + renderer[0] ])
endif endif
@ -171,14 +167,10 @@ foreach test : node_parser_tests
test('parser ' + test, node_parser, test('parser ' + test, node_parser,
args: [ join_paths(meson.current_source_dir(), 'nodeparser', test) args: [ join_paths(meson.current_source_dir(), 'nodeparser', test)
], ],
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'GSETTINGS_BACKEND=memory', 'GSK_RENDERER=opengl',
'GDK_DEBUG=default-settings',
'GTK_CSD=1',
'G_ENABLE_DIAGNOSTIC=0',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), '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())
'GSK_RENDERER=opengl'
], ],
suite: 'gsk') suite: 'gsk')
endif endif
@ -207,15 +199,10 @@ foreach t : tests
test(test_name, test_exe, test(test_name, test_exe,
args: [ '--tap', '-k' ], args: [ '--tap', '-k' ],
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',
'GTK_CSD=1',
'G_ENABLE_DIAGNOSTIC=0',
'GSK_RENDERER=cairo', 'GSK_RENDERER=cairo',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), '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())
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
], ],
suite: 'gsk') suite: 'gsk')
endforeach endforeach

View File

@ -19,7 +19,7 @@ main (int argc, char **argv)
display = gdk_display_open (display_name); display = gdk_display_open (display_name);
if (!display) if (!display)
return 1; return 0;
gdk_display_manager_set_default_display (gdk_display_manager_get (), display); 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"); but = gtk_button_new_with_label ("Try to Exit");
g_signal_connect_swapped (but, "clicked", 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_window_set_child (GTK_WINDOW (win), but);
gtk_widget_show (win); gtk_widget_show (win);

View File

@ -111,16 +111,11 @@ foreach t : tests
test(test_name, test_exe, test(test_name, test_exe,
args: [ '--tap', '-k' ], args: [ '--tap', '-k' ],
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',
'GTK_CSD=1',
'G_ENABLE_DIAGNOSTIC=0',
'NO_AT_BRIDGE=1', 'NO_AT_BRIDGE=1',
'GSK_RENDERER=cairo', 'GSK_RENDERER=cairo',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), '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()),
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
], ],
suite: 'gtk', suite: 'gtk',
should_fail: expect_fail, should_fail: expect_fail,
@ -138,14 +133,9 @@ if add_languages('cpp', required: false)
test('c++ keywords', test_exe, test('c++ keywords', test_exe,
args: [ '--tap', '-k' ], args: [ '--tap', '-k' ],
#protocol: 'tap', #protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'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_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()),
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
], ],
suite: 'gtk') suite: 'gtk')
if get_option('install-tests') if get_option('install-tests')
@ -192,12 +182,7 @@ foreach test : focus_chain_tests
test(test[0] + ' ' + test[1], focus_chain, test(test[0] + ' ' + test[1], focus_chain,
args: [ join_paths(meson.current_source_dir(), 'focus-chain', test[0] + '.ui'), args: [ join_paths(meson.current_source_dir(), 'focus-chain', test[0] + '.ui'),
join_paths(meson.current_source_dir(), 'focus-chain', test[0] + '.' + test[1]) ], join_paths(meson.current_source_dir(), 'focus-chain', test[0] + '.' + test[1]) ],
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'GSETTINGS_BACKEND=memory',
'GDK_DEBUG=default-settings',
'GTK_CSD=1',
'G_ENABLE_DIAGNOSTIC=0',
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), '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())
], ],
@ -226,14 +211,12 @@ if false and get_option ('profiler')
test('performance-layout', test_performance, test('performance-layout', test_performance,
args: [ '--mark', 'size allocation', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ], args: [ '--mark', 'size allocation', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
env: [ 'GTK_THEME=Empty', env: [ 'GTK_THEME=Empty' ],
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ],
suite: [ 'gtk' ]) suite: [ 'gtk' ])
test('performance-snapshot', test_performance, test('performance-snapshot', test_performance,
args: [ '--mark', 'widget snapshot', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ], args: [ '--mark', 'widget snapshot', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
env: [ 'GTK_THEME=Empty', env: [ 'GTK_THEME=Empty' ],
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ],
suite: [ 'gtk' ]) suite: [ 'gtk' ])
endif endif

View File

@ -289,6 +289,7 @@ test_trigger_trigger (void)
{ {
GtkShortcutTrigger *trigger[4]; GtkShortcutTrigger *trigger[4];
GdkDisplay *display; GdkDisplay *display;
GdkSeat *seat;
GdkSurface *surface; GdkSurface *surface;
GdkDevice *device; GdkDevice *device;
GdkEvent *event; GdkEvent *event;
@ -307,14 +308,21 @@ test_trigger_trigger (void)
}; };
int i, j; 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[0] = g_object_ref (gtk_never_trigger_get ());
trigger[1] = gtk_keyval_trigger_new (GDK_KEY_a, GDK_CONTROL_MASK); trigger[1] = gtk_keyval_trigger_new (GDK_KEY_a, GDK_CONTROL_MASK);
trigger[2] = gtk_mnemonic_trigger_new (GDK_KEY_u); trigger[2] = gtk_mnemonic_trigger_new (GDK_KEY_u);
trigger[3] = gtk_alternative_trigger_new (g_object_ref (trigger[1]), trigger[3] = gtk_alternative_trigger_new (g_object_ref (trigger[1]),
g_object_ref (trigger[2])); g_object_ref (trigger[2]));
display = gdk_display_get_default (); device = gdk_seat_get_keyboard (seat);
device = gdk_seat_get_keyboard (gdk_display_get_default_seat (display));
surface = gdk_surface_new_toplevel (display, 100, 100); surface = gdk_surface_new_toplevel (display, 100, 100);
for (i = 0; i < G_N_ELEMENTS (tests); i++) for (i = 0; i < G_N_ELEMENTS (tests); i++)

View File

@ -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 # otherwise we're going to have failures down the line
diff = find_program('diff', required: true) 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('performance')
subdir('gdk') subdir('gdk')
subdir('gsk') subdir('gsk')

View File

@ -89,8 +89,18 @@ main (int argc, char *argv[])
{ {
GError *err = NULL; GError *err = NULL;
GFile *file; GFile *file;
const char *subdir;
file = g_file_new_for_commandline_arg (opt_output); 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_file_make_directory_with_parents (file, NULL, &err))
{ {
if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_EXISTS)) 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)) if (!g_subprocess_get_successful (subprocess))
g_error ("Child process failed"); g_error ("Child process failed");
g_object_unref (subprocess); g_object_unref (subprocess);
g_object_unref (launcher); g_object_unref (launcher);

View File

@ -109,8 +109,18 @@ get_output_dir (GError **error)
{ {
GError *err = NULL; GError *err = NULL;
GFile *file; GFile *file;
const char *subdir;
file = g_file_new_for_commandline_arg (arg_output_dir); 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_file_make_directory_with_parents (file, NULL, &err))
{ {
if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_EXISTS)) if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_EXISTS))

View File

@ -438,16 +438,11 @@ foreach testname : testdata
join_paths(meson.current_source_dir(), testname), join_paths(meson.current_source_dir(), testname),
], ],
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'GSETTINGS_BACKEND=memory', 'GSK_RENDERER=opengl',
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
'GTK_CSD=1',
'GDK_DEBUG=default-settings',
'G_ENABLE_DIAGNOSTIC=0',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), '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()),
'GSK_RENDERER=opengl', 'REFTEST_MODULE_DIR=@0@'.format(meson.current_build_dir())
'REFTEST_MODULE_DIR=@0@'.format(meson.current_build_dir()),
], ],
suite: 'reftest', suite: 'reftest',
should_fail: xfails.contains(testname)) should_fail: xfails.contains(testname))

View File

@ -20,11 +20,7 @@ if bash.found()
args: t, args: t,
workdir: meson.current_build_dir(), workdir: meson.current_build_dir(),
protocol: 'tap', protocol: 'tap',
env: [ 'GIO_USE_VOLUME_MONITOR=unix', env: [
'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_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()),
'GTK_BUILDER_TOOL=@0@'.format(get_variable('gtk4_builder_tool').full_path()), 'GTK_BUILDER_TOOL=@0@'.format(get_variable('gtk4_builder_tool').full_path()),