From 46f153320ca5b9f40ba065f9b8a94a74cea8e9cf Mon Sep 17 00:00:00 2001 From: DonO Date: Thu, 7 Mar 2024 10:04:21 -0600 Subject: [PATCH] Window Switch - detail info for all workspaces option --- docs/labwc-config.5.scd | 12 +++++++----- docs/rc.xml.all | 9 +++++++++ include/config/rcxml.h | 2 ++ src/config/rcxml.c | 13 ++++++++++++- src/osd.c | 20 ++++++++++++++++++-- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index 7be9d3e7c..bf18304a4 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -196,7 +196,7 @@ this is for compatibility with Openbox. *content* defines what the field shows and can be any of: - - *type* Show view type ("xdg-shell" or "xwayland") + - *type* Show view type ("W" for xdg-shell or "X" for xwayland) - *identifier* Show identifier (app_id for native Wayland windows and WM_CLASS for XWayland clients) @@ -303,10 +303,9 @@ extending outward from the snapped edge. ## WORKSPACES ** - Define workspaces. A workspace covers all outputs. The OSD only shows - windows on the current workspace. Workspaces can be switched to with - GoToDesktop and windows can be moved with SendToDesktop. See - labwc-actions(5) for more information about their arguments. + Define workspaces. A workspace covers all outputs. Workspaces can be + switched to with GoToDesktop and windows can be moved with SendToDesktop. + See labwc-actions(5) for more information about their arguments. The number attribute defines the minimum number of workspaces. Default is 1. The number attribute is optional. If the number attribute is @@ -316,6 +315,9 @@ extending outward from the snapped edge. Define the timeout after which to hide the workspace OSD. A setting of 0 disables the OSD. Default is 1000 ms. +** + Set the prefix to use when using "number" above. Default is "Workspace" + ## THEME ** diff --git a/docs/rc.xml.all b/docs/rc.xml.all index 902f88c56..17468f251 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -100,9 +100,18 @@ Or it can also be configured like this: + Or like this: + + 500 + 5 + ws + + popupTime defaults to 1000 so could be left out. Set to 0 to completely disable the workspace OSD. + prefix defaults to "Workspace" when using number instead of names. + Use GoToDesktop left | right to switch workspaces. Use SendToDesktop left | right to move windows. See man labwc-actions for further information. diff --git a/include/config/rcxml.h b/include/config/rcxml.h index a0250711a..707f00d42 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -129,6 +129,7 @@ struct rcxml { struct { int popuptime; int min_nr_workspaces; + char *prefix; struct wl_list workspaces; /* struct workspace.link */ } workspace_config; @@ -140,6 +141,7 @@ struct rcxml { bool show; bool preview; bool outlines; + bool allworkspaces; 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 1b2265d2e..acb1ac389 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -895,9 +895,13 @@ 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 (parse_bool(content, -1) == true) { rc.window_switcher.criteria &= ~LAB_VIEW_CRITERIA_CURRENT_WORKSPACE; + } else { + rc.window_switcher.criteria |= + LAB_VIEW_CRITERIA_CURRENT_WORKSPACE; } /* Remove this long term - just a friendly warning for now */ @@ -934,6 +938,8 @@ entry(xmlNode *node, char *nodename, char *content) rc.workspace_config.popuptime = atoi(content); } else if (!strcasecmp(nodename, "number.desktops")) { rc.workspace_config.min_nr_workspaces = MAX(1, atoi(content)); + } else if (!strcasecmp(nodename, "prefix.desktops")) { + rc.workspace_config.prefix = xstrdup(content); } else if (!strcasecmp(nodename, "popupShow.resize")) { if (!strcasecmp(content, "Always")) { rc.resize_indicator = LAB_RESIZE_INDICATOR_ALWAYS; @@ -1153,6 +1159,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.criteria = LAB_VIEW_CRITERIA_CURRENT_WORKSPACE | LAB_VIEW_CRITERIA_ROOT_TOPLEVEL | LAB_VIEW_CRITERIA_NO_SKIP_WINDOW_SWITCHER; @@ -1465,10 +1472,14 @@ post_processing(void) int nr_workspaces = wl_list_length(&rc.workspace_config.workspaces); if (nr_workspaces < rc.workspace_config.min_nr_workspaces) { + char *ws_name = xstrdup("Workspace"); + if (rc.workspace_config.prefix) { + ws_name = rc.workspace_config.prefix; + } struct workspace *workspace; for (int i = nr_workspaces; i < rc.workspace_config.min_nr_workspaces; i++) { workspace = znew(*workspace); - workspace->name = strdup_printf("Workspace %d", i + 1); + workspace->name = strdup_printf("%s %d", ws_name, i + 1); wl_list_append(&rc.workspace_config.workspaces, &workspace->link); } } diff --git a/src/osd.c b/src/osd.c index b0b59a784..fc70fea53 100644 --- a/src/osd.c +++ b/src/osd.c @@ -230,10 +230,10 @@ get_type(struct view *view) { switch (view->type) { case LAB_XDG_SHELL_VIEW: - return "[xdg-shell]"; + return "[W] "; #if HAVE_XWAYLAND case LAB_XWAYLAND_VIEW: - return "[xwayland]"; + return "[X] "; #endif } return ""; @@ -362,7 +362,23 @@ 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, (*view)->workspace->name); + if ((*view)->maximized) { + buf_add(&buf, " M "); + } else if ((*view)->minimized) { + buf_add(&buf, " m "); + } else if ((*view)->fullscreen) { + buf_add(&buf, " F "); + } else { + buf_add(&buf, " "); + } + } buf_add(&buf, get_type(*view)); + if (rc.window_switcher.allworkspaces && + wl_list_length(&server->outputs) > 1) { + buf_add(&buf, (*view)->output->wlr_output->name); + } break; case LAB_FIELD_IDENTIFIER: buf_add(&buf, get_app_id(*view));