]> git.mdlowis.com Git - proto/labwc.git/commitdiff
action: add "ShowMenu" option
authorJohan Malm <jgm323@gmail.com>
Sat, 31 Oct 2020 15:27:22 +0000 (15:27 +0000)
committerJohan Malm <jgm323@gmail.com>
Sat, 31 Oct 2020 15:27:22 +0000 (15:27 +0000)
Parse the following in rc.xml:

<keyboard>
  <keybind key="">
    <action name="ShowMenu">
      <menu>root-menu</menu>
    </action>
  </keybind>
</keyboard>

docs/labwc-actions.5.md
src/action.c
src/config/rcxml.c
src/cursor.c

index 058d43d732dee4a23ad70be46dc55fbdc3e03990..5c3d792d14d3d143c41766d0b1b446a55e9da082 100644 (file)
@@ -1,6 +1,6 @@
 % labwc-actions(5)
 % Johan Malm
-% 31 Aug, 2020
+% 31 Oct, 2020
 
 # NAME
 
@@ -35,6 +35,10 @@ of tags specific to each action as defined below.
 
 :   Re-load configuration and theme files
 
+`ShowMenu`
+
+:   Show menu specified by `<menu>` option. Valid menu is "root-menu"
+
 # SEE ALSO
 
 labwc(1), labwc-config(5), labwc-theme(5)
index 098ee6cca5c5897cf5b3c47b18323c4f5248795f..b1c8cc3baf480e8ebfbea35ed25712e93d70ceef 100644 (file)
@@ -3,23 +3,39 @@
 #include "common/log.h"
 #include "common/spawn.h"
 #include "labwc.h"
+#include "menu/menu.h"
+
+static void
+show_menu(struct server *server, const char *menu)
+{
+       if (!menu) {
+               return;
+       }
+       if (!strcasecmp(menu, "root-menu")) {
+               server->input_mode = LAB_INPUT_STATE_MENU;
+               menu_move(server->rootmenu, server->seat.cursor->x,
+                       server->seat.cursor->y);
+       }
+}
 
 void
 action(struct server *server, const char *action, const char *command)
 {
        if (!action)
                return;
-       if (!strcasecmp(action, "Exit")) {
-               wl_display_terminate(server->wl_display);
+       if (!strcasecmp(action, "Debug")) {
+               /* nothing */
        } else if (!strcasecmp(action, "Execute")) {
                spawn_async_no_shell(command);
+       } else if (!strcasecmp(action, "Exit")) {
+               wl_display_terminate(server->wl_display);
        } else if (!strcasecmp(action, "NextWindow")) {
                server->cycle_view =
                        desktop_cycle_view(server, server->cycle_view);
        } else if (!strcasecmp(action, "Reconfigure")) {
                spawn_async_no_shell("killall -SIGHUP labwc");
-       } else if (!strcasecmp(action, "Debug")) {
-               dbg_show_views(server);
+       } else if (!strcasecmp(action, "ShowMenu")) {
+               show_menu(server, command);
        } else {
                warn("action (%s) not supported", action);
        }
index 5aab7d92001988e1e9feba8a3a58c554b6096675..a93acaf06496b7015d48f8d3d14a5a1bfbe698cf 100644 (file)
@@ -56,6 +56,8 @@ fill_keybind(char *nodename, char *content)
                current_keybind->action = strdup(content);
        } else if (!strcmp(nodename, "command.action")) {
                current_keybind->command = strdup(content);
+       } else if (!strcmp(nodename, "menu.action")) {
+               current_keybind->command = strdup(content);
        }
 }
 
index 67d3d1b88ee3309a7b02f2c257bf8208e490a392..abfdc11d425f458c99ecdbc0f8fb09128b836d9a 100644 (file)
@@ -267,13 +267,10 @@ cursor_button(struct wl_listener *listener, void *data)
        /* handle _press_ on desktop */
        if (!view) {
                /* launch root-menu */
-               server->input_mode = LAB_INPUT_STATE_MENU;
-               menu_move(server->rootmenu, server->seat.cursor->x,
-                       server->seat.cursor->y);
+               action(server, "ShowMenu", "root-menu");
                return;
        }
 
-
        /* Handle _press_ on view */
        desktop_focus_view(&server->seat, view);
        switch (view_area) {