]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add omnipresent flag for views
authorBrandon Nason <brandon.nason@gmail.com>
Sat, 25 Nov 2023 23:54:36 +0000 (17:54 -0600)
committerJohan Malm <johanmalm@users.noreply.github.com>
Tue, 28 Nov 2023 21:41:30 +0000 (21:41 +0000)
docs/labwc-actions.5.scd
include/view.h
src/action.c
src/menu/menu.c
src/view.c
src/workspaces.c

index 5b2463bbb27ca7cf4466b7086c225fb6345d09d9..2af1f0bc499e88bac84d3514d9a6f00a59ced1f2 100644 (file)
@@ -133,6 +133,9 @@ Actions are used in menus and keyboard/mouse bindings.
        when defining window-rules for desktop-management tools that do not
        support the wlr-layer-shell protocol.
 
+*<action name="ToggleOmnipresent" />*
+       Toggle omnipresent (visible on all workspaces / sticky) for the focused window.
+
 *<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 f7329fdc67d9bb71b2394416071bac210bcb60ac..04460f3b7daf60bbd501e4b064ba5a310c1ea658 100644 (file)
@@ -149,6 +149,7 @@ struct view {
        bool minimized;
        enum view_axis maximized;
        bool fullscreen;
+       bool visible_on_all_workspaces;
        enum view_edge tiled;
        bool inhibits_keybinds;
        xkb_layout_index_t keyboard_layout;
@@ -400,8 +401,10 @@ void view_toggle_decorations(struct view *view);
 
 bool view_is_always_on_top(struct view *view);
 bool view_is_always_on_bottom(struct view *view);
+bool view_is_omnipresent(struct view *view);
 void view_toggle_always_on_top(struct view *view);
 void view_toggle_always_on_bottom(struct view *view);
+void view_toggle_visible_on_all_workspaces(struct view *view);
 
 bool view_is_tiled(struct view *view);
 bool view_is_floating(struct view *view);
index bd0b7051985d172002b40d0fadaecc4d9b5e760c..07a52dd2b45cdd6c25dec7aefddc3cb581e06517 100644 (file)
@@ -78,6 +78,7 @@ enum action_type {
        ACTION_TYPE_TOGGLE_DECORATIONS,
        ACTION_TYPE_TOGGLE_ALWAYS_ON_TOP,
        ACTION_TYPE_TOGGLE_ALWAYS_ON_BOTTOM,
+       ACTION_TYPE_TOGGLE_OMNIPRESENT,
        ACTION_TYPE_FOCUS,
        ACTION_TYPE_UNFOCUS,
        ACTION_TYPE_ICONIFY,
@@ -120,6 +121,7 @@ const char *action_names[] = {
        "ToggleDecorations",
        "ToggleAlwaysOnTop",
        "ToggleAlwaysOnBottom",
+       "ToggleOmnipresent",
        "Focus",
        "Unfocus",
        "Iconify",
@@ -744,6 +746,11 @@ actions_run(struct view *activator, struct server *server,
                                view_toggle_always_on_bottom(view);
                        }
                        break;
+               case ACTION_TYPE_TOGGLE_OMNIPRESENT:
+                       if (view) {
+                               view_toggle_visible_on_all_workspaces(view);
+                       }
+                       break;
                case ACTION_TYPE_FOCUS:
                        if (view) {
                                desktop_focus_view(view, /*raise*/ false);
index eca829250e52228d8b607b3a060921a6566323ff..3e36d3ad80cc1f4b6b83a6a57bf4b719a4e1b707 100644 (file)
@@ -723,6 +723,8 @@ init_windowmenu(struct server *server)
                fill_item("name.action", "ToggleDecorations");
                current_item = item_create(menu, _("AlwaysOnTop"), false);
                fill_item("name.action", "ToggleAlwaysOnTop");
+               current_item = item_create(menu, _("ToggleOmnipresent"), false);
+               fill_item("name.action", "ToggleOmnipresent");
 
                /* Workspace sub-menu */
                struct menu *workspace_menu = menu_create(server, "workspaces", "");
index 4a2008df1a481da014bc74eb8b72cdf77d4ca7ee..f26ca4ac4f9c6d294af5e800acdbdc3c0f98dfe4 100644 (file)
@@ -1045,6 +1045,13 @@ view_toggle_always_on_bottom(struct view *view)
        }
 }
 
+void
+view_toggle_visible_on_all_workspaces(struct view *view)
+{
+       assert(view);
+       view->visible_on_all_workspaces = !view->visible_on_all_workspaces;
+}
+
 void
 view_move_to_workspace(struct view *view, struct workspace *workspace)
 {
index c04bc34a513dca8968f8dd14ed2db1dd732f9838..e7707c5feafd2b2d67d5636699a83f881726b282 100644 (file)
@@ -276,6 +276,16 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
        wlr_scene_node_set_enabled(
                &server->workspace_current->tree->node, false);
 
+       /* Move Omnipresent views to new workspace */
+       struct view *view;
+       enum lab_view_criteria criteria =
+               LAB_VIEW_CRITERIA_CURRENT_WORKSPACE;
+       for_each_view(view, &server->views, criteria) {
+               if (view->visible_on_all_workspaces) {
+                       view_move_to_workspace(view, target);
+               }
+       }
+
        /* Enable the new workspace */
        wlr_scene_node_set_enabled(&target->tree->node, true);