From cf7a4b0602c07cc0ef10e3f9c4d70feb0d0cb30c Mon Sep 17 00:00:00 2001 From: DonO Date: Mon, 11 Mar 2024 18:45:10 -0500 Subject: [PATCH] Window switcher, all workspace re-engineer code --- include/config/rcxml.h | 3 ++- src/config/rcxml.c | 8 +++++--- src/osd.c | 11 +++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/config/rcxml.h b/include/config/rcxml.h index 707f00d4..ff36e1c3 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -21,6 +21,7 @@ enum window_switcher_field_content { LAB_FIELD_IDENTIFIER, LAB_FIELD_TRIMMED_IDENTIFIER, LAB_FIELD_TITLE, + LAB_FIELD_WINFO, }; enum view_placement_policy { @@ -141,7 +142,7 @@ struct rcxml { bool show; bool preview; bool outlines; - bool allworkspaces; + bool all_workspaces; uint32_t criteria; struct wl_list fields; /* struct window_switcher_field.link */ } window_switcher; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index f63ca921..ea45d1ff 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -206,6 +206,8 @@ fill_window_switcher_field(char *nodename, char *content) current_field->content = LAB_FIELD_TRIMMED_IDENTIFIER; } else if (!strcmp(content, "title")) { current_field->content = LAB_FIELD_TITLE; + } else if (!strcmp(content, "winfo")) { + current_field->content = LAB_FIELD_WINFO; } else { 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")) { set_bool(content, &rc.window_switcher.outlines); } else if (!strcasecmp(nodename, "allWorkspaces.windowSwitcher")) { - set_bool(content, &rc.window_switcher.allworkspaces); - if (rc.window_switcher.allworkspaces) { + set_bool(content, &rc.window_switcher.all_workspaces); + if (rc.window_switcher.all_workspaces) { rc.window_switcher.criteria &= ~LAB_VIEW_CRITERIA_CURRENT_WORKSPACE; } @@ -1156,7 +1158,7 @@ rcxml_init(void) rc.window_switcher.show = true; rc.window_switcher.preview = 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 | LAB_VIEW_CRITERIA_ROOT_TOPLEVEL | LAB_VIEW_CRITERIA_NO_SKIP_WINDOW_SWITCHER; diff --git a/src/osd.c b/src/osd.c index 34f85e56..2e6bd54d 100644 --- a/src/osd.c +++ b/src/osd.c @@ -230,14 +230,14 @@ get_type(struct view *view) { switch (view->type) { case LAB_XDG_SHELL_VIEW: - if (rc.window_switcher.allworkspaces) { + if (rc.window_switcher.all_workspaces) { return "[W] "; } else { return "[xdg-shell]"; } #if HAVE_XWAYLAND case LAB_XWAYLAND_VIEW: - if (rc.window_switcher.allworkspaces) { + if (rc.window_switcher.all_workspaces) { return "[X] "; } else { return "[xwayland]"; @@ -370,7 +370,10 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h, switch (field->content) { 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); if ((*view)->maximized) { 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)); - if (rc.window_switcher.allworkspaces && + if (rc.window_switcher.all_workspaces && wl_list_length(&server->outputs) > 1) { buf_add(&buf, (*view)->output->wlr_output->name); }