From: Emanuele Torre Date: Sun, 31 Jan 2021 17:28:49 +0000 (+0100) Subject: Restore the last window state with `node -t ~` X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=e908026fe345e17e8310f0eb4ff8c3b93e71a367;p=bspwm.git Restore the last window state with `node -t ~` Closes #1253. --- diff --git a/doc/bspwm.1 b/doc/bspwm.1 index e798b23..fa14977 100644 --- a/doc/bspwm.1 +++ b/doc/bspwm.1 @@ -2,12 +2,12 @@ .\" Title: bspwm .\" Author: [see the "Author" section] .\" Generator: DocBook XSL Stylesheets vsnapshot -.\" Date: 12/24/2020 +.\" Date: 05/28/2021 .\" Manual: Bspwm Manual -.\" Source: Bspwm 0.9.10-18-g87822b5 +.\" Source: Bspwm 0.9.10-25-g94c3c69 .\" Language: English .\" -.TH "BSPWM" "1" "12/24/2020" "Bspwm 0\&.9\&.10\-18\-g87822b5" "Bspwm Manual" +.TH "BSPWM" "1" "05/28/2021" "Bspwm 0\&.9\&.10\-25\-g94c3c69" "Bspwm Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -738,11 +738,16 @@ Adjust the split ratios of the tree rooted at the selected node so that all wind Circulate the windows of the tree rooted at the selected node\&. .RE .PP -\fB\-t\fR, \fB\-\-state\fR [~](tiled|pseudo_tiled|floating|fullscreen) +\fB\-t\fR, \fB\-\-state\fR ~|[~]\fISTATE\fR .RS 4 Set the state of the selected window\&. If \fB~\fR -is present and the current state matches the given state, then the argument is interpreted as the last state\&. +is present and the current state matches +\fISTATE\fR, then the argument is interpreted as its last state\&. If the argument is just +\fB~\fR +with +\fISTATE\fR +omitted, then the state of the selected window is set to its last state\&. .RE .PP \fB\-g\fR, \fB\-\-flag\fR hidden|sticky|private|locked|marked[=on|off] diff --git a/doc/bspwm.1.asciidoc b/doc/bspwm.1.asciidoc index ca504c2..b5413ea 100644 --- a/doc/bspwm.1.asciidoc +++ b/doc/bspwm.1.asciidoc @@ -452,8 +452,8 @@ Commands *-C*, *--circulate* forward|backward:: Circulate the windows of the tree rooted at the selected node. -*-t*, *--state* [~](tiled|pseudo_tiled|floating|fullscreen):: - Set the state of the selected window. If *~* is present and the current state matches the given state, then the argument is interpreted as the last state. +*-t*, *--state* \~|\[~]'STATE':: + Set the state of the selected window. If *\~* is present and the current state matches 'STATE', then the argument is interpreted as its last state. If the argument is just *~* with 'STATE' omitted, then the state of the selected window is set to its last state. *-g*, *--flag* hidden|sticky|private|locked|marked[=on|off]:: Set or toggle the given flag for the selected node. diff --git a/src/messages.c b/src/messages.c index d385259..5b6e608 100644 --- a/src/messages.c +++ b/src/messages.c @@ -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) {