]> git.mdlowis.com Git - proto/labwc.git/commitdiff
action: add "ToggleMaximize"
authorJohan Malm <jgm323@gmail.com>
Tue, 13 Jul 2021 20:54:22 +0000 (21:54 +0100)
committerJohan Malm <jgm323@gmail.com>
Tue, 13 Jul 2021 20:54:22 +0000 (21:54 +0100)
docs/labwc-actions.5.scd
src/action.c

index 2035f987803be3f2795da76c6f6686d0b6d87a6b..62b99848ca9c26df2e5307d72afede2840f07a54 100644 (file)
@@ -26,6 +26,9 @@ Actions are used in keyboard bindings.
 *<action name="ShowMenu"><menu>*
        Show menu. Valid menu name is "root-menu".
 
+*<action name="ToggleMaximize"><menu>*
+       Toggle maximize state of top-most window.
+
 # SEE ALSO
 
 labwc(1), labwc-config(5), labwc-theme(5)
index a03cdfdae978488a2a6186f6f6aaba8fc7f2cc28..a1cef98e0ccfdfa3ea7eb425f345a1bb4dba3613 100644 (file)
@@ -25,7 +25,9 @@ action(struct server *server, const char *action, const char *command)
                return;
        if (!strcasecmp(action, "Close")) {
                struct view *view = topmost_mapped_view(server);
-               view->impl->close(view);
+               if (view) {
+                       view->impl->close(view);
+               }
        } else if (!strcasecmp(action, "Debug")) {
                /* nothing */
        } 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");
        } else if (!strcasecmp(action, "ShowMenu")) {
                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 {
                warn("action (%s) not supported", action);
        }