action: add "ToggleMaximize"

This commit is contained in:
Johan Malm 2021-07-13 21:54:22 +01:00
parent 69f0f68cc2
commit c668fd9b07
2 changed files with 16 additions and 1 deletions

View file

@ -26,6 +26,9 @@ Actions are used in keyboard bindings.
*<action name="ShowMenu"><menu>* *<action name="ShowMenu"><menu>*
Show menu. Valid menu name is "root-menu". Show menu. Valid menu name is "root-menu".
*<action name="ToggleMaximize"><menu>*
Toggle maximize state of top-most window.
# SEE ALSO # SEE ALSO
labwc(1), labwc-config(5), labwc-theme(5) labwc(1), labwc-config(5), labwc-theme(5)

View file

@ -25,7 +25,9 @@ action(struct server *server, const char *action, const char *command)
return; return;
if (!strcasecmp(action, "Close")) { if (!strcasecmp(action, "Close")) {
struct view *view = topmost_mapped_view(server); struct view *view = topmost_mapped_view(server);
view->impl->close(view); if (view) {
view->impl->close(view);
}
} else if (!strcasecmp(action, "Debug")) { } else if (!strcasecmp(action, "Debug")) {
/* nothing */ /* nothing */
} else if (!strcasecmp(action, "Execute")) { } else if (!strcasecmp(action, "Execute")) {
@ -44,6 +46,16 @@ action(struct server *server, const char *action, const char *command)
spawn_async_no_shell("killall -SIGHUP labwc"); spawn_async_no_shell("killall -SIGHUP labwc");
} else if (!strcasecmp(action, "ShowMenu")) { } else if (!strcasecmp(action, "ShowMenu")) {
show_menu(server, command); show_menu(server, command);
} 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);
}
} else { } else {
warn("action (%s) not supported", action); warn("action (%s) not supported", action);
} }