From 7e8bf8d2a81f37303e0c9ae430f1acbff106da22 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Wed, 14 Oct 2026 14:16:42 +0300 Subject: Wayland: fix GL thread races, reconnect ordering and sizing bugs - GL swaps on a rendering thread no longer touch frame callbacks or presentation feedback. They set a per-surface flag and wake the loop; the owner thread arms both at its next flush and commits, so the frame callback fires without waiting for the application's next swap. - Clear the offline flag only after the reconnect rebuild succeeds, and not when the connection was lost again during it. - make_current fails with ENOTCONN for a window without a context. Detaching is a no-op when nothing is current or the EGL display is gone. - Window move, resize, window menu and drag start need a pointer button or tablet tip that is still held; otherwise they fail with ESTALE and use that press's serial. Popups fail with ESTALE without an input serial and with ENOTCONN while the display is lost. - An oversized device size shrinks to the buffer limits, keeping the aspect ratio, instead of closing the window. - FIXED_SIZE windows pin xdg min and max on every set_size. The 64px minimum applies only to compositor-suggested sizes, not to application sizes. - The keyboard-enter serial becomes the input serial. Clipboard copy with no keyboard focus fails with ESTALE. - Relative-pointer windows relock after a reconnect rebuild. - errno: EBUSY for an active drag, ENOTSUP for place_under_pointer and for GL without EGL, EINVAL for drag carry without a drag. - Default window title and app ID are "YASL". - Pointer motion and button events carry unrounded device-pixel positions in precise_x/precise_y with precise_position set. Co-Authored-By: Claude Haiku 5.5 --- src/platform/wayland/keyboard.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/platform/wayland/keyboard.c') diff --git a/src/platform/wayland/keyboard.c b/src/platform/wayland/keyboard.c index 9637341..cf6d56c 100644 --- a/src/platform/wayland/keyboard.c +++ b/src/platform/wayland/keyboard.c @@ -144,7 +144,7 @@ static void push_focus(struct wayland_surface *w, bool focused) static void keyboard_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys) { - (void)keyboard; (void)serial; (void)keys; + (void)keyboard; (void)keys; struct seat *s = data; struct wayland_surface *w = surface_root(surface ? (struct wayland_surface *)wl_surface_get_user_data(surface) : NULL); @@ -155,6 +155,8 @@ static void keyboard_enter(void *data, struct wl_keyboard *keyboard, s->keyboard_focus = NULL; return; } + /* The enter serial is a valid input serial, e.g. for set_selection. */ + seat_note_input(s, serial); bool focused = conn_keyboard_on(s->conn, w, s); s->keyboard_focus = w; keyboard_reset_keys(s, w); @@ -433,12 +435,12 @@ bool wayland_display_copy_text(struct wayland_display *c, enum yasl_private_sele errno = EINVAL; return false; } - if (!s || !s->clipboard) { - errno = ENOTSUP; + if (!s || !s->keyboard_focus || !s->input_serial) { + errno = ESTALE; return false; } - if (!s->input_serial) { - errno = EAGAIN; + if (!s->clipboard) { + errno = ENOTSUP; return false; } errno = 0; -- cgit v1.2.3