]> git.mdlowis.com Git - proto/labwc.git/commitdiff
window-rules: add skipTaskbar and skipWindowSwitcher
authorJohan Malm <jgm323@gmail.com>
Sat, 20 May 2023 09:20:36 +0000 (10:20 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 22 May 2023 19:37:49 +0000 (20:37 +0100)
docs/labwc-config.5.scd
include/window-rules.h
src/config/rcxml.c
src/desktop.c
src/osd.c
src/view-impl-common.c
src/window-rules.c

index 730af280bb7fc4a55182c6955c7c96d01818d7e6..e2c23cacddad8e749a061c920501b63b1866cdde 100644 (file)
@@ -430,6 +430,15 @@ situation.
        *serverDecoration* over-rules any other setting for server-side window
        decoration on first map.
 
+*<windowRules><windowRule skipTaskbar="">* [yes|no|default]
+       *skipTaskbar* removes window foreign-toplevel protocol handle so that
+       it does not appear in clients such as panels and taskbars using that
+       protocol.
+
+*<windowRules><windowRule skipWindowSwitcher="">* [yes|no|default]
+       *skipWindowSwitcher* removes window from the Window Switcher (alt-tab
+       on-screen-display)
+
 ## ENVIRONMENT VARIABLES
 
 *XCURSOR_THEME* and *XCURSOR_SIZE* are supported to set cursor theme
index 9a002d084ef2029bd6e36f60e7c39212bdb1498b..4d983df02c4283cb4f65827b894bad8946b17311 100644 (file)
@@ -26,6 +26,8 @@ struct window_rule {
        struct wl_list actions;
 
        enum property server_decoration;
+       enum property skip_taskbar;
+       enum property skip_window_switcher;
 
        struct wl_list link; /* struct rcxml.window_rules */
 };
index 03e1594040ff0d3bd9aa074f5010d3989f1b83f9..b168e0b6db7fdd7525be8d089acc4c67e4f9decc 100644 (file)
@@ -110,6 +110,10 @@ fill_window_rule(char *nodename, char *content)
        /* Properties */
        } else if (!strcasecmp(nodename, "serverDecoration")) {
                set_property(content, &current_window_rule->server_decoration);
+       } else if (!strcasecmp(nodename, "skipTaskbar")) {
+               set_property(content, &current_window_rule->skip_taskbar);
+       } else if (!strcasecmp(nodename, "skipWindowSwitcher")) {
+               set_property(content, &current_window_rule->skip_window_switcher);
 
        /* Actions */
        } else if (!strcmp(nodename, "name.action")) {
index bab5d725afaee1910a84ff6f4666ae58701d6584..9493b696ada4de3ec7201c1d8159460a7959d87d 100644 (file)
@@ -9,6 +9,7 @@
 #include "node.h"
 #include "ssd.h"
 #include "view.h"
+#include "window-rules.h"
 #include "workspaces.h"
 #include "xwayland.h"
 
@@ -191,7 +192,9 @@ desktop_cycle_view(struct server *server, struct view *start_view,
                        continue;
                }
                view = node_view_from_node(node);
-               if (isfocusable(view)) {
+
+               enum property skip = window_rules_get_property(view, "skipWindowSwitcher");
+               if (isfocusable(view) && skip != LAB_PROP_TRUE) {
                        return view;
                }
        } while (view != start_view);
index f5ce9199dcede2fea26ceabaa58b7a3ca9b88813..882a3419409128c2a8815a2e775e532e11ba4c48 100644 (file)
--- a/src/osd.c
+++ b/src/osd.c
@@ -15,6 +15,7 @@
 #include "theme.h"
 #include "node.h"
 #include "view.h"
+#include "window-rules.h"
 #include "workspaces.h"
 
 #define OSD_ITEM_HEIGHT (20)
@@ -69,7 +70,8 @@ get_osd_height(struct wl_list *node_list)
                        continue;
                }
                view = node_view_from_node(node);
-               if (!isfocusable(view)) {
+               enum property skip = window_rules_get_property(view, "skipWindowSwitcher");
+               if (!isfocusable(view) || skip == LAB_PROP_TRUE) {
                        continue;
                }
                height += OSD_ITEM_HEIGHT;
@@ -344,7 +346,8 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
                        continue;
                }
                struct view *view = node_view_from_node(node);
-               if (!isfocusable(view)) {
+               enum property skip = window_rules_get_property(view, "skipWindowSwitcher");
+               if (!isfocusable(view) || skip == LAB_PROP_TRUE) {
                        continue;
                }
 
index ce22753745f999640ec3b2a05138f4726a1e696b..b39fb51775524bb4a1a8ae0da1cf71d63be930ca 100644 (file)
@@ -34,6 +34,22 @@ view_impl_map(struct view *view)
        if (!view->been_mapped) {
                window_rules_apply(view, LAB_WINDOW_RULE_EVENT_ON_FIRST_MAP);
        }
+
+       /*
+        * It's tempting to just never create the foreign-toplevel handle in the
+        * map handlers, but the app_id/title might not have been set at that
+        * point, so it's safer to process the property here
+        */
+       enum property ret = window_rules_get_property(view, "skipTaskbar");
+       if (ret == LAB_PROP_TRUE) {
+               if (view->toplevel.handle) {
+                       wlr_foreign_toplevel_handle_v1_destroy(view->toplevel.handle);
+               }
+       }
+
+       wlr_log(WLR_DEBUG, "[map] identifier=%s, title=%s\n",
+               view_get_string_prop(view, "app_id"),
+               view_get_string_prop(view, "title"));
 }
 
 static bool
index 899f89c1b9e215258c9bc94315f2ca283103f330..7b366da0aa8d9954b2fb3b17ac5399a615aee933 100644 (file)
@@ -81,10 +81,17 @@ window_rules_get_property(struct view *view, const char *property)
                 * for.
                 */
                if (view_matches_criteria(rule, view)) {
-                       if (!strcasecmp(property, "serverDecoration")) {
-                               if (rule->server_decoration) {
-                                       return rule->server_decoration;
-                               }
+                       if (rule->server_decoration
+                                       && !strcasecmp(property, "serverDecoration")) {
+                               return rule->server_decoration;
+                       }
+                       if (rule->skip_taskbar
+                                       && !strcasecmp(property, "skipTaskbar")) {
+                               return rule->skip_taskbar;
+                       }
+                       if (rule->skip_window_switcher
+                                       && !strcasecmp(property, "skipWindowSwitcher")) {
+                               return rule->skip_window_switcher;
                        }
                }
        }