]> git.mdlowis.com Git - proto/labwc.git/commitdiff
osd: add window-switcher field content types (#1623)
authordroc12345 <80716141+droc12345@users.noreply.github.com>
Sat, 16 Mar 2024 15:28:37 +0000 (10:28 -0500)
committerGitHub <noreply@github.com>
Sat, 16 Mar 2024 15:28:37 +0000 (15:28 +0000)
...`workspace`, `state`, `type_short` and `output`.

Example usage:

    <windowSwitcher allWorkspaces="yes">
      <fields>
        <field content="workspace" width="5%" />
        <field content="state" width="3%" />
        <field content="type_short" width="3%" />
        <field content="output" width="9%" />
        <field content="identifier" width="30%" />
        <field content="title" width="50%" />
      </fields>
    </windowSwitcher>

docs/labwc-config.5.scd
docs/rc.xml.all
include/config/rcxml.h
src/config/rcxml.c
src/osd.c

index ad9c01427071113197e6b6c98d1ea75403311ba5..d21db03bb0cad2489b0159f3e725f913142f77cc 100644 (file)
@@ -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.
 
index 3865c571a67018f9ef08c551d9d57f388b2a6521..65a6ab542f2722a90ca62437ca836cb49fc86774 100644 (file)
     </fields>
   </windowSwitcher>
 
+  <!--
+    When using all workspaces option of window switcher, there are extra fields
+    that can be used, workspace (variable length), state (single space), 
+    type_short (3 spaces), output (variable length), and can be set up 
+    like this. Note: output only shows if more than one output available.
+
+    <windowSwitcher show="yes" preview="no" outlines="no" allWorkspaces="yes">
+      <fields>
+        <field content="workspace" width="5%" />
+        <field content="state" width="3%" />
+        <field content="type_short" width="3%" />
+        <field content="output" width="9%" />
+        <field content="identifier" width="30%" />
+        <field content="title" width="50%" />
+       </fields>  
+    </windowSwitcher>
+  -->
+
   <!-- edge strength is in pixels -->
   <resistance>
     <screenEdgeStrength>20</screenEdgeStrength>
index 277db84920b9084302ea68317a566ac66ee36692..ac4d179518a7bb4790e8cab6895bd4fe94bcba6f 100644 (file)
@@ -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 {
index fd5b41e8f717d23d71ab0c2e06e4b6615a8fae86..d6a926d0c8d8531506f59b1c0c1b093d9eeb4944 100644 (file)
@@ -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);
                }
index b0b59a784fa21a859bc72798d96d76268cbf54b0..d6d6be56422ea080dc611d2f6d746d7cb8cd2eed 100644 (file)
--- 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;