rcxml: rewrite <touch> parser

This commit is contained in:
tokyo4j 2025-04-12 01:33:28 +09:00 committed by Johan Malm
parent 8ae2d72cef
commit 7adbfe88aa

View file

@ -640,27 +640,24 @@ fill_mouse_context(xmlNode *node)
} }
static void static void
fill_touch(char *nodename, char *content, struct parser_state *state) fill_touch(xmlNode *node)
{ {
if (!strcasecmp(nodename, "touch")) { struct touch_config_entry *touch_config = znew(*touch_config);
state->current_touch = znew(*state->current_touch); wl_list_append(&rc.touch_configs, &touch_config->link);
wl_list_append(&rc.touch_configs, &state->current_touch->link);
return;
}
if (!content) { xmlNode *child;
return; char *key, *content;
} LAB_XML_FOR_EACH(node, child, key, content) {
if (!strcasecmp(key, "deviceName")) {
if (!strcasecmp(nodename, "deviceName.touch")) { xstrdup_replace(touch_config->device_name, content);
xstrdup_replace(state->current_touch->device_name, content); } else if (!strcasecmp(key, "mapToOutput")) {
} else if (!strcasecmp(nodename, "mapToOutput.touch")) { xstrdup_replace(touch_config->output_name, content);
xstrdup_replace(state->current_touch->output_name, content); } else if (!strcasecmp(key, "mouseEmulation")) {
} else if (!strcasecmp(nodename, "mouseEmulation.touch")) { set_bool(content, &touch_config->force_mouse_emulation);
set_bool(content, &state->current_touch->force_mouse_emulation); } else {
} else { wlr_log(WLR_ERROR, "Unexpected data in touch parser: %s=\"%s\"",
wlr_log(WLR_ERROR, "Unexpected data in touch parser: %s=\"%s\"", key, content);
nodename, content); }
} }
} }
@ -1060,8 +1057,8 @@ entry(xmlNode *node, char *nodename, char *content, struct parser_state *state)
fill_mouse_context(node); fill_mouse_context(node);
return; return;
} }
if (state->in_touch) { if (!strcasecmp(nodename, "touch")) {
fill_touch(nodename, content, state); fill_touch(node);
return; return;
} }
if (state->in_libinput_category) { if (state->in_libinput_category) {