mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
config: support <margin top="" bottom="" left="" right="" output="" />
This commit is contained in:
parent
3a9dcd54a7
commit
4a531daef8
5 changed files with 97 additions and 0 deletions
|
|
@ -31,12 +31,14 @@
|
|||
#include "workspaces.h"
|
||||
|
||||
static bool in_regions;
|
||||
static bool in_usable_area_override;
|
||||
static bool in_keybind;
|
||||
static bool in_mousebind;
|
||||
static bool in_libinput_category;
|
||||
static bool in_window_switcher_field;
|
||||
static bool in_window_rules;
|
||||
|
||||
static struct usable_area_override *current_usable_area_override;
|
||||
static struct keybind *current_keybind;
|
||||
static struct mousebind *current_mousebind;
|
||||
static struct libinput_category *current_libinput_category;
|
||||
|
|
@ -60,6 +62,36 @@ enum font_place {
|
|||
static void load_default_key_bindings(void);
|
||||
static void load_default_mouse_bindings(void);
|
||||
|
||||
static void
|
||||
fill_usable_area_override(char *nodename, char *content)
|
||||
{
|
||||
if (!strcasecmp(nodename, "margin")) {
|
||||
current_usable_area_override = znew(*current_usable_area_override);
|
||||
wl_list_append(&rc.usable_area_overrides, ¤t_usable_area_override->link);
|
||||
return;
|
||||
}
|
||||
string_truncate_at_pattern(nodename, ".margin");
|
||||
if (!content) {
|
||||
/* nop */
|
||||
} else if (!current_usable_area_override) {
|
||||
wlr_log(WLR_ERROR, "no usable-area-override object");
|
||||
} else if (!strcmp(nodename, "output")) {
|
||||
free(current_usable_area_override->output);
|
||||
current_usable_area_override->output = xstrdup(content);
|
||||
} else if (!strcmp(nodename, "left")) {
|
||||
current_usable_area_override->margin.left = atoi(content);
|
||||
} else if (!strcmp(nodename, "right")) {
|
||||
current_usable_area_override->margin.right = atoi(content);
|
||||
} else if (!strcmp(nodename, "top")) {
|
||||
current_usable_area_override->margin.top = atoi(content);
|
||||
} else if (!strcmp(nodename, "bottom")) {
|
||||
current_usable_area_override->margin.bottom = atoi(content);
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "Unexpected data usable-area-override parser: %s=\"%s\"",
|
||||
nodename, content);
|
||||
}
|
||||
}
|
||||
|
||||
/* Does a boolean-parse but also allows 'default' */
|
||||
static void
|
||||
set_property(const char *str, enum property *variable)
|
||||
|
|
@ -478,6 +510,9 @@ entry(xmlNode *node, char *nodename, char *content)
|
|||
printf("%s: %s\n", nodename, content);
|
||||
}
|
||||
|
||||
if (in_usable_area_override) {
|
||||
fill_usable_area_override(nodename, content);
|
||||
}
|
||||
if (in_keybind) {
|
||||
fill_keybind(nodename, content);
|
||||
}
|
||||
|
|
@ -564,6 +599,7 @@ entry(xmlNode *node, char *nodename, char *content)
|
|||
} else if (!strcasecmp(nodename, "name.context.mouse")) {
|
||||
current_mouse_context = content;
|
||||
current_mousebind = NULL;
|
||||
|
||||
} else if (!strcasecmp(nodename, "repeatRate.keyboard")) {
|
||||
rc.repeat_rate = atoi(content);
|
||||
} else if (!strcasecmp(nodename, "repeatDelay.keyboard")) {
|
||||
|
|
@ -656,6 +692,12 @@ xml_tree_walk(xmlNode *node)
|
|||
if (!strcasecmp((char *)n->name, "comment")) {
|
||||
continue;
|
||||
}
|
||||
if (!strcasecmp((char *)n->name, "margin")) {
|
||||
in_usable_area_override = true;
|
||||
traverse(n);
|
||||
in_usable_area_override = false;
|
||||
continue;
|
||||
}
|
||||
if (!strcasecmp((char *)n->name, "keybind")) {
|
||||
in_keybind = true;
|
||||
traverse(n);
|
||||
|
|
@ -724,6 +766,7 @@ rcxml_init(void)
|
|||
static bool has_run;
|
||||
|
||||
if (!has_run) {
|
||||
wl_list_init(&rc.usable_area_overrides);
|
||||
wl_list_init(&rc.keybinds);
|
||||
wl_list_init(&rc.mousebinds);
|
||||
wl_list_init(&rc.libinput_categories);
|
||||
|
|
@ -1185,6 +1228,13 @@ rcxml_finish(void)
|
|||
zfree(rc.font_osd.name);
|
||||
zfree(rc.theme_name);
|
||||
|
||||
struct usable_area_override *area, *area_tmp;
|
||||
wl_list_for_each_safe(area, area_tmp, &rc.usable_area_overrides, link) {
|
||||
wl_list_remove(&area->link);
|
||||
zfree(area->output);
|
||||
zfree(area);
|
||||
}
|
||||
|
||||
struct keybind *k, *k_tmp;
|
||||
wl_list_for_each_safe(k, k_tmp, &rc.keybinds, link) {
|
||||
wl_list_remove(&k->link);
|
||||
|
|
@ -1228,6 +1278,7 @@ rcxml_finish(void)
|
|||
}
|
||||
|
||||
/* Reset state vars for starting fresh when Reload is triggered */
|
||||
current_usable_area_override = NULL;
|
||||
current_keybind = NULL;
|
||||
current_mousebind = NULL;
|
||||
current_libinput_category = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue