dir=(north west south east) \
cycle_dir=(next prev)
local -a jump=($dir first second brother parent 1 2) \
- node_desc=($dir $cycle_dir last newest older newer focused pointed biggest) \
+ node_desc=($dir $cycle_dir any last newest older newer focused pointed biggest) \
node_mod=($node_state $flag $layer focused automatic local \
active leaf window same_class descendant_of ancestor_of) \
- desktop_desc=($cycle_dir last newest older newer focused) \
+ desktop_desc=($cycle_dir any last newest older newer focused) \
desktop_mod=(focused occupied local urgent) \
- monitor_desc=($dir $cycle_dir primary last newest older newer focused pointed) \
+ monitor_desc=($dir $cycle_dir any last newest older newer focused pointed primary) \
monitor_mod=(focused occupied) \
presel_dir=($dir cancel)
local quote="${compstate[quote]}" context state state_descr line
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 03/07/2018
.\" Manual: Bspwm Manual
-.\" Source: Bspwm 0.9.3-52-gf83f7ef
+.\" Source: Bspwm 0.9.3-55-g7d639d1
.\" Language: English
.\"
-.TH "BSPWM" "1" "03/07/2018" "Bspwm 0\&.9\&.3\-52\-gf83f7ef" "Bspwm Manual"
+.TH "BSPWM" "1" "03/07/2018" "Bspwm 0\&.9\&.3\-55\-g7d639d1" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.RS 4
.\}
.nf
-NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|newest|
+NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|any|last|newest|
older|newer|focused|pointed|
biggest|<node_id>)[\&.[!]focused][\&.[!]automatic][\&.[!]local][\&.[!]active]
[\&.[!]leaf][\&.[!]window][\&.[!]STATE][\&.[!]FLAG][\&.[!]LAYER]
Selects the node at the given path\&.
.RE
.PP
+any
+.RS 4
+Selects the first node that matches the given selectors\&.
+.RE
+.PP
last
.RS 4
Selects the previously focused node relative to the reference node\&.
.RS 4
.\}
.nf
-DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|last|newest|older|newer|
+DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|any|last|newest|older|newer|
[MONITOR_SEL:](focused|^<n>)|
<desktop_id>|<desktop_name>)[\&.[!]occupied][\&.[!]focused][\&.[!]urgent][\&.[!]local]
.fi
Selects the desktop in the given direction relative to the reference desktop\&.
.RE
.PP
+any
+.RS 4
+Selects the first desktop that matches the given selectors\&.
+.RE
+.PP
last
.RS 4
Selects the previously focused desktop relative to the reference desktop\&.
.RS 4
.\}
.nf
-MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|newest|older|newer|
+MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|any|last|newest|older|newer|
focused|pointed|primary|^<n>|
<monitor_id>|<monitor_name>)[\&.[!]occupied][\&.[!]focused]
.fi
Selects the monitor in the given (cyclic) direction relative to the reference monitor\&.
.RE
.PP
+any
+.RS 4
+Selects the first monitor that matches the given selectors\&.
+.RE
+.PP
last
.RS 4
Selects the previously focused monitor relative to the reference monitor\&.
Select a node.
----
-NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|last|newest|
+NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|any|last|newest|
older|newer|focused|pointed|
biggest|<node_id>)[.[!]focused][.[!]automatic][.[!]local][.[!]active]
[.[!]leaf][.[!]window][.[!]STATE][.[!]FLAG][.[!]LAYER]
'PATH'::
Selects the node at the given path.
+any::
+ Selects the first node that matches the given selectors.
+
last::
Selects the previously focused node relative to the reference node.
Select a desktop.
----
-DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|last|newest|older|newer|
+DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|any|last|newest|older|newer|
[MONITOR_SEL:](focused|^<n>)|
<desktop_id>|<desktop_name>)[.[!]occupied][.[!]focused][.[!]urgent][.[!]local]
----
'CYCLE_DIR'::
Selects the desktop in the given direction relative to the reference desktop.
+any::
+ Selects the first desktop that matches the given selectors.
+
last::
Selects the previously focused desktop relative to the reference desktop.
Select a monitor.
----
-MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|newest|older|newer|
+MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|any|last|newest|older|newer|
focused|pointed|primary|^<n>|
<monitor_id>|<monitor_name>)[.[!]occupied][.[!]focused]
----
'CYCLE_DIR'::
Selects the monitor in the given (cyclic) direction relative to the reference monitor.
+any::
+ Selects the first monitor that matches the given selectors.
+
last::
Selects the previously focused monitor relative to the reference monitor.
return false;
}
+bool find_any_desktop(coordinates_t *ref, coordinates_t *dst, desktop_select_t *sel)
+{
+ for (monitor_t *m = mon_head; m != NULL; m = m->next) {
+ for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
+ coordinates_t loc = {m, d, NULL};
+ if (desktop_matches(&loc, ref, sel)) {
+ *dst = loc;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
bool set_layout(monitor_t *m, desktop_t *d, layout_t l)
{
if (d->layout == l) {
void focus_desktop(monitor_t *m, desktop_t *d);
bool activate_desktop(monitor_t *m, desktop_t *d);
bool find_closest_desktop(coordinates_t *ref, coordinates_t *dst, cycle_dir_t dir, desktop_select_t *sel);
+bool find_any_desktop(coordinates_t *ref, coordinates_t *dst, desktop_select_t *sel);
bool set_layout(monitor_t *m, desktop_t *d, layout_t l);
void handle_presel_feedbacks(monitor_t *m, desktop_t *d);
bool transfer_desktop(monitor_t *ms, monitor_t *md, desktop_t *d, bool follow);
return nearest;
}
+bool find_any_monitor(coordinates_t *ref, coordinates_t *dst, monitor_select_t *sel)
+{
+ for (monitor_t *m = mon_head; m != NULL; m = m->next) {
+ coordinates_t loc = {m, NULL, NULL};
+ if (monitor_matches(&loc, ref, sel)) {
+ *dst = loc;
+ return true;
+ }
+ }
+ return false;
+}
+
bool update_monitors(void)
{
xcb_randr_get_screen_resources_reply_t *sres = xcb_randr_get_screen_resources_reply(dpy, xcb_randr_get_screen_resources(dpy, root), NULL);
monitor_t *monitor_from_point(xcb_point_t pt);
monitor_t *monitor_from_client(client_t *c);
monitor_t *nearest_monitor(monitor_t *m, direction_t dir, monitor_select_t *sel);
+bool find_any_monitor(coordinates_t *ref, coordinates_t *dst, monitor_select_t *sel);
bool update_monitors(void);
#endif
find_closest_node(ref, dst, cyc, &sel);
} else if (parse_history_direction(desc, &hdi)) {
history_find_node(hdi, ref, dst, &sel);
+ } else if (streq("any", desc)) {
+ find_any_node(ref, dst, &sel);
} else if (streq("last", desc)) {
history_find_node(HISTORY_OLDER, ref, dst, &sel);
} else if (streq("newest", desc)) {
find_closest_desktop(ref, dst, cyc, &sel);
} else if (parse_history_direction(desc, &hdi)) {
history_find_desktop(hdi, ref, dst, &sel);
+ } else if (streq("any", desc)) {
+ find_any_desktop(ref, dst, &sel);
} else if (streq("last", desc)) {
history_find_desktop(HISTORY_OLDER, ref, dst, &sel);
} else if (streq("newest", desc)) {
dst->monitor = closest_monitor(ref->monitor, cyc, &sel);
} else if (parse_history_direction(desc, &hdi)) {
history_find_monitor(hdi, ref, dst, &sel);
+ } else if (streq("any", desc)) {
+ find_any_monitor(ref, dst, &sel);
} else if (streq("last", desc)) {
history_find_monitor(HISTORY_OLDER, ref, dst, &sel);
} else if (streq("newest", desc)) {
}
}
+void find_any_node(coordinates_t *ref, coordinates_t *dst, node_select_t *sel)
+{
+ for (monitor_t *m = mon_head; m != NULL; m = m->next) {
+ for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
+ if (find_any_node_in(m, d, d->root, ref, dst, sel)) {
+ return;
+ }
+ }
+ }
+}
+
+bool find_any_node_in(monitor_t *m, desktop_t *d, node_t *n, coordinates_t *ref, coordinates_t *dst, node_select_t *sel)
+{
+ if (n == NULL) {
+ return false;
+ } else {
+ coordinates_t loc = {m, d, n};
+ if (node_matches(&loc, ref, sel)) {
+ *dst = loc;
+ return true;
+ } else {
+ if (find_any_node_in(m, d, n->first_child, ref, dst, sel)) {
+ return true;
+ } else {
+ return find_any_node_in(m, d, n->second_child, ref, dst, sel);
+ }
+ }
+ }
+}
+
/* Based on https://github.com/ntrrgc/right-window */
void find_nearest_neighbor(coordinates_t *ref, coordinates_t *dst, direction_t dir, node_select_t *sel)
{
bool is_descendant(node_t *a, node_t *b);
bool find_by_id(uint32_t id, coordinates_t *loc);
node_t *find_by_id_in(node_t *r, uint32_t id);
+void find_any_node(coordinates_t *ref, coordinates_t *dst, node_select_t *sel);
+bool find_any_node_in(monitor_t *m, desktop_t *d, node_t *n, coordinates_t *ref, coordinates_t *dst, node_select_t *sel);
void find_nearest_neighbor(coordinates_t *ref, coordinates_t *dst, direction_t dir, node_select_t *sel);
unsigned int node_area(desktop_t *d, node_t *n);
int tiled_count(node_t *n);