summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-13 17:08:48 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-13 17:08:48 +0300
commitac6f9f5e7711521455b83ceb843a25e091646d43 (patch)
tree0dfd5fc46a605cd4980ef3c9131ddbaa2270c78a /src/common
parentd4d13e616cb15ef22479d9cb97922af93317a01a (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'src/common')
-rw-r--r--src/common/backend.c7
-rw-r--r--src/common/backend.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/src/common/backend.c b/src/common/backend.c
index d35d243..b15233f 100644
--- a/src/common/backend.c
+++ b/src/common/backend.c
@@ -110,6 +110,13 @@ int yasl_display_modifiers(const struct yasl_display *d)
return d->ops->display_modifiers(d);
}
+int yasl_display_double_click_ms(const struct yasl_display *d)
+{
+ int ms = d && d->ops->display_double_click_ms ? d->ops->display_double_click_ms(d) : 0;
+ /* Reject nonsense from misconfigured settings as well as no answer. */
+ return ms > 0 && ms <= 10000 ? ms : YASL_DOUBLE_CLICK_MS_DEFAULT;
+}
+
void yasl_display_copy(struct yasl_display *d, enum yasl_selection sel, const char *text)
{
if (!d || !d->ops->display_copy || !text ||
diff --git a/src/common/backend.h b/src/common/backend.h
index fd60418..96ce9e7 100644
--- a/src/common/backend.h
+++ b/src/common/backend.h
@@ -57,6 +57,8 @@ struct yasl_backend_ops {
int (*display_dispatch_timeout)(struct yasl_display *d, int timeout_ms);
void (*display_flush)(struct yasl_display *d);
int (*display_modifiers)(const struct yasl_display *d);
+ /* Optional; returns zero or less when the system reports no interval. */
+ int (*display_double_click_ms)(const struct yasl_display *d);
void (*display_copy)(struct yasl_display *d, enum yasl_selection sel, const char *text);
void (*display_paste)(struct yasl_display *d, enum yasl_selection sel, struct yasl_surface *target);
bool (*display_drag_start)(struct yasl_display *d, struct yasl_surface *origin, const struct yasl_drag_image *image, const struct yasl_drag_listener *l, void *ud);