Add a special raw name selector

Fixes #704.
This commit is contained in:
Bastien Dejean 2017-09-08 21:23:53 +02:00
parent 412da35b73
commit 614a56b753
3 changed files with 41 additions and 9 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: 08/22/2017
.\" Date: 09/08/2017
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.9.3-22-g7091d65
.\" Source: Bspwm 0.9.3-26-g412da35
.\" Language: English
.\"
.TH "BSPWM" "1" "08/22/2017" "Bspwm 0\&.9\&.3\-22\-g7091d65" "Bspwm Manual"
.TH "BSPWM" "1" "09/08/2017" "Bspwm 0\&.9\&.3\-26\-g412da35" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -90,6 +90,8 @@ The relative targets are computed in relation to the given reference (the defaul
An exclamation mark can be prepended to any modifier in order to reverse its meaning\&.
.sp
The following characters cannot be used in monitor or desktop names: \fB#\fR, \fB:\fR, \fB\&.\fR\&.
.sp
The special selector \fB%<name>\fR can be used to select a monitor or a desktop with an invalid name\&.
.SS "Node"
.sp
Select a node\&.
@ -98,7 +100,11 @@ Select a node\&.
.RS 4
.\}
.nf
NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|older|newer|focused|pointed|biggest|<node_id>)[\&.[!]focused][\&.[!]automatic][\&.[!]local][\&.[!]active][\&.[!]leaf][\&.[!]window][\&.[!]STATE][\&.[!]FLAG][\&.[!]LAYER][\&.[!]same_class][\&.[!]descendant_of][\&.[!]ancestor_of]
NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|
older|newer|focused|pointed|
biggest|<node_id>)[\&.[!]focused][\&.[!]automatic][\&.[!]local][\&.[!]active]
[\&.[!]leaf][\&.[!]window][\&.[!]STATE][\&.[!]FLAG][\&.[!]LAYER]
[\&.[!]same_class][\&.[!]descendant_of][\&.[!]ancestor_of]
STATE := tiled|pseudo_tiled|floating|fullscreen
@ -291,7 +297,9 @@ Select a desktop\&.
.RS 4
.\}
.nf
DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|last|older|newer|[MONITOR_SEL:](focused|^<n>)|<desktop_id>|<desktop_name>)[\&.[!]occupied][\&.[!]focused][\&.[!]urgent][\&.[!]local]
DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|last|older|newer|
[MONITOR_SEL:](focused|^<n>)|
<desktop_id>|<desktop_name>)[\&.[!]occupied][\&.[!]focused][\&.[!]urgent][\&.[!]local]
.fi
.if n \{\
.RE
@ -384,7 +392,9 @@ Select a monitor\&.
.RS 4
.\}
.nf
MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|older|newer|focused|pointed|primary|^<n>|<monitor_id>|<monitor_name>)[\&.[!]occupied][\&.[!]focused]
MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|older|newer|
focused|pointed|primary|^<n>|
<monitor_id>|<monitor_name>)[\&.[!]occupied][\&.[!]focused]
.fi
.if n \{\
.RE

View file

@ -66,13 +66,19 @@ meaning.
The following characters cannot be used in monitor or desktop names: *#*, *:*, *.*.
The special selector *%<name>* can be used to select a monitor or a desktop with an invalid name.
Node
~~~~
Select a node.
----
NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|older|newer|focused|pointed|biggest|<node_id>)[.[!]focused][.[!]automatic][.[!]local][.[!]active][.[!]leaf][.[!]window][.[!]STATE][.[!]FLAG][.[!]LAYER][.[!]same_class][.[!]descendant_of][.[!]ancestor_of]
NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|
older|newer|focused|pointed|
biggest|<node_id>)[.[!]focused][.[!]automatic][.[!]local][.[!]active]
[.[!]leaf][.[!]window][.[!]STATE][.[!]FLAG][.[!]LAYER]
[.[!]same_class][.[!]descendant_of][.[!]ancestor_of]
STATE := tiled|pseudo_tiled|floating|fullscreen
@ -183,7 +189,9 @@ Desktop
Select a desktop.
----
DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|last|older|newer|[MONITOR_SEL:](focused|^<n>)|<desktop_id>|<desktop_name>)[.[!]occupied][.[!]focused][.[!]urgent][.[!]local]
DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|last|older|newer|
[MONITOR_SEL:](focused|^<n>)|
<desktop_id>|<desktop_name>)[.[!]occupied][.[!]focused][.[!]urgent][.[!]local]
----
Descriptors
@ -234,7 +242,9 @@ Monitor
Select a monitor.
----
MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|older|newer|focused|pointed|primary|^<n>|<monitor_id>|<monitor_name>)[.[!]occupied][.[!]focused]
MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|older|newer|
focused|pointed|primary|^<n>|
<monitor_id>|<monitor_name>)[.[!]occupied][.[!]focused]
----
Descriptors

View file

@ -571,6 +571,11 @@ int node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
{
if (*desc == '%') {
locate_desktop(desc + 1, dst);
goto end;
}
coordinates_t ref_copy = *ref;
ref = &ref_copy;
char *desc_copy = copy_string(desc, strlen(desc));
@ -670,6 +675,7 @@ int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
free(desc_copy);
end:
if (dst->desktop == NULL) {
return SELECTOR_INVALID;
}
@ -679,6 +685,11 @@ int desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
int monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
{
if (*desc == '%') {
locate_monitor(desc + 1, dst);
goto end;
}
coordinates_t ref_copy = *ref;
ref = &ref_copy;
char *desc_copy = copy_string(desc, strlen(desc));
@ -771,6 +782,7 @@ int monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
free(desc_copy);
end:
if (dst->monitor == NULL) {
return SELECTOR_INVALID;
}