From ac6f9f5e7711521455b83ceb843a25e091646d43 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 17:08:48 +0300 Subject: Report the system double-click interval wsap_term hardcodes 400 ms in three places to count clicks. yasl_display_double_click_ms() reads the interval from the system. X11 parses Net/DoubleClickTime from the XSETTINGS owner's property. Wayland has no protocol for it, so it asks the Settings portal for KDE's DoubleClickInterval, which KDE sends as a string and which exists only when the user set it, then GNOME's double-click. X11 without XSETTINGS asks the portal too. Cocoa reads NSEvent.doubleClickInterval. Missing or implausible values give YASL_DOUBLE_CLICK_MS_DEFAULT, 400 ms. The X11 state test covers the XSETTINGS parser in both byte orders and with truncation. The Xwayland test owns the settings selection. The desktop test serves both portal keys. The Cocoa path is not built or run here. Co-Authored-By: Claude Opus 5.5 --- tests/x11/test_input.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests/x11/test_input.c') diff --git a/tests/x11/test_input.c b/tests/x11/test_input.c index bbcbf45..95943d1 100644 --- a/tests/x11/test_input.c +++ b/tests/x11/test_input.c @@ -65,6 +65,37 @@ static void check_selection_encoding(struct x11_display *d, struct x11_surface * } } +/* Own the XSETTINGS selection with one Net/DoubleClickTime value. */ +static void check_double_click(struct x11_display *d) +{ + /* No settings owner and no portal: the default applies. */ + unsetenv("DBUS_SESSION_BUS_ADDRESS"); + unsetenv("XDG_RUNTIME_DIR"); + assert(yasl_display_double_click_ms(&d->base) == YASL_DOUBLE_CLICK_MS_DEFAULT); + + char name[32]; + snprintf(name, sizeof(name), "_XSETTINGS_S%d", d->screen); + Atom selection = XInternAtom(d->native, name, False); + Atom property = XInternAtom(d->native, "_XSETTINGS_SETTINGS", False); + Window owner = XCreateSimpleWindow(d->native, DefaultRootWindow(d->native), + 0, 0, 1, 1, 0, 0, 0); + XSetSelectionOwner(d->native, selection, owner, CurrentTime); + static const unsigned char blob[] = { + LSBFirst, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 19, 0, 'N', 'e', 't', '/', 'D', 'o', 'u', 'b', 'l', 'e', + 'C', 'l', 'i', 'c', 'k', 'T', 'i', 'm', 'e', 0, 0, 0, 0, 0, + 250, 0, 0, 0, + }; + XChangeProperty(d->native, owner, property, property, 8, PropModeReplace, + blob, sizeof(blob)); + XSync(d->native, False); + assert(yasl_display_double_click_ms(&d->base) == 250); + + XDestroyWindow(d->native, owner); + XSync(d->native, False); + assert(yasl_display_double_click_ms(&d->base) == YASL_DOUBLE_CLICK_MS_DEFAULT); +} + int main(void) { struct yasl_display_spec ds = {.backend = YASL_BACKEND_X11}; @@ -117,6 +148,7 @@ int main(void) XFree(saved); s->ic = saved_ic; check_selection_encoding(d, s); + check_double_click(d); /* Test CSD interactive actions, window menu, and IME caret */ assert(yasl_display_caps(base) & YASL_CAP_CSD); -- cgit v1.2.3