rcxml: sync rcxml.window_switcher with XML format

This commit is contained in:
tokyo4j 2025-12-07 17:44:36 +09:00 committed by Johan Malm
parent a98fd8f974
commit e2d83ff7f5
6 changed files with 39 additions and 37 deletions

View file

@ -177,16 +177,18 @@ struct rcxml {
/* Window Switcher */ /* Window Switcher */
struct { struct {
bool show;
bool preview; bool preview;
bool outlines; bool outlines;
bool unshade; bool unshade;
enum lab_view_criteria criteria;
struct wl_list fields; /* struct window_switcher_field.link */
enum cycle_osd_style style;
enum cycle_osd_output_criteria output_criteria;
char *thumbnail_label_format;
enum window_switcher_order order; enum window_switcher_order order;
enum lab_view_criteria criteria;
struct {
bool show;
enum cycle_osd_style style;
enum cycle_osd_output_criteria output_criteria;
char *thumbnail_label_format;
struct wl_list fields; /* struct cycle_osd_field.link */
} osd;
} window_switcher; } window_switcher;
struct wl_list window_rules; /* struct window_rule.link */ struct wl_list window_rules; /* struct window_rule.link */

View file

@ -39,7 +39,7 @@ struct cycle_osd_field {
enum cycle_osd_field_content content; enum cycle_osd_field_content content;
int width; int width;
char *format; char *format;
struct wl_list link; /* struct rcxml.window_switcher.fields */ struct wl_list link; /* struct rcxml.window_switcher.osd.fields */
}; };
struct buf; struct buf;

View file

