]> git.mdlowis.com Git - proto/labwc.git/commitdiff
osd: support full app_id in window switcher (#1309)
authorkyak <699631+kyak@users.noreply.github.com>
Wed, 27 Dec 2023 10:55:49 +0000 (13:55 +0300)
committerGitHub <noreply@github.com>
Wed, 27 Dec 2023 10:55:49 +0000 (10:55 +0000)
Support showing full application
identifier or the trimmed variant in window switcher OSD.

Regression notice: For anyone using ‘identifier’ in window-switcher field configuration, change it to ‘trimmed_identifier’.

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

index fac994d0445de0a2b396e41806504a1cb2d3d728..a7c9dda35ebd23df7b4a06b2a28b657e297a71d7 100644 (file)
@@ -163,6 +163,9 @@ this is for compatibility with Openbox.
                - *identifier* Show identifier (app_id for native Wayland
                  windows and WM_CLASS for XWayland clients)
 
+               - *trimmed_identifier* Show trimmed identifier. Trimming removes the first
+                 two nodes of 'org.' strings.
+
                - *title* Show window title if different to app_id
 
        *width* defines the width of the field expressed as a percentage of
index 96439dc9e3c7e0dda61d88ee81a5eb5fecf97ccb..c5ef69cf09086970dfea2102953c7e5e241fd113 100644 (file)
@@ -56,7 +56,8 @@
   <windowSwitcher show="yes" preview="yes" outlines="yes">
     <fields>
       <field content="type" width="25%" />
-      <field content="identifier" width="25%" />
+      <field content="trimmed_identifier" width="25%" />
+      <!-- <field content="identifier" width="25%" /> -->
       <field content="title" width="50%" />
     </fields>
   </windowSwitcher>
index 068baa9eb16ba590962b20cec1faa040bf941e7a..a1978d86cffcc8dc48c1165c90dd1759bc52d9a4 100644 (file)
@@ -17,6 +17,7 @@ enum window_switcher_field_content {
        LAB_FIELD_NONE = 0,
        LAB_FIELD_TYPE,
        LAB_FIELD_IDENTIFIER,
+       LAB_FIELD_TRIMMED_IDENTIFIER,
        LAB_FIELD_TITLE,
 };
 
index 50b8f85c4e61a9f75da1549fbeb8efc8a97a8088..0ff22edd8d49a6814438f1bc3ce4eaca2d452422 100644 (file)
@@ -198,6 +198,8 @@ fill_window_switcher_field(char *nodename, char *content)
                } else if (!strcmp(content, "app_id")) {
                        wlr_log(WLR_ERROR, "window-switcher field 'app_id' is deprecated");
                        current_field->content = LAB_FIELD_IDENTIFIER;
+               } else if (!strcmp(content, "trimmed_identifier")) {
+                       current_field->content = LAB_FIELD_TRIMMED_IDENTIFIER;
                } else if (!strcmp(content, "title")) {
                        current_field->content = LAB_FIELD_TITLE;
                } else {
@@ -1228,7 +1230,7 @@ static struct {
        int width;
 } fields[] = {
        { LAB_FIELD_TYPE, 25 },
-       { LAB_FIELD_IDENTIFIER, 25 },
+       { LAB_FIELD_TRIMMED_IDENTIFIER, 25 },
        { LAB_FIELD_TITLE, 50 },
        { LAB_FIELD_NONE, 0 },
 };
index 230f87afc6bc35606a52525977f63638a1ddf3a0..e367b97d1ee7cdff38c3f934196a53984a5a5c75 100644 (file)
--- a/src/osd.c
+++ b/src/osd.c
@@ -41,6 +41,15 @@ static const char *
 get_formatted_app_id(struct view *view)
 {
        char *s = (char *)view_get_string_prop(view, "app_id");
+       if (!s) {
+               return NULL;
+       }
+       return s;
+}
+
+static const char *
+get_trimmed_app_id(char *s)
+{
        if (!s) {
                return NULL;
        }
@@ -355,6 +364,12 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
                        case LAB_FIELD_IDENTIFIER:
                                buf_add(&buf, get_app_id(*view));
                                break;
+                       case LAB_FIELD_TRIMMED_IDENTIFIER:
+                               {
+                                       char *s = (char *)get_app_id(*view);
+                                       buf_add(&buf, get_trimmed_app_id(s));
+                                       break;
+                               }
                        case LAB_FIELD_TITLE:
                                buf_add(&buf, get_title(*view));
                                break;