From: alex Date: Sun, 29 Aug 2021 22:31:57 +0000 (-0400) Subject: Implemented in rc.xml X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=36f5b49f2a3ab8c263bb4b7baeb416523c25d37c;p=proto%2Flabwc.git Implemented in rc.xml --- diff --git a/docs/rc.xml.all b/docs/rc.xml.all index 80eeae05..8fa7e167 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -72,6 +72,8 @@ + + 200 diff --git a/include/config/rcxml.h b/include/config/rcxml.h index e2c60e35..72bea661 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -20,6 +20,7 @@ struct rcxml { int font_size_menuitem; struct wl_list keybinds; struct wl_list mousebinds; + long doubleclick_time; /* in ms */ }; extern struct rcxml rc; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index d13db7c0..9e6d0298 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -1,6 +1,7 @@ #define _POSIX_C_SOURCE 200809L #include #include +#include #include #include #include @@ -374,6 +375,39 @@ traverse_context(xmlNode* node) } } +static void +traverse_doubleclick_time(xmlNode* node) +{ + /* + * this node + * | + * | + * v + * 200 + */ + for(xmlNode* n = node->children; n && n->name; n = n->next) { + if(n->type == XML_TEXT_NODE) { + long doubleclick_time_parsed = strtol((const char*)n->content, NULL, 10); + + /* + * There are 2 possible sources for a bad doubleclicktime value: + * - user gave a value of 0 (which doesn't make sense) + * - user gave a negative value (which doesn't make sense) + * - user gave a value which strtol couldn't parse + * + * since strtol() returns 0 on error, all we have to do is check + * for to see if strtol() returned 0 or less to handle the error + * cases. in case of error, we just choose not to override the + * default value and everything should be fine + */ + bool valid_doubleclick_time = doubleclick_time_parsed > 0; + if(valid_doubleclick_time) { + rc.doubleclick_time = doubleclick_time_parsed; + } + } + } +} + static void traverse_mouse(xmlNode* node) { @@ -385,16 +419,19 @@ traverse_mouse(xmlNode* node) * | * v * - * -| - * | - * ... | -- This node's only supported child is context - * | - * -| + * 200 ] + * -| + * | + * ... | -- This node's only supported children + * | are doubleClickTime and context + * -| * */ for(xmlNode* n = node->children; n && n->name; n = n->next) { if(strcasecmp((const char*)n->name, "context") == 0) { traverse_context(n); + } else if(strcasecmp((const char*)n->name, "doubleClickTime") == 0) { + traverse_doubleclick_time(n); } else if(is_ignorable_node(n)) { continue; } else { @@ -454,6 +491,7 @@ rcxml_init() rc.corner_radius = 8; rc.font_size_activewindow = 10; rc.font_size_menuitem = 10; + rc.doubleclick_time = 500; } static void diff --git a/src/cursor.c b/src/cursor.c index 5770f542..9801dd41 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -343,7 +343,7 @@ cursor_button(struct wl_listener *listener, void *data) desktop_focus_view(&server->seat, view); damage_all_outputs(server); - if (is_double_click(500) && view_area == LAB_SSD_PART_TITLEBAR) { + if (is_double_click(rc.doubleclick_time) && view_area == LAB_SSD_PART_TITLEBAR) { struct mousebind* mousebind; wl_list_for_each_reverse(mousebind, &rc.mousebinds, link) { if( (mousebind->context == MOUSE_CONTEXT_TITLEBAR) &&