]> git.lizzy.rs Git - bspwm.git/blobdiff - src/messages.c
Restore the last window state with `node -t ~`
[bspwm.git] / src / messages.c
index d3852594bf1872ee7c6c97a690323bd37f5b3859..5b6e608ac7c2da96fe6da06f29eb173a6cdd4155 100644 (file)
@@ -296,20 +296,27 @@ void cmd_node(char **args, int num, FILE *rsp)
                                alternate = true;
                                (*args)++;
                        }
-                       if (parse_client_state(*args, &cst)) {
-                               if (alternate && trg.node != NULL && trg.node->client != NULL &&
-                                   trg.node->client->state == cst) {
+                       if (alternate && (*args)[0] == '\0') {
+                               if (trg.node != NULL && trg.node->client != NULL) {
                                        cst = trg.node->client->last_state;
-                               }
-                               if (!set_state(trg.monitor, trg.desktop, trg.node, cst)) {
+                               } else {
                                        fail(rsp, "");
                                        break;
                                }
-                               changed = true;
+                       } else if (parse_client_state(*args, &cst)) {
+                               if (alternate && trg.node != NULL && trg.node->client != NULL &&
+                                   trg.node->client->state == cst) {
+                                       cst = trg.node->client->last_state;
+                               }
                        } else {
                                fail(rsp, "node %s: Invalid argument: '%s'.\n", *(args - 1), *args);
                                break;
                        }
+                       if (!set_state(trg.monitor, trg.desktop, trg.node, cst)) {
+                               fail(rsp, "");
+                               break;
+                       }
+                       changed = true;
                } else if (streq("-g", *args) || streq("--flag", *args)) {
                        num--, args++;
                        if (num < 1) {