mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
More robust rc.xml parsing
This commit is contained in:
parent
dc203a28e9
commit
2b82bdcdb7
2 changed files with 44 additions and 16 deletions
|
|
@ -52,19 +52,25 @@ fill_keybind(char *nodename, char *content)
|
||||||
string_truncate_at_pattern(nodename, ".keybind.keyboard");
|
string_truncate_at_pattern(nodename, ".keybind.keyboard");
|
||||||
if (!strcmp(nodename, "key")) {
|
if (!strcmp(nodename, "key")) {
|
||||||
current_keybind = keybind_create(content);
|
current_keybind = keybind_create(content);
|
||||||
}
|
current_keybind_action = NULL;
|
||||||
/*
|
/*
|
||||||
* We expect <keybind key=""> to come first
|
* If an invalid keybind has been provided,
|
||||||
* If a invalid keybind has been provided, keybind_create() complains
|
* keybind_create() complains.
|
||||||
* so we just silently ignore it here.
|
*/
|
||||||
*/
|
if (!current_keybind) {
|
||||||
if (!current_keybind) {
|
wlr_log(WLR_ERROR, "Invalid keybind: %s", content);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!strcmp(nodename, "name.action")) {
|
} else if (!current_keybind) {
|
||||||
|
wlr_log(WLR_ERROR, "expect <keybind key=\"\"> element first. "
|
||||||
|
"nodename: '%s' content: '%s'", nodename, content);
|
||||||
|
} else if (!strcmp(nodename, "name.action")) {
|
||||||
current_keybind_action = action_create(content);
|
current_keybind_action = action_create(content);
|
||||||
wl_list_insert(current_keybind->actions.prev,
|
wl_list_insert(current_keybind->actions.prev,
|
||||||
¤t_keybind_action->link);
|
¤t_keybind_action->link);
|
||||||
|
} else if (!current_keybind_action) {
|
||||||
|
wlr_log(WLR_ERROR, "expect <action name=\"\"> element first. "
|
||||||
|
"nodename: '%s' content: '%s'", nodename, content);
|
||||||
} else if (!strcmp(nodename, "command.action")) {
|
} else if (!strcmp(nodename, "command.action")) {
|
||||||
current_keybind_action->arg = strdup(content);
|
current_keybind_action->arg = strdup(content);
|
||||||
} else if (!strcmp(nodename, "direction.action")) {
|
} else if (!strcmp(nodename, "direction.action")) {
|
||||||
|
|
@ -86,27 +92,39 @@ fill_mousebind(char *nodename, char *content)
|
||||||
* </mousebind>
|
* </mousebind>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!strcmp(nodename, "mousebind.context.mouse")) {
|
if (!current_mouse_context) {
|
||||||
|
wlr_log(WLR_ERROR, "expect <context name=\"\"> element first. "
|
||||||
|
"nodename: '%s' content: '%s'", nodename, content);
|
||||||
|
return;
|
||||||
|
} else if (!strcmp(nodename, "mousebind.context.mouse")) {
|
||||||
wlr_log(WLR_INFO, "create mousebind for %s",
|
wlr_log(WLR_INFO, "create mousebind for %s",
|
||||||
current_mouse_context);
|
current_mouse_context);
|
||||||
current_mousebind = mousebind_create(current_mouse_context);
|
current_mousebind = mousebind_create(current_mouse_context);
|
||||||
}
|
current_mousebind_action = NULL;
|
||||||
if (!content) {
|
return;
|
||||||
|
} else if (!content) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string_truncate_at_pattern(nodename, ".mousebind.context.mouse");
|
|
||||||
|
|
||||||
if (!strcmp(nodename, "button")) {
|
string_truncate_at_pattern(nodename, ".mousebind.context.mouse");
|
||||||
|
if (!current_mousebind) {
|
||||||
|
wlr_log(WLR_ERROR,
|
||||||
|
"expect <mousebind button=\"\" action=\"\"> element first. "
|
||||||
|
"nodename: '%s' content: '%s'", nodename, content);
|
||||||
|
} else if (!strcmp(nodename, "button")) {
|
||||||
current_mousebind->button = mousebind_button_from_str(content,
|
current_mousebind->button = mousebind_button_from_str(content,
|
||||||
¤t_mousebind->modifiers);
|
¤t_mousebind->modifiers);
|
||||||
} else if (!strcmp(nodename, "action")) {
|
} else if (!strcmp(nodename, "action")) {
|
||||||
/* <mousebind button="" action="EVENT"> */
|
/* <mousebind button="" action="EVENT"> */
|
||||||
current_mousebind->mouse_event =
|
current_mousebind->mouse_event =
|
||||||
mousebind_event_from_str(content);
|
mousebind_event_from_str(content);
|
||||||
} else if (!strcmp(nodename, "name.action")) {
|
} else if (!strcmp(nodename, "name.action")) {
|
||||||
current_mousebind_action = action_create(content);
|
current_mousebind_action = action_create(content);
|
||||||
wl_list_insert(current_mousebind->actions.prev,
|
wl_list_insert(current_mousebind->actions.prev,
|
||||||
¤t_mousebind_action->link);
|
¤t_mousebind_action->link);
|
||||||
|
} else if (!current_mousebind_action) {
|
||||||
|
wlr_log(WLR_ERROR, "expect <action name=\"\"> element first. "
|
||||||
|
"nodename: '%s' content: '%s'", nodename, content);
|
||||||
} else if (!strcmp(nodename, "command.action")) {
|
} else if (!strcmp(nodename, "command.action")) {
|
||||||
current_mousebind_action->arg = strdup(content);
|
current_mousebind_action->arg = strdup(content);
|
||||||
} else if (!strcmp(nodename, "direction.action")) {
|
} else if (!strcmp(nodename, "direction.action")) {
|
||||||
|
|
@ -349,6 +367,7 @@ entry(xmlNode *node, char *nodename, char *content)
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(nodename, "name.context.mouse")) {
|
} else if (!strcasecmp(nodename, "name.context.mouse")) {
|
||||||
current_mouse_context = content;
|
current_mouse_context = content;
|
||||||
|
current_mousebind = NULL;
|
||||||
} else if (!strcasecmp(nodename, "repeatRate.keyboard")) {
|
} else if (!strcasecmp(nodename, "repeatRate.keyboard")) {
|
||||||
rc.repeat_rate = atoi(content);
|
rc.repeat_rate = atoi(content);
|
||||||
} else if (!strcasecmp(nodename, "repeatDelay.keyboard")) {
|
} else if (!strcasecmp(nodename, "repeatDelay.keyboard")) {
|
||||||
|
|
@ -686,4 +705,12 @@ rcxml_finish(void)
|
||||||
zfree(l->name);
|
zfree(l->name);
|
||||||
zfree(l);
|
zfree(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reset state vars for starting fresh when Reload is triggered */
|
||||||
|
current_keybind = NULL;
|
||||||
|
current_mousebind = NULL;
|
||||||
|
current_libinput_category = NULL;
|
||||||
|
current_mouse_context = NULL;
|
||||||
|
current_keybind_action = NULL;
|
||||||
|
current_mousebind_action = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ fill_item(char *nodename, char *content)
|
||||||
/* <item label=""> defines the start of a new item */
|
/* <item label=""> defines the start of a new item */
|
||||||
if (!strcmp(nodename, "label")) {
|
if (!strcmp(nodename, "label")) {
|
||||||
current_item = item_create(current_menu, content);
|
current_item = item_create(current_menu, content);
|
||||||
|
current_item_action = NULL;
|
||||||
} else if (!current_item) {
|
} else if (!current_item) {
|
||||||
wlr_log(WLR_ERROR, "expect <item label=\"\"> element first. "
|
wlr_log(WLR_ERROR, "expect <item label=\"\"> element first. "
|
||||||
"nodename: '%s' content: '%s'", nodename, content);
|
"nodename: '%s' content: '%s'", nodename, content);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue