mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
action: add "ShowMenu" option
Parse the following in rc.xml:
<keyboard>
<keybind key="">
<action name="ShowMenu">
<menu>root-menu</menu>
</action>
</keybind>
</keyboard>
This commit is contained in:
parent
a26fd5a75b
commit
543f00131c
4 changed files with 28 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
% labwc-actions(5)
|
% labwc-actions(5)
|
||||||
% Johan Malm
|
% Johan Malm
|
||||||
% 31 Aug, 2020
|
% 31 Oct, 2020
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
|
@ -35,6 +35,10 @@ of tags specific to each action as defined below.
|
||||||
|
|
||||||
: Re-load configuration and theme files
|
: Re-load configuration and theme files
|
||||||
|
|
||||||
|
`ShowMenu`
|
||||||
|
|
||||||
|
: Show menu specified by `<menu>` option. Valid menu is "root-menu"
|
||||||
|
|
||||||
# SEE ALSO
|
# SEE ALSO
|
||||||
|
|
||||||
labwc(1), labwc-config(5), labwc-theme(5)
|
labwc(1), labwc-config(5), labwc-theme(5)
|
||||||
|
|
|
||||||
24
src/action.c
24
src/action.c
|
|
@ -3,23 +3,39 @@
|
||||||
#include "common/log.h"
|
#include "common/log.h"
|
||||||
#include "common/spawn.h"
|
#include "common/spawn.h"
|
||||||
#include "labwc.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
|
void
|
||||||
action(struct server *server, const char *action, const char *command)
|
action(struct server *server, const char *action, const char *command)
|
||||||
{
|
{
|
||||||
if (!action)
|
if (!action)
|
||||||
return;
|
return;
|
||||||
if (!strcasecmp(action, "Exit")) {
|
if (!strcasecmp(action, "Debug")) {
|
||||||
wl_display_terminate(server->wl_display);
|
/* nothing */
|
||||||
} else if (!strcasecmp(action, "Execute")) {
|
} else if (!strcasecmp(action, "Execute")) {
|
||||||
spawn_async_no_shell(command);
|
spawn_async_no_shell(command);
|
||||||
|
} else if (!strcasecmp(action, "Exit")) {
|
||||||
|
wl_display_terminate(server->wl_display);
|
||||||
} else if (!strcasecmp(action, "NextWindow")) {
|
} else if (!strcasecmp(action, "NextWindow")) {
|
||||||
server->cycle_view =
|
server->cycle_view =
|
||||||
desktop_cycle_view(server, server->cycle_view);
|
desktop_cycle_view(server, server->cycle_view);
|
||||||
} else if (!strcasecmp(action, "Reconfigure")) {
|
} else if (!strcasecmp(action, "Reconfigure")) {
|
||||||
spawn_async_no_shell("killall -SIGHUP labwc");
|
spawn_async_no_shell("killall -SIGHUP labwc");
|
||||||
} else if (!strcasecmp(action, "Debug")) {
|
} else if (!strcasecmp(action, "ShowMenu")) {
|
||||||
dbg_show_views(server);
|
show_menu(server, command);
|
||||||
} else {
|
} else {
|
||||||
warn("action (%s) not supported", action);
|
warn("action (%s) not supported", action);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,8 @@ fill_keybind(char *nodename, char *content)
|
||||||
current_keybind->action = strdup(content);
|
current_keybind->action = strdup(content);
|
||||||
} else if (!strcmp(nodename, "command.action")) {
|
} else if (!strcmp(nodename, "command.action")) {
|
||||||
current_keybind->command = strdup(content);
|
current_keybind->command = strdup(content);
|
||||||
|
} else if (!strcmp(nodename, "menu.action")) {
|
||||||
|
current_keybind->command = strdup(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -267,13 +267,10 @@ cursor_button(struct wl_listener *listener, void *data)
|
||||||
/* handle _press_ on desktop */
|
/* handle _press_ on desktop */
|
||||||
if (!view) {
|
if (!view) {
|
||||||
/* launch root-menu */
|
/* launch root-menu */
|
||||||
server->input_mode = LAB_INPUT_STATE_MENU;
|
action(server, "ShowMenu", "root-menu");
|
||||||
menu_move(server->rootmenu, server->seat.cursor->x,
|
|
||||||
server->seat.cursor->y);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Handle _press_ on view */
|
/* Handle _press_ on view */
|
||||||
desktop_focus_view(&server->seat, view);
|
desktop_focus_view(&server->seat, view);
|
||||||
switch (view_area) {
|
switch (view_area) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue