summaryrefslogtreecommitdiff
path: root/src/platform/freedesktop
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/freedesktop')
-rw-r--r--src/platform/freedesktop/dbus.c21
-rw-r--r--src/platform/freedesktop/dbus.h5
2 files changed, 25 insertions, 1 deletions
diff --git a/src/platform/freedesktop/dbus.c b/src/platform/freedesktop/dbus.c
index abca900..484b987 100644
--- a/src/platform/freedesktop/dbus.c
+++ b/src/platform/freedesktop/dbus.c
@@ -4,6 +4,7 @@
#if YASL_HAS_DBUS
#include <dbus/dbus.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -116,6 +117,15 @@ static bool iter_int(DBusMessageIter *it, int64_t *out)
}
DBusBasicValue v;
switch (dbus_message_iter_get_arg_type(it)) {
+ case DBUS_TYPE_STRING: {
+ dbus_message_iter_get_basic(it, &v);
+ char *end;
+ errno = 0;
+ long long n = strtoll(v.str, &end, 10);
+ if (errno || end == v.str || *end) return false;
+ *out = n;
+ return true;
+ }
case DBUS_TYPE_BYTE: dbus_message_iter_get_basic(it, &v); *out = v.byt; return true;
case DBUS_TYPE_BOOLEAN: dbus_message_iter_get_basic(it, &v); *out = v.bool_val; return true;
case DBUS_TYPE_INT16: dbus_message_iter_get_basic(it, &v); *out = v.i16; return true;
@@ -185,3 +195,14 @@ bool portal_read_int(const char *ns, const char *key, int64_t *out)
}
#endif
+
+int portal_double_click_ms(void)
+{
+ /* kdeglobals holds only values the user changed, so a KDE answer is
+ * deliberate; the GNOME key can be a default from another portal backend. */
+ int64_t ms;
+ if (portal_read_int("org.kde.kdeglobals.KDE", "DoubleClickInterval", &ms) ||
+ portal_read_int("org.gnome.desktop.peripherals.mouse", "double-click", &ms))
+ return ms > 0 && ms <= INT32_MAX ? (int)ms : 0;
+ return 0;
+}
diff --git a/src/platform/freedesktop/dbus.h b/src/platform/freedesktop/dbus.h
index 3b1662b..fd0aeb1 100644
--- a/src/platform/freedesktop/dbus.h
+++ b/src/platform/freedesktop/dbus.h
@@ -10,7 +10,10 @@
/* Send org.freedesktop.Notifications.Notify without waiting for a reply. */
bool bus_notify(const char *app, const char *title, const char *body);
-/* Read an integer setting through the XDG Settings portal, waiting briefly. */
+/* Read an integer setting through the XDG Settings portal, waiting briefly.
+ * A string holding a decimal integer also counts, as KDE reports them. */
bool portal_read_int(const char *ns, const char *key, int64_t *out);
+/* The KDE or GNOME double-click interval from the portal, or zero. */
+int portal_double_click_ms(void);
#endif