mirror of
https://github.com/labwc/labwc.git
synced 2026-03-11 05:33:49 -04:00
Implemented <doubleClickTime> in rc.xml
This commit is contained in:
parent
a4fdb43d42
commit
36f5b49f2a
4 changed files with 47 additions and 6 deletions
|
|
@ -72,6 +72,8 @@
|
||||||
</keyboard>
|
</keyboard>
|
||||||
|
|
||||||
<mouse>
|
<mouse>
|
||||||
|
<!-- time is in ms -->
|
||||||
|
<doubleClickTime>200</doubleClickTime>
|
||||||
<context name="TitleBar">
|
<context name="TitleBar">
|
||||||
<mousebind button="Left" action="DoubleClick">
|
<mousebind button="Left" action="DoubleClick">
|
||||||
<action name="ToggleMaximize"/>
|
<action name="ToggleMaximize"/>
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ struct rcxml {
|
||||||
int font_size_menuitem;
|
int font_size_menuitem;
|
||||||
struct wl_list keybinds;
|
struct wl_list keybinds;
|
||||||
struct wl_list mousebinds;
|
struct wl_list mousebinds;
|
||||||
|
long doubleclick_time; /* in ms */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct rcxml rc;
|
extern struct rcxml rc;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
|
|
@ -374,6 +375,39 @@ traverse_context(xmlNode* node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
traverse_doubleclick_time(xmlNode* node)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* this node
|
||||||
|
* |
|
||||||
|
* |
|
||||||
|
* v
|
||||||
|
* <doubleClickTime>200</doubleClickTime>
|
||||||
|
*/
|
||||||
|
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
|
static void
|
||||||
traverse_mouse(xmlNode* node)
|
traverse_mouse(xmlNode* node)
|
||||||
{
|
{
|
||||||
|
|
@ -385,16 +419,19 @@ traverse_mouse(xmlNode* node)
|
||||||
* |
|
* |
|
||||||
* v
|
* v
|
||||||
* <mouse>
|
* <mouse>
|
||||||
* <context name="TitleBar"> -|
|
* <doubleClickTime>200</doubleClickTime> ]
|
||||||
* <mousebind....> |
|
* <context name="TitleBar"> -|
|
||||||
* ... | -- This node's only supported child is context
|
* <mousebind....> |
|
||||||
* </mousebind> |
|
* ... | -- This node's only supported children
|
||||||
* </context> -|
|
* </mousebind> | are doubleClickTime and context
|
||||||
|
* </context> -|
|
||||||
* </mouse>
|
* </mouse>
|
||||||
*/
|
*/
|
||||||
for(xmlNode* n = node->children; n && n->name; n = n->next) {
|
for(xmlNode* n = node->children; n && n->name; n = n->next) {
|
||||||
if(strcasecmp((const char*)n->name, "context") == 0) {
|
if(strcasecmp((const char*)n->name, "context") == 0) {
|
||||||
traverse_context(n);
|
traverse_context(n);
|
||||||
|
} else if(strcasecmp((const char*)n->name, "doubleClickTime") == 0) {
|
||||||
|
traverse_doubleclick_time(n);
|
||||||
} else if(is_ignorable_node(n)) {
|
} else if(is_ignorable_node(n)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -454,6 +491,7 @@ rcxml_init()
|
||||||
rc.corner_radius = 8;
|
rc.corner_radius = 8;
|
||||||
rc.font_size_activewindow = 10;
|
rc.font_size_activewindow = 10;
|
||||||
rc.font_size_menuitem = 10;
|
rc.font_size_menuitem = 10;
|
||||||
|
rc.doubleclick_time = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,7 @@ cursor_button(struct wl_listener *listener, void *data)
|
||||||
desktop_focus_view(&server->seat, view);
|
desktop_focus_view(&server->seat, view);
|
||||||
damage_all_outputs(server);
|
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;
|
struct mousebind* mousebind;
|
||||||
wl_list_for_each_reverse(mousebind, &rc.mousebinds, link) {
|
wl_list_for_each_reverse(mousebind, &rc.mousebinds, link) {
|
||||||
if( (mousebind->context == MOUSE_CONTEXT_TITLEBAR) &&
|
if( (mousebind->context == MOUSE_CONTEXT_TITLEBAR) &&
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue