diff options
Diffstat (limited to 'src/platform/freedesktop/dbus.c')
| -rw-r--r-- | src/platform/freedesktop/dbus.c | 21 |
1 files changed, 21 insertions, 0 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; +} |
