]> git.mdlowis.com Git - proto/labwc.git/commitdiff
action: add ToggleAlwaysOnBottom
authorJohan Malm <jgm323@gmail.com>
Thu, 11 May 2023 21:26:41 +0000 (22:26 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 22 May 2023 19:37:49 +0000 (20:37 +0100)
docs/labwc-actions.5.scd
include/labwc.h
include/view.h
src/action.c
src/server.c
src/view-impl-common.c
src/view.c

index 0e47d8bbbaa00e4dc6c0ede95a708479ceb3aff9..0e346a31dffaf9c65afb89938fee200463e5a653 100644 (file)
@@ -80,6 +80,13 @@ Actions are used in menus and keyboard/mouse bindings.
 *<action name="ToggleAlwaysOnTop">*
        Toggle always-on-top of focused window.
 
+*<action name="ToggleAlwaysOnBottom">*
+       Toggle bewteen layers 'always-on-bottom' and 'normal'. When a window is
+       in the 'always-on-bottom' layer, it is rendered below all other
+       top-level windows. It is anticipated that this action will be useful
+       when defining window-rules for desktop-management tools that do not
+       support the wlr-layer-shell protocol.
+
 *<action name="ToggleKeybinds">*
        Stop handling keybinds other than ToggleKeybinds itself.
        This can be used to allow A-Tab and similar keybinds to be delivered
index cbd61424f25f4b98754181ffb13e291310489b82..d2d16aeb1cffbf533bdbb25cc9d35dc53126ddbf 100644 (file)
@@ -263,6 +263,7 @@ struct server {
 
        /* Tree for all non-layer xdg/xwayland-shell surfaces with always-on-top/below */
        struct wlr_scene_tree *view_tree_always_on_top;
+       struct wlr_scene_tree *view_tree_always_on_bottom;
 #if HAVE_XWAYLAND
        /* Tree for unmanaged xsurfaces without initialized view (usually popups) */
        struct wlr_scene_tree *unmanaged_tree;
index 08e3f273bafe0f7613eddba143d237336e46677c..53f8de73a1d0524d406caa7db2d219387ce8dc07 100644 (file)
@@ -171,8 +171,11 @@ void view_maximize(struct view *view, bool maximize,
 void view_set_fullscreen(struct view *view, bool fullscreen);
 void view_toggle_maximize(struct view *view);
 void view_toggle_decorations(struct view *view);
-void view_toggle_always_on_top(struct view *view);
+
 bool view_is_always_on_top(struct view *view);
+void view_toggle_always_on_top(struct view *view);
+void view_toggle_always_on_bottom(struct view *view);
+
 bool view_is_tiled(struct view *view);
 bool view_is_floating(struct view *view);
 void view_move_to_workspace(struct view *view, struct workspace *workspace);
index 0134270a0049b2428fa121dccbc832467bfd4966..3699a39f538bfc42f1e04f7a5b329129d16eea8b 100644 (file)
@@ -61,6 +61,7 @@ enum action_type {
        ACTION_TYPE_TOGGLE_FULLSCREEN,
        ACTION_TYPE_TOGGLE_DECORATIONS,
        ACTION_TYPE_TOGGLE_ALWAYS_ON_TOP,
+       ACTION_TYPE_TOGGLE_ALWAYS_ON_BOTTOM,
        ACTION_TYPE_FOCUS,
        ACTION_TYPE_ICONIFY,
        ACTION_TYPE_MOVE,
@@ -93,6 +94,7 @@ const char *action_names[] = {
        "ToggleFullscreen",
        "ToggleDecorations",
        "ToggleAlwaysOnTop",
+       "ToggleAlwaysOnBottom",
        "Focus",
        "Iconify",
        "Move",
@@ -519,6 +521,11 @@ actions_run(struct view *activator, struct server *server,
                                view_toggle_always_on_top(view);
                        }
                        break;
+               case ACTION_TYPE_TOGGLE_ALWAYS_ON_BOTTOM:
+                       if (view) {
+                               view_toggle_always_on_bottom(view);
+                       }
+                       break;
                case ACTION_TYPE_FOCUS:
                        if (view) {
                                desktop_focus_and_activate_view(&server->seat, view);
index 9e9ad42831468e5f683e91ccf72f666052c2ef9d..4e3c3d6910032d60cf56e983787418e047d9107e 100644 (file)
@@ -307,6 +307,7 @@ server_init(struct server *server)
         * | layer-shell       | background-layer | Yes        | swaybg
         */
 
+       server->view_tree_always_on_bottom = wlr_scene_tree_create(&server->scene->tree);
        server->view_tree = wlr_scene_tree_create(&server->scene->tree);
        server->view_tree_always_on_top = wlr_scene_tree_create(&server->scene->tree);
        server->xdg_popup_tree = wlr_scene_tree_create(&server->scene->tree);
index dacfc9b070c9f77b95120570b6c8facaffcb0a33..ce22753745f999640ec3b2a05138f4726a1e696b 100644 (file)
@@ -27,13 +27,13 @@ view_impl_move_to_back(struct view *view)
 void
 view_impl_map(struct view *view)
 {
-       if (!view->been_mapped) {
-               window_rules_apply(view, LAB_WINDOW_RULE_EVENT_ON_FIRST_MAP);
-       }
        desktop_focus_and_activate_view(&view->server->seat, view);
        view_move_to_front(view);
        view_update_title(view);
        view_update_app_id(view);
+       if (!view->been_mapped) {
+               window_rules_apply(view, LAB_WINDOW_RULE_EVENT_ON_FIRST_MAP);
+       }
 }
 
 static bool
index ea7ce086d98cdcfba8a4c9c6d53dd6823f602579..6f287b3a0ada1f409245fe86050bcb13392392e8 100644 (file)
@@ -627,6 +627,28 @@ view_toggle_always_on_top(struct view *view)
        }
 }
 
+static bool
+view_is_always_on_bottom(struct view *view)
+{
+       assert(view);
+       return view->scene_tree->node.parent ==
+               view->server->view_tree_always_on_bottom;
+}
+
+void
+view_toggle_always_on_bottom(struct view *view)
+{
+       assert(view);
+       if (view_is_always_on_bottom(view)) {
+               view->workspace = view->server->workspace_current;
+               wlr_scene_node_reparent(&view->scene_tree->node,
+                       view->workspace->tree);
+       } else {
+               wlr_scene_node_reparent(&view->scene_tree->node,
+                       view->server->view_tree_always_on_bottom);
+       }
+}
+
 void
 view_move_to_workspace(struct view *view, struct workspace *workspace)
 {