labwc/src/action.c

63 lines
1.5 KiB
C
Raw Normal View History

2020-09-25 19:42:40 +01:00
#include <strings.h>
2020-08-12 19:37:44 +01:00
#include "common/log.h"
#include "common/spawn.h"
2020-09-25 20:05:20 +01:00
#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);
}
2021-01-09 22:51:20 +00:00
damage_all_outputs(server);
}
2020-06-18 20:18:01 +01:00
void
action(struct server *server, const char *action, const char *command)
2020-06-18 20:18:01 +01:00
{
2020-09-25 19:37:51 +01:00
if (!action)
2020-06-18 20:18:01 +01:00
return;
if (!strcasecmp(action, "Close")) {
struct view *view = topmost_mapped_view(server);
2021-07-13 21:54:22 +01:00
if (view) {
view->impl->close(view);
}
} else if (!strcasecmp(action, "Debug")) {
/* nothing */
2020-09-25 19:42:40 +01:00
} else if (!strcasecmp(action, "Execute")) {
struct buf cmd;
buf_init(&cmd);
buf_add(&cmd, command);
buf_expand_shell_variables(&cmd);
spawn_async_no_shell(cmd.buf);
free(cmd.buf);
} else if (!strcasecmp(action, "Exit")) {
wl_display_terminate(server->wl_display);
2020-09-25 19:37:51 +01:00
} else if (!strcasecmp(action, "NextWindow")) {
server->cycle_view =
2020-10-31 14:46:33 +00:00
desktop_cycle_view(server, server->cycle_view);
2020-09-25 19:42:40 +01:00
} else if (!strcasecmp(action, "Reconfigure")) {
2020-10-21 20:30:59 +01:00
spawn_async_no_shell("killall -SIGHUP labwc");
} else if (!strcasecmp(action, "ShowMenu")) {
show_menu(server, command);
2021-07-13 21:54:22 +01:00
} else if (!strcasecmp(action, "ToggleMaximize")) {
struct view *view = topmost_mapped_view(server);
if (!view) {
return;
}
if (view->maximized) {
view_maximize(view, false);
} else {
view_maximize(view, true);
}
2020-06-18 20:18:01 +01:00
} else {
2020-09-25 19:37:51 +01:00
warn("action (%s) not supported", action);
2020-06-18 20:18:01 +01:00
}
}