@ -324,7 +324,7 @@ static void
clear_window_switcher_fields(void) clear_window_switcher_fields(void)
{ {
struct cycle_osd_field *field, *field_tmp; struct cycle_osd_field *field, *field_tmp;
wl_list_for_each_safe(field, field_tmp, &rc.window_switcher.fields, link) { wl_list_for_each_safe(field, field_tmp, &rc.window_switcher.osd.fields, link) {
wl_list_remove(&field->link); wl_list_remove(&field->link);
cycle_osd_field_free(field); cycle_osd_field_free(field);
} }
@ -334,7 +334,7 @@ static void
fill_window_switcher_field(xmlNode *node) fill_window_switcher_field(xmlNode *node)
{ {
struct cycle_osd_field *field = znew(*field); struct cycle_osd_field *field = znew(*field);
wl_list_append(&rc.window_switcher.fields, &field->link); wl_list_append(&rc.window_switcher.osd.fields, &field->link);
xmlNode *child; xmlNode *child;
char *key, *content; char *key, *content;
@ -1071,7 +1071,7 @@ entry(xmlNode *node, char *nodename, char *content)
} else if (!strcasecmp(nodename, "prefix.desktops")) { } else if (!strcasecmp(nodename, "prefix.desktops")) {
xstrdup_replace(rc.workspace_config.prefix, content); xstrdup_replace(rc.workspace_config.prefix, content);
} else if (!strcasecmp(nodename, "thumbnailLabelFormat.osd.windowSwitcher")) { } else if (!strcasecmp(nodename, "thumbnailLabelFormat.osd.windowSwitcher")) {
xstrdup_replace(rc.window_switcher.thumbnail_label_format, content); xstrdup_replace(rc.window_switcher.osd.thumbnail_label_format, content);
} else if (!lab_xml_node_is_leaf(node)) { } else if (!lab_xml_node_is_leaf(node)) {
/* parse children of nested nodes other than above */ /* parse children of nested nodes other than above */
@ -1219,23 +1219,23 @@ entry(xmlNode *node, char *nodename, char *content)
* thumnailLabelFormat is handled above to allow for an empty value * thumnailLabelFormat is handled above to allow for an empty value
*/ */
} else if (!strcasecmp(nodename, "show.osd.windowSwitcher")) { } else if (!strcasecmp(nodename, "show.osd.windowSwitcher")) {
set_bool(content, &rc.window_switcher.show); set_bool(content, &rc.window_switcher.osd.show);
} else if (!strcasecmp(nodename, "style.osd.windowSwitcher")) { } else if (!strcasecmp(nodename, "style.osd.windowSwitcher")) {
if (!strcasecmp(content, "classic")) { if (!strcasecmp(content, "classic")) {
rc.window_switcher.style = CYCLE_OSD_STYLE_CLASSIC; rc.window_switcher.osd.style = CYCLE_OSD_STYLE_CLASSIC;
} else if (!strcasecmp(content, "thumbnail")) { } else if (!strcasecmp(content, "thumbnail")) {
rc.window_switcher.style = CYCLE_OSD_STYLE_THUMBNAIL; rc.window_switcher.osd.style = CYCLE_OSD_STYLE_THUMBNAIL;
} else { } else {
wlr_log(WLR_ERROR, "Invalid windowSwitcher style '%s': " wlr_log(WLR_ERROR, "Invalid windowSwitcher style '%s': "
"should be one of classic|thumbnail", content); "should be one of classic|thumbnail", content);
} }
} else if (!strcasecmp(nodename, "output.osd.windowSwitcher")) { } else if (!strcasecmp(nodename, "output.osd.windowSwitcher")) {
if (!strcasecmp(content, "all")) { if (!strcasecmp(content, "all")) {
rc.window_switcher.output_criteria = CYCLE_OSD_OUTPUT_ALL; rc.window_switcher.osd.output_criteria = CYCLE_OSD_OUTPUT_ALL;
} else if (!strcasecmp(content, "cursor")) { } else if (!strcasecmp(content, "cursor")) {
rc.window_switcher.output_criteria = CYCLE_OSD_OUTPUT_CURSOR; rc.window_switcher.osd.output_criteria = CYCLE_OSD_OUTPUT_CURSOR;
} else if (!strcasecmp(content, "focused")) { } else if (!strcasecmp(content, "focused")) {
rc.window_switcher.output_criteria = CYCLE_OSD_OUTPUT_FOCUSED; rc.window_switcher.osd.output_criteria = CYCLE_OSD_OUTPUT_FOCUSED;
} else { } else {
wlr_log(WLR_ERROR, "Invalid windowSwitcher output '%s': " wlr_log(WLR_ERROR, "Invalid windowSwitcher output '%s': "
"should be one of all|focused|cursor", content); "should be one of all|focused|cursor", content);
@ -1252,14 +1252,14 @@ entry(xmlNode *node, char *nodename, char *content)
/* The following two are for backward compatibility only. */ /* The following two are for backward compatibility only. */
} else if (!strcasecmp(nodename, "show.windowSwitcher")) { } else if (!strcasecmp(nodename, "show.windowSwitcher")) {
set_bool(content, &rc.window_switcher.show); set_bool(content, &rc.window_switcher.osd.show);
wlr_log(WLR_ERROR, "<windowSwitcher show=\"\" /> is deprecated." wlr_log(WLR_ERROR, "<windowSwitcher show=\"\" /> is deprecated."
" Use <windowSwitcher><osd show=\"\" />"); " Use <windowSwitcher><osd show=\"\" />");
} else if (!strcasecmp(nodename, "style.windowSwitcher")) { } else if (!strcasecmp(nodename, "style.windowSwitcher")) {
if (!strcasecmp(content, "classic")) { if (!strcasecmp(content, "classic")) {
rc.window_switcher.style = CYCLE_OSD_STYLE_CLASSIC; rc.window_switcher.osd.style = CYCLE_OSD_STYLE_CLASSIC;
} else if (!strcasecmp(content, "thumbnail")) { } else if (!strcasecmp(content, "thumbnail")) {
rc.window_switcher.style = CYCLE_OSD_STYLE_THUMBNAIL; rc.window_switcher.osd.style = CYCLE_OSD_STYLE_THUMBNAIL;
} }
wlr_log(WLR_ERROR, "<windowSwitcher style=\"\" /> is deprecated." wlr_log(WLR_ERROR, "<windowSwitcher style=\"\" /> is deprecated."
" Use <windowSwitcher><osd style=\"\" />"); " Use <windowSwitcher><osd style=\"\" />");
@ -1282,7 +1282,7 @@ entry(xmlNode *node, char *nodename, char *content)
/* The following three are for backward compatibility only */ /* The following three are for backward compatibility only */
} else if (!strcasecmp(nodename, "show.windowSwitcher.core")) { } else if (!strcasecmp(nodename, "show.windowSwitcher.core")) {
set_bool(content, &rc.window_switcher.show); set_bool(content, &rc.window_switcher.osd.show);
} else if (!strcasecmp(nodename, "preview.windowSwitcher.core")) { } else if (!strcasecmp(nodename, "preview.windowSwitcher.core")) {
set_bool(content, &rc.window_switcher.preview); set_bool(content, &rc.window_switcher.preview);
} else if (!strcasecmp(nodename, "outlines.windowSwitcher.core")) { } else if (!strcasecmp(nodename, "outlines.windowSwitcher.core")) {
@ -1290,7 +1290,7 @@ entry(xmlNode *node, char *nodename, char *content)
/* The following three are for backward compatibility only */ /* The following three are for backward compatibility only */
} else if (!strcasecmp(nodename, "cycleViewOSD.core")) { } else if (!strcasecmp(nodename, "cycleViewOSD.core")) {
set_bool(content, &rc.window_switcher.show); set_bool(content, &rc.window_switcher.osd.show);
wlr_log(WLR_ERROR, "<cycleViewOSD> is deprecated." wlr_log(WLR_ERROR, "<cycleViewOSD> is deprecated."
" Use <windowSwitcher show=\"\" />"); " Use <windowSwitcher show=\"\" />");
} else if (!strcasecmp(nodename, "cycleViewPreview.core")) { } else if (!strcasecmp(nodename, "cycleViewPreview.core")) {
@ -1419,7 +1419,7 @@ rcxml_init(void)
wl_list_init(&rc.libinput_categories); wl_list_init(&rc.libinput_categories);
wl_list_init(&rc.workspace_config.workspaces); wl_list_init(&rc.workspace_config.workspaces);
wl_list_init(&rc.regions); wl_list_init(&rc.regions);
wl_list_init(&rc.window_switcher.fields); wl_list_init(&rc.window_switcher.osd.fields);
wl_list_init(&rc.window_rules); wl_list_init(&rc.window_rules);
wl_list_init(&rc.touch_configs); wl_list_init(&rc.touch_configs);
} }
@ -1484,10 +1484,10 @@ rcxml_init(void)
rc.snap_top_maximize = true; rc.snap_top_maximize = true;
rc.snap_tiling_events_mode = LAB_TILING_EVENTS_ALWAYS; rc.snap_tiling_events_mode = LAB_TILING_EVENTS_ALWAYS;
rc.window_switcher.show = true; rc.window_switcher.osd.show = true;
rc.window_switcher.style = CYCLE_OSD_STYLE_CLASSIC; rc.window_switcher.osd.style = CYCLE_OSD_STYLE_CLASSIC;
rc.window_switcher.output_criteria = CYCLE_OSD_OUTPUT_ALL; rc.window_switcher.osd.output_criteria = CYCLE_OSD_OUTPUT_ALL;
rc.window_switcher.thumbnail_label_format = xstrdup("%T"); rc.window_switcher.osd.thumbnail_label_format = xstrdup("%T");
rc.window_switcher.preview = true; rc.window_switcher.preview = true;
rc.window_switcher.outlines = true; rc.window_switcher.outlines = true;
rc.window_switcher.unshade = true; rc.window_switcher.unshade = true;
@ -1673,7 +1673,7 @@ load_default_window_switcher_fields(void)
struct cycle_osd_field *field = znew(*field); struct cycle_osd_field *field = znew(*field);
field->content = fields[i].content; field->content = fields[i].content;
field->width = fields[i].width; field->width = fields[i].width;
wl_list_append(&rc.window_switcher.fields, &field->link); wl_list_append(&rc.window_switcher.osd.fields, &field->link);
} }
} }
@ -1794,7 +1794,7 @@ post_processing(void)
if (rc.workspace_config.popuptime == INT_MIN) { if (rc.workspace_config.popuptime == INT_MIN) {
rc.workspace_config.popuptime = 1000; rc.workspace_config.popuptime = 1000;
} }
if (!wl_list_length(&rc.window_switcher.fields)) { if (!wl_list_length(&rc.window_switcher.osd.fields)) {
wlr_log(WLR_INFO, "load default window switcher fields"); wlr_log(WLR_INFO, "load default window switcher fields");
load_default_window_switcher_fields(); load_default_window_switcher_fields();
} }
@ -1888,7 +1888,7 @@ validate(void)
/* OSD fields */ /* OSD fields */
int field_width_sum = 0; int field_width_sum = 0;
struct cycle_osd_field *field, *field_tmp; struct cycle_osd_field *field, *field_tmp;
wl_list_for_each_safe(field, field_tmp, &rc.window_switcher.fields, link) { wl_list_for_each_safe(field, field_tmp, &rc.window_switcher.osd.fields, link) {
field_width_sum += field->width; field_width_sum += field->width;
if (!cycle_osd_field_is_valid(field) || field_width_sum > 100) { if (!cycle_osd_field_is_valid(field) || field_width_sum > 100) {
wlr_log(WLR_ERROR, "Deleting invalid window switcher field %p", field); wlr_log(WLR_ERROR, "Deleting invalid window switcher field %p", field);
@ -1964,7 +1964,7 @@ rcxml_finish(void)
zfree(rc.fallback_app_icon_name); zfree(rc.fallback_app_icon_name);
zfree(rc.workspace_config.prefix); zfree(rc.workspace_config.prefix);
zfree(rc.tablet.output_name); zfree(rc.tablet.output_name);
zfree(rc.window_switcher.thumbnail_label_format); zfree(rc.window_switcher.osd.thumbnail_label_format);
clear_title_layout(); clear_title_layout();

View file

@ -257,7 +257,7 @@ preview_selected_view(struct view *view)
static struct cycle_osd_impl * static struct cycle_osd_impl *
get_osd_impl(void) get_osd_impl(void)
{ {
switch (rc.window_switcher.style) { switch (rc.window_switcher.osd.style) {
case CYCLE_OSD_STYLE_CLASSIC: case CYCLE_OSD_STYLE_CLASSIC:
return &cycle_osd_classic_impl; return &cycle_osd_classic_impl;
case CYCLE_OSD_STYLE_THUMBNAIL: case CYCLE_OSD_STYLE_THUMBNAIL:
@ -307,9 +307,9 @@ init_cycle(struct server *server)
return false; return false;
} }
if (rc.window_switcher.show) { if (rc.window_switcher.osd.show) {
/* Create OSD */ /* Create OSD */
switch (rc.window_switcher.output_criteria) { switch (rc.window_switcher.osd.output_criteria) {
case CYCLE_OSD_OUTPUT_ALL: { case CYCLE_OSD_OUTPUT_ALL: {
struct output *output; struct output *output;
wl_list_for_each(output, &server->outputs, link) { wl_list_for_each(output, &server->outputs, link) {
@ -342,7 +342,7 @@ update_cycle(struct server *server)
{ {
struct cycle_state *cycle = &server->cycle; struct cycle_state *cycle = &server->cycle;
if (rc.window_switcher.show) { if (rc.window_switcher.osd.show) {
struct output *output; struct output *output;
wl_list_for_each(output, &server->outputs, link) { wl_list_for_each(output, &server->outputs, link) {
if (output->cycle_osd.tree) { if (output->cycle_osd.tree) {

View file

@ -36,7 +36,7 @@ create_fields_scene(struct server *server, struct view *view,
&theme->osd_window_switcher_classic; &theme->osd_window_switcher_classic;
struct cycle_osd_field *field; struct cycle_osd_field *field;
wl_list_for_each(field, &rc.window_switcher.fields, link) { wl_list_for_each(field, &rc.window_switcher.osd.fields, link) {
int field_width = field_widths_sum * field->width / 100.0; int field_width = field_widths_sum * field->width / 100.0;
struct wlr_scene_node *node = NULL; struct wlr_scene_node *node = NULL;
int height = -1; int height = -1;
@ -144,7 +144,7 @@ cycle_osd_classic_create(struct output *output)
y += switcher_theme->item_height; y += switcher_theme->item_height;
} }
int nr_fields = wl_list_length(&rc.window_switcher.fields); int nr_fields = wl_list_length(&rc.window_switcher.osd.fields);
/* This is the width of the area available for text fields */ /* This is the width of the area available for text fields */
int field_widths_sum = w - 2 * padding int field_widths_sum = w - 2 * padding

View file

@ -103,7 +103,7 @@ create_label(struct wlr_scene_tree *parent, struct view *view,
{ {
struct buf buf = BUF_INIT; struct buf buf = BUF_INIT;
cycle_osd_field_set_custom(&buf, view, cycle_osd_field_set_custom(&buf, view,
rc.window_switcher.thumbnail_label_format); rc.window_switcher.osd.thumbnail_label_format);
struct scaled_font_buffer *buffer = struct scaled_font_buffer *buffer =
scaled_font_buffer_create(parent); scaled_font_buffer_create(parent);
scaled_font_buffer_update(buffer, buf.data, scaled_font_buffer_update(buffer, buf.data,