]> git.mdlowis.com Git - proto/labwc.git/commitdiff
window-rules: add ignoreFocusRequest property
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 3 Sep 2023 12:01:40 +0000 (14:01 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 10 Sep 2023 11:31:15 +0000 (13:31 +0200)
This allows to reject focus requests from specific applications.

docs/labwc-config.5.scd
include/window-rules.h
src/config/rcxml.c
src/window-rules.c
src/xdg.c
src/xwayland.c

index ca301883fc8f69116e3bfb717a8b995f181cb32f..eceebc97e0aa54f92e49348413dc507b5398e9ea 100644 (file)
@@ -482,6 +482,9 @@ situation.
        *skipWindowSwitcher* removes window from the Window Switcher (alt-tab
        on-screen-display)
 
+*<windowRules><windowRule ignoreFocusRequest="">* [yes|no|default]
+       *ignoreFocusRequest* prevent window to activate itself.
+
 ## ENVIRONMENT VARIABLES
 
 *XCURSOR_THEME* and *XCURSOR_SIZE* are supported to set cursor theme
index 69a56195c34d078d713fcf400c8928df7ed1cad3..fae1daf7a4b3d0294febfa6cf18d1fff579cfd6c 100644 (file)
@@ -29,6 +29,7 @@ struct window_rule {
        enum property server_decoration;
        enum property skip_taskbar;
        enum property skip_window_switcher;
+       enum property ignore_focus_request;
 
        struct wl_list link; /* struct rcxml.window_rules */
 };
index 2c525c72110f8e0c63a5811994680a719a863c3d..5b079cae3c3a735870f171f2dd9cc277a41ea198 100644 (file)
@@ -150,6 +150,8 @@ fill_window_rule(char *nodename, char *content)
                set_property(content, &current_window_rule->skip_taskbar);
        } else if (!strcasecmp(nodename, "skipWindowSwitcher")) {
                set_property(content, &current_window_rule->skip_window_switcher);
+       } else if (!strcasecmp(nodename, "ignoreFocusRequest")) {
+               set_property(content, &current_window_rule->ignore_focus_request);
 
        /* Actions */
        } else if (!strcmp(nodename, "name.action")) {
index de9da91da76e9e76782ae11cb221cf515310592b..2607199a76eb7154732643fb68171cb32249b54e 100644 (file)
@@ -124,6 +124,10 @@ window_rules_get_property(struct view *view, const char *property)
                                        && !strcasecmp(property, "skipWindowSwitcher")) {
                                return rule->skip_window_switcher;
                        }
+                       if (rule->ignore_focus_request
+                                       && !strcasecmp(property, "ignoreFocusRequest")) {
+                               return rule->ignore_focus_request;
+                       }
                }
        }
        return LAB_PROP_UNSPECIFIED;
index 20b87b6ad3a4758aed9f898f7bfef206af761499..9be6338b104a540e2b1ce5333caf44bc68be914f 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -590,6 +590,11 @@ xdg_activation_handle_request(struct wl_listener *listener, void *data)
         * for the seat / serial being correct and then allow the request.
         */
 
+       if (window_rules_get_property(view, "ignoreFocusRequest") == LAB_PROP_TRUE) {
+               wlr_log(WLR_INFO, "Ignoring focus request due to window rule configuration");
+               return;
+       }
+
        /*
         * TODO: This is the exact same code as used in foreign.c.
         *       Refactor it into a public helper function somewhere.
index 4f9a84bd5e7808a51718d88e5a6738fb2b0db86e..b00119c66278239b28f5159ef2044949862e67f6 100644 (file)
@@ -285,6 +285,12 @@ handle_request_activate(struct wl_listener *listener, void *data)
        struct xwayland_view *xwayland_view =
                wl_container_of(listener, xwayland_view, request_activate);
        struct view *view = &xwayland_view->base;
+
+       if (window_rules_get_property(view, "ignoreFocusRequest") == LAB_PROP_TRUE) {
+               wlr_log(WLR_INFO, "Ignoring focus request due to window rule configuration");
+               return;
+       }
+
        desktop_focus_and_activate_view(&view->server->seat, view);
        view_move_to_front(view);
 }