From: droc12345 <80716141+droc12345@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:28:37 +0000 (-0500) Subject: osd: add window-switcher field content types (#1623) X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=b0c2ac1a6d01a1e954a9eb64c1f6fe2a7c61e840;p=proto%2Flabwc.git osd: add window-switcher field content types (#1623) ...`workspace`, `state`, `type_short` and `output`. Example usage: --- diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index ad9c0142..d21db03b 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -216,6 +216,14 @@ this is for compatibility with Openbox. - *title* Show window title if different to app_id + - *workspace* Show workspace name + + - *state* Show window state, M/m/F (max/min/full) + + - *type_short* Show view type ("W" or "X") + + - *output* Show output id, if more than one output detected + *width* defines the width of the field expressed as a percentage of the overall window switcher width. The "%" character is required. diff --git a/docs/rc.xml.all b/docs/rc.xml.all index 3865c571..65a6ab54 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -63,6 +63,24 @@ + + 20 diff --git a/include/config/rcxml.h b/include/config/rcxml.h index 277db849..ac4d1795 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -21,6 +21,10 @@ enum window_switcher_field_content { LAB_FIELD_IDENTIFIER, LAB_FIELD_TRIMMED_IDENTIFIER, LAB_FIELD_TITLE, + LAB_FIELD_WORKSPACE, + LAB_FIELD_WIN_STATE, + LAB_FIELD_TYPE_SHORT, + LAB_FIELD_OUTPUT, }; enum view_placement_policy { diff --git a/src/config/rcxml.c b/src/config/rcxml.c index fd5b41e8..d6a926d0 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -207,6 +207,14 @@ 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, "workspace")) { + current_field->content = LAB_FIELD_WORKSPACE; + } else if (!strcmp(content, "state")) { + current_field->content = LAB_FIELD_WIN_STATE; + } else if (!strcmp(content, "type_short")) { + current_field->content = LAB_FIELD_TYPE_SHORT; + } else if (!strcmp(content, "output")) { + current_field->content = LAB_FIELD_OUTPUT; } else { wlr_log(WLR_ERROR, "bad windowSwitcher field '%s'", content); } diff --git a/src/osd.c b/src/osd.c index b0b59a78..d6d6be56 100644 --- a/src/osd.c +++ b/src/osd.c @@ -239,6 +239,20 @@ get_type(struct view *view) return ""; } +static const char * +get_type_short(struct view *view) +{ + switch (view->type) { + case LAB_XDG_SHELL_VIEW: + return "[W]"; +#if HAVE_XWAYLAND + case LAB_XWAYLAND_VIEW: + return "[X]"; +#endif + } + return ""; +} + static const char * get_app_id(struct view *view) { @@ -364,6 +378,31 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h, case LAB_FIELD_TYPE: buf_add(&buf, get_type(*view)); break; + case LAB_FIELD_TYPE_SHORT: + buf_add(&buf, get_type_short(*view)); + break; + case LAB_FIELD_WORKSPACE: + buf_add(&buf, (*view)->workspace->name); + break; + case LAB_FIELD_WIN_STATE: + 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, " "); + } + break; + case LAB_FIELD_OUTPUT: + if (wl_list_length(&server->outputs) > 1 && + output_is_usable((*view)->output)) { + buf_add(&buf, (*view)->output->wlr_output->name); + } else { + buf_add(&buf, " "); + } + break; case LAB_FIELD_IDENTIFIER: buf_add(&buf, get_app_id(*view)); break;