Add wm command: --reorder-monitors

This commit is contained in:
Bastien Dejean 2017-07-30 14:48:03 +02:00
parent a4c5b29212
commit b4c470784d
3 changed files with 30 additions and 3 deletions

View file

@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 07/25/2017
.\" Date: 07/30/2017
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.9.3-14-gefec936
.\" Source: Bspwm 0.9.3-16-ga4c5b29
.\" Language: English
.\"
.TH "BSPWM" "1" "07/25/2017" "Bspwm 0\&.9\&.3\-14\-gefec936" "Bspwm Manual"
.TH "BSPWM" "1" "07/30/2017" "Bspwm 0\&.9\&.3\-16\-ga4c5b29" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -900,6 +900,11 @@ Load a world state from the given file\&.
Add a monitor for the given name and rectangle\&.
.RE
.PP
\fB\-O\fR, \fB\-\-reorder\-monitors\fR <name>\&...
.RS 4
Reorder the list of monitors to match the given order\&.
.RE
.PP
\fB\-o\fR, \fB\-\-adopt\-orphans\fR
.RS 4
Manage all the unmanaged windows remaining from a previous session\&.

View file

@ -531,6 +531,9 @@ Commands
*-a*, *--add-monitor* <name> WxH+X+Y::
Add a monitor for the given name and rectangle.
*-O*, *--reorder-monitors* <name>...::
Reorder the list of monitors to match the given order.
*-o*, *--adopt-orphans*::
Manage all the unmanaged windows remaining from a previous session.

View file

@ -1190,6 +1190,25 @@ void cmd_wm(char **args, int num, FILE *rsp)
fail(rsp, "wm %s: Invalid argument: '%s'.\n", *(args - 1), *args);
break;
}
} else if (streq("-O", *args) || streq("--reorder-monitors", *args)) {
num--, args++;
if (num < 1) {
fail(rsp, "wm %s: Not enough arguments.\n", *(args - 1));
return;
}
monitor_t *m = mon_head;
while (m != NULL && num > 0) {
monitor_t *next = m->next;
coordinates_t dst;
if (locate_monitor(*args, &dst)) {
swap_monitors(m, dst.monitor);
if (next == dst.monitor) {
next = m;
}
}
m = next;
num--, args++;
}
} else if (streq("-o", *args) || streq("--adopt-orphans", *args)) {
adopt_orphans();
} else if (streq("-g", *args) || streq("--get-status", *args)) {