]> git.mdlowis.com Git - proto/labwc.git/commitdiff
client send to menu
authorDroc <japhack@yahoo.com>
Thu, 19 Sep 2024 00:01:28 +0000 (19:01 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 19 Sep 2024 05:36:27 +0000 (06:36 +0100)
Shows all workspaces that current view can be sent to.
Works best when added to Client menu.

<menu id="client-send-to-menu" label="Send to..." />

Menu uses ">" and "<"  to highlight the current workspace

docs/labwc-actions.5.scd
docs/labwc-menu.5.scd
docs/menu.xml
include/menu/menu.h
src/action.c
src/menu/menu.c

index 7092a44c28ce21d096e6b141ad3efb9be9159fe6..85595c9370d61e67ccf0d782d33bc8b74c66b0a4 100644 (file)
@@ -115,9 +115,9 @@ Actions are used in menus and keyboard/mouse bindings.
        Show a menu.
 
        *menu* The name of the menu to show. The menus "root-menu",
-       "client-menu", and "client-list-combined-menu" are guaranteed to exist,
-       but others may be defined explicitly. See labwc-menu(5) for more
-       information.
+       "client-menu", "client-send-to-menu" and "client-list-combined-menu"
+       are guaranteed to exist, but others may be defined explicitly.
+       See labwc-menu(5) for more information.
 
        *atCursor* [yes|no] When opening a menu, open the menu at the location
        of the mouse cursor. When set to no, the menu will appear at the
index f017d986b7db87e6ae6e1d5be3d20fb1fb2b5485..072a7ea7f68c0b813cb624d7c93cd67fb6f265bf 100644 (file)
@@ -49,7 +49,11 @@ The menu file must be entirely enclosed within <openbox_menu> and
                - "root-menu" for the root window context menu
                - "client-menu" for a window's titlebar context menu
                - "client-list-combined-menu" for a list of all windows across
-                 all workspaces
+                 all workspaces. Will change focus to the app that gets
+                 selected or go to workspace without activating any app if
+                 "Go there" is selected.
+               - "client-send-to-menu" shows all workspaces and sends current
+                 view to that workspace when selected.
 
 *menu.id* (when nested under other *<menu>* element)
        Link to a submenu defined elsewhere (by a *<menu id="">* at toplevel)
index 2fd2c0945cdb0a444bbb38f42dc634d3f561b092..f64228a67de637e05e36d9aeb911c39d1f977d2e 100644 (file)
       <action name="ToggleOmnipresent" />
     </item>
   </menu>
+  <!--
+    openbox default workspace selector
+    to use replace above workspace menu with the example below
+    the label is required, but you can change the text.
+
+    <menu id="client-send-to-menu" label="Send to..." />
+  -->
   <item label="Close">
     <action name="Close" />
   </item>
index 424d47f99b7f1db8328e17c9dabaf5c156d44c8e..f55bc365ba93285f3c673af550fa6a5c05446dbe 100644 (file)
@@ -137,5 +137,6 @@ void menu_close_root(struct server *server);
 void menu_reconfigure(struct server *server);
 
 void update_client_list_combined_menu(struct server *server);
+void update_client_send_to_menu(struct server *server);
 
 #endif /* LABWC_MENU_H */
index 67067ad32c60fb1817e85314a703561af1c3e09f..a543538749c6baf1372648554fe17ac0458fb276 100644 (file)
@@ -680,10 +680,12 @@ show_menu(struct server *server, struct view *view,
 
        /* The client menu needs an active client */
        bool is_client_menu = !strcasecmp(menu_name, "client-menu");
-       if (!view && is_client_menu) {
-               return;
+       if (is_client_menu) {
+               if (!view) {
+                       return;
+               }
+               update_client_send_to_menu(menu->server);
        }
-
        /* Place menu in the view corner if desired (and menu is not root-menu) */
        if (!at_cursor && view) {
                /* push the client menu underneath the window menu button */
index 321826f5bc8dd12dead1e86a550f3a4787879d88..94b7b3f347c320389d09975750675fe44a0ca60c 100644 (file)
@@ -910,6 +910,52 @@ menu_hide_submenu(struct server *server, const char *id)
        }
 }
 
+static void
+init_client_send_to_menu(struct server *server)
+{
+       /* Just create placeholder. Contents will be created when launched */
+       menu_create(server, "client-send-to-menu", "");
+}
+
+/*
+ * This is client-send-to-menu
+ * an internal menu similar to root-menu and client-menu
+ *
+ * This will look at workspaces and produce a menu
+ * with the workspace names that can be used with
+ * SendToDesktop, left/right options are included.
+ */
+void
+update_client_send_to_menu(struct server *server)
+{
+       struct menu *menu = menu_get_by_id(server,
+                       "client-send-to-menu");
+
+       if (menu) {
+               struct menuitem *item, *next;
+               wl_list_for_each_safe(item, next, &menu->menuitems, link) {
+                       item_destroy(item);
+               }
+       }
+
+       menu->size.height = 0;
+
+       struct workspace *workspace;
+
+       wl_list_for_each(workspace, &server->workspaces, link) {
+               if (workspace == server->workspace_current) {
+                       current_item = item_create(menu, strdup_printf(">%s<", workspace->name),
+                                       /*show arrow*/ false);
+               } else {
+                       current_item = item_create(menu, workspace->name, /*show arrow*/ false);
+               }
+               fill_item("name.action", "SendToDesktop");
+               fill_item("to.action", workspace->name);
+       }
+
+       menu_update_width(menu);
+}
+
 static void
 init_client_list_combined_menu(struct server *server)
 {
@@ -1056,6 +1102,7 @@ menu_init(struct server *server)
        init_rootmenu(server);
        init_windowmenu(server);
        init_client_list_combined_menu(server);
+       init_client_send_to_menu(server);
        post_processing(server);
        validate(server);
 }