Window switcher, all workspace re-engineer code

This commit is contained in:
DonO 2024-03-11 18:45:10 -05:00
parent 9b9855cb53
commit cf7a4b0602
3 changed files with 14 additions and 8 deletions

View file

@ -21,6 +21,7 @@ enum window_switcher_field_content {
LAB_FIELD_IDENTIFIER, LAB_FIELD_IDENTIFIER,
LAB_FIELD_TRIMMED_IDENTIFIER, LAB_FIELD_TRIMMED_IDENTIFIER,
LAB_FIELD_TITLE, LAB_FIELD_TITLE,
LAB_FIELD_WINFO,
}; };
enum view_placement_policy { enum view_placement_policy {
@ -141,7 +142,7 @@ struct rcxml {
bool show; bool show;
bool preview; bool preview;
bool outlines; bool outlines;
bool allworkspaces; bool all_workspaces;
uint32_t criteria; uint32_t criteria;
struct wl_list fields; /* struct window_switcher_field.link */ struct wl_list fields; /* struct window_switcher_field.link */
} window_switcher; } window_switcher;

View file

@ -206,6 +206,8 @@ fill_window_switcher_field(char *nodename, char *content)
current_field->content = LAB_FIELD_TRIMMED_IDENTIFIER; current_field->content = LAB_FIELD_TRIMMED_IDENTIFIER;
} else if (!strcmp(content, "title")) { } else if (!strcmp(content, "title")) {
current_field->content = LAB_FIELD_TITLE; current_field->content = LAB_FIELD_TITLE;
} else if (!strcmp(content, "winfo")) {
current_field->content = LAB_FIELD_WINFO;
} else { } else {
wlr_log(WLR_ERROR, "bad windowSwitcher field '%s'", content); wlr_log(WLR_ERROR, "bad windowSwitcher field '%s'", content);
} }
@ -895,8 +897,8 @@ entry(xmlNode *node, char *nodename, char *content)
} else if (!strcasecmp(nodename, "outlines.windowSwitcher")) { } else if (!strcasecmp(nodename, "outlines.windowSwitcher")) {
set_bool(content, &rc.window_switcher.outlines); set_bool(content, &rc.window_switcher.outlines);
} else if (!strcasecmp(nodename, "allWorkspaces.windowSwitcher")) { } else if (!strcasecmp(nodename, "allWorkspaces.windowSwitcher")) {
set_bool(content, &rc.window_switcher.allworkspaces); set_bool(content, &rc.window_switcher.all_workspaces);
if (rc.window_switcher.allworkspaces) { if (rc.window_switcher.all_workspaces) {
rc.window_switcher.criteria &= rc.window_switcher.criteria &=
~LAB_VIEW_CRITERIA_CURRENT_WORKSPACE; ~LAB_VIEW_CRITERIA_CURRENT_WORKSPACE;
} }
@ -1156,7 +1158,7 @@ rcxml_init(void)
rc.window_switcher.show = true; rc.window_switcher.show = true;
rc.window_switcher.preview = true; rc.window_switcher.preview = true;
rc.window_switcher.outlines = true; rc.window_switcher.outlines = true;
rc.window_switcher.allworkspaces = false; rc.window_switcher.all_workspaces = false;
rc.window_switcher.criteria = LAB_VIEW_CRITERIA_CURRENT_WORKSPACE rc.window_switcher.criteria = LAB_VIEW_CRITERIA_CURRENT_WORKSPACE
| LAB_VIEW_CRITERIA_ROOT_TOPLEVEL | LAB_VIEW_CRITERIA_ROOT_TOPLEVEL
| LAB_VIEW_CRITERIA_NO_SKIP_WINDOW_SWITCHER; | LAB_VIEW_CRITERIA_NO_SKIP_WINDOW_SWITCHER;

View file

@ -230,14 +230,14 @@ get_type(struct view *view)
{ {
switch (view->type) { switch (view->type) {
case LAB_XDG_SHELL_VIEW: case LAB_XDG_SHELL_VIEW:
if (rc.window_switcher.allworkspaces) { if (rc.window_switcher.all_workspaces) {
return "[W] "; return "[W] ";
} else { } else {
return "[xdg-shell]"; return "[xdg-shell]";
} }
#if HAVE_XWAYLAND #if HAVE_XWAYLAND
case LAB_XWAYLAND_VIEW: case LAB_XWAYLAND_VIEW:
if (rc.window_switcher.allworkspaces) { if (rc.window_switcher.all_workspaces) {
return "[X] "; return "[X] ";
} else { } else {
return "[xwayland]"; return "[xwayland]";
@ -370,7 +370,10 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
switch (field->content) { switch (field->content) {
case LAB_FIELD_TYPE: case LAB_FIELD_TYPE:
if (rc.window_switcher.allworkspaces) { buf_add(&buf, get_type(*view));
break;
case LAB_FIELD_WINFO:
if (rc.window_switcher.all_workspaces) {
buf_add(&buf, (*view)->workspace->name); buf_add(&buf, (*view)->workspace->name);
if ((*view)->maximized) { if ((*view)->maximized) {
buf_add(&buf, " M "); buf_add(&buf, " M ");
@ -383,7 +386,7 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
} }
} }
buf_add(&buf, get_type(*view)); buf_add(&buf, get_type(*view));
if (rc.window_switcher.allworkspaces && if (rc.window_switcher.all_workspaces &&
wl_list_length(&server->outputs) > 1) { wl_list_length(&server->outputs) > 1) {
buf_add(&buf, (*view)->output->wlr_output->name); buf_add(&buf, (*view)->output->wlr_output->name);
} }