Skip to content

Commit

Permalink
Make the focused and active modifiers coherent
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville committed Dec 14, 2018
1 parent 93c6de1 commit a94093b
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 64 deletions.
70 changes: 38 additions & 32 deletions doc/bspwm.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 12/12/2018
.\" Date: 12/14/2018
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.9.5-24-g0f5a69b
.\" Source: Bspwm 0.9.5-25-g93c6de1
.\" Language: English
.\"
.TH "BSPWM" "1" "12/12/2018" "Bspwm 0\&.9\&.5\-24\-g0f5a69b" "Bspwm Manual"
.TH "BSPWM" "1" "12/14/2018" "Bspwm 0\&.9\&.5\-25\-g93c6de1" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -102,7 +102,7 @@ Select a node\&.
.nf
NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|any|last|newest|
older|newer|focused|pointed|biggest|smallest|
<node_id>)[\&.[!]focused][\&.[!]automatic][\&.[!]local][\&.[!]active]
<node_id>)[\&.[!]focused][\&.[!]active][\&.[!]automatic][\&.[!]local]
[\&.[!]leaf][\&.[!]window][\&.[!]STATE][\&.[!]FLAG][\&.[!]LAYER]
[\&.[!]same_class][\&.[!]descendant_of][\&.[!]ancestor_of]

Expand Down Expand Up @@ -240,12 +240,17 @@ Jumps to the node holding the edge in the given direction\&.
.PP
[!]focused
.RS 4
Only consider focused or unfocused nodes\&.
Only consider the focused node\&.
.RE
.PP
[!]active
.RS 4
Only consider nodes that are the focused node of their desktop\&.
.RE
.PP
[!]automatic
.RS 4
Only consider nodes in automatic or manual insertion mode\&. See also
Only consider nodes in automatic insertion mode\&. See also
\fB\-\-presel\-dir\fR
under
\fBNode\fR
Expand All @@ -256,52 +261,47 @@ section below\&.
.PP
[!]local
.RS 4
Only consider nodes in or not in the reference desktop\&.
.RE
.PP
[!]active
.RS 4
Only consider nodes in or not in the active desktop of their monitor\&.
Only consider nodes in the reference desktop\&.
.RE
.PP
[!]leaf
.RS 4
Only consider leaves or internal nodes\&.
Only consider leaf nodes\&.
.RE
.PP
[!]window
.RS 4
Only consider nodes that hold or don\(cqt hold a window\&.
Only consider nodes that hold a window\&.
.RE
.PP
[!](tiled|pseudo_tiled|floating|fullscreen)
.RS 4
Only consider windows in or not in the given state\&.
Only consider windows in the given state\&.
.RE
.PP
[!]same_class
.RS 4
Only consider windows that have or don\(cqt have the same class as the reference window\&.
Only consider windows that have the same class as the reference window\&.
.RE
.PP
[!]descendant_of
.RS 4
Only consider nodes that are or aren\(cqt descendants of the reference node\&.
Only consider nodes that are descendants of the reference node\&.
.RE
.PP
[!]ancestor_of
.RS 4
Only consider nodes that are or aren\(cqt ancestors of the reference node\&.
Only consider nodes that are ancestors of the reference node\&.
.RE
.PP
[!](hidden|sticky|private|locked|marked|urgent)
.RS 4
Only consider windows that have or don\(cqt have the given flag set\&.
Only consider windows that have the given flag set\&.
.RE
.PP
[!](below|normal|above)
.RS 4
Only consider windows in or not in the given layer\&.
Only consider windows in the given layer\&.
.RE
.RE
.SS "Desktop"
Expand All @@ -314,7 +314,8 @@ Select a desktop\&.
.nf
DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|any|last|newest|older|newer|
[MONITOR_SEL:](focused|^<n>)|
<desktop_id>|<desktop_name>)[\&.[!]occupied][\&.[!]focused][\&.[!]urgent][\&.[!]local]
<desktop_id>|<desktop_name>)[\&.[!]focused][\&.[!]active]
[\&.[!]occupied][\&.[!]urgent][\&.[!]local]
.fi
.if n \{\
.RE
Expand Down Expand Up @@ -389,24 +390,29 @@ Selects the desktop with the given name\&.
\fBModifiers\fR
.RS 4
.PP
[!]occupied
[!]focused
.RS 4
Only consider occupied or free desktops\&.
Only consider the focused desktop\&.
.RE
.PP
[!]focused
[!]active
.RS 4
Only consider desktops that are the focused desktop of their monitor\&.
.RE
.PP
[!]occupied
.RS 4
Only consider focused or unfocused desktops\&.
Only consider occupied desktops\&.
.RE
.PP
[!]urgent
.RS 4
Only consider urgent or non urgent desktops\&.
Only consider urgent desktops\&.
.RE
.PP
[!]local
.RS 4
Only consider desktops inside or outside of the reference monitor\&.
Only consider desktops inside the reference monitor\&.
.RE
.RE
.SS "Monitor"
Expand All @@ -419,7 +425,7 @@ Select a monitor\&.
.nf
MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|any|last|newest|older|newer|
focused|pointed|primary|^<n>|
<monitor_id>|<monitor_name>)[\&.[!]occupied][\&.[!]focused]
<monitor_id>|<monitor_name>)[\&.[!]focused][\&.[!]occupied]
.fi
.if n \{\
.RE
Expand Down Expand Up @@ -507,14 +513,14 @@ Selects the monitor with the given name\&.
\fBModifiers\fR
.RS 4
.PP
[!]occupied
[!]focused
.RS 4
Only consider monitors where the focused desktop is occupied or free\&.
Only consider the focused monitor\&.
.RE
.PP
[!]focused
[!]occupied
.RS 4
Only consider focused or unfocused monitors\&.
Only consider monitors where the focused desktop is occupied\&.
.RE
.RE
.SH "WINDOW STATES"
Expand Down
59 changes: 33 additions & 26 deletions doc/bspwm.1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Select a node.
----
NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|any|last|newest|
older|newer|focused|pointed|biggest|smallest|
<node_id>)[.[!]focused][.[!]automatic][.[!]local][.[!]active]
<node_id>)[.[!]focused][.[!]active][.[!]automatic][.[!]local]
[.[!]leaf][.[!]window][.[!]STATE][.[!]FLAG][.[!]LAYER]
[.[!]same_class][.[!]descendant_of][.[!]ancestor_of]
Expand Down Expand Up @@ -156,41 +156,43 @@ parent::
Modifiers
^^^^^^^^^



[!]focused::
Only consider focused or unfocused nodes.
Only consider the focused node.

[!]active::
Only consider nodes that are the focused node of their desktop.

[!]automatic::
Only consider nodes in automatic or manual insertion mode. See also *--presel-dir* under *Node* in the *DOMAINS* section below.
Only consider nodes in automatic insertion mode. See also *--presel-dir* under *Node* in the *DOMAINS* section below.

[!]local::
Only consider nodes in or not in the reference desktop.

[!]active::
Only consider nodes in or not in the active desktop of their monitor.
Only consider nodes in the reference desktop.

[!]leaf::
Only consider leaves or internal nodes.
Only consider leaf nodes.

[!]window::
Only consider nodes that hold or don't hold a window.
Only consider nodes that hold a window.

[!](tiled|pseudo_tiled|floating|fullscreen)::
Only consider windows in or not in the given state.
Only consider windows in the given state.

[!]same_class::
Only consider windows that have or don't have the same class as the reference window.
Only consider windows that have the same class as the reference window.

[!]descendant_of::
Only consider nodes that are or aren't descendants of the reference node.
Only consider nodes that are descendants of the reference node.

[!]ancestor_of::
Only consider nodes that are or aren't ancestors of the reference node.
Only consider nodes that are ancestors of the reference node.

[!](hidden|sticky|private|locked|marked|urgent)::
Only consider windows that have or don't have the given flag set.
Only consider windows that have the given flag set.

[!](below|normal|above)::
Only consider windows in or not in the given layer.
Only consider windows in the given layer.

Desktop
~~~~~~~
Expand All @@ -200,7 +202,8 @@ Select a desktop.
----
DESKTOP_SEL := [DESKTOP_SEL#](CYCLE_DIR|any|last|newest|older|newer|
[MONITOR_SEL:](focused|^<n>)|
<desktop_id>|<desktop_name>)[.[!]occupied][.[!]focused][.[!]urgent][.[!]local]
<desktop_id>|<desktop_name>)[.[!]focused][.[!]active]
[.[!]occupied][.[!]urgent][.[!]local]
----

Descriptors
Expand Down Expand Up @@ -239,17 +242,20 @@ focused::
Modifiers
^^^^^^^^^

[!]occupied::
Only consider occupied or free desktops.

[!]focused::
Only consider focused or unfocused desktops.
Only consider the focused desktop.

[!]active::
Only consider desktops that are the focused desktop of their monitor.

[!]occupied::
Only consider occupied desktops.

[!]urgent::
Only consider urgent or non urgent desktops.
Only consider urgent desktops.

[!]local::
Only consider desktops inside or outside of the reference monitor.
Only consider desktops inside the reference monitor.

Monitor
~~~~~~~
Expand All @@ -259,7 +265,7 @@ Select a monitor.
----
MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|any|last|newest|older|newer|
focused|pointed|primary|^<n>|
<monitor_id>|<monitor_name>)[.[!]occupied][.[!]focused]
<monitor_id>|<monitor_name>)[.[!]focused][.[!]occupied]
----

Descriptors
Expand Down Expand Up @@ -308,11 +314,12 @@ primary::
Modifiers
^^^^^^^^^

[!]focused::
Only consider the focused monitor.

[!]occupied::
Only consider monitors where the focused desktop is occupied or free.
Only consider monitors where the focused desktop is occupied.

[!]focused::
Only consider focused or unfocused monitors.


Window States
Expand Down
3 changes: 2 additions & 1 deletion src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ bool parse_desktop_modifiers(char *desc, desktop_select_t *sel)
} else if (streq("!occupied", tok)) {
sel->occupied = OPTION_FALSE;
GET_MOD(focused)
GET_MOD(active)
GET_MOD(urgent)
GET_MOD(local)
} else {
Expand All @@ -522,8 +523,8 @@ bool parse_node_modifiers(char *desc, node_select_t *sel)
sel->tiled = OPTION_FALSE;
GET_MOD(automatic)
GET_MOD(focused)
GET_MOD(local)
GET_MOD(active)
GET_MOD(local)
GET_MOD(leaf)
GET_MOD(window)
GET_MOD(pseudo_tiled)
Expand Down
23 changes: 19 additions & 4 deletions src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ node_select_t make_node_select(void)
node_select_t sel = {
.automatic = OPTION_NONE,
.focused = OPTION_NONE,
.local = OPTION_NONE,
.active = OPTION_NONE,
.local = OPTION_NONE,
.leaf = OPTION_NONE,
.window = OPTION_NONE,
.tiled = OPTION_NONE,
Expand Down Expand Up @@ -459,6 +459,7 @@ desktop_select_t make_desktop_select(void)
desktop_select_t sel = {
.occupied = OPTION_NONE,
.focused = OPTION_NONE,
.active = OPTION_NONE,
.urgent = OPTION_NONE,
.local = OPTION_NONE
};
Expand Down Expand Up @@ -984,12 +985,19 @@ bool node_matches(coordinates_t *loc, coordinates_t *ref, node_select_t *sel)
}

if (sel->focused != OPTION_NONE &&
loc->node != loc->desktop->focus
loc->node != mon->desk->focus
? sel->focused == OPTION_TRUE
: sel->focused == OPTION_FALSE) {
return false;
}

if (sel->active != OPTION_NONE &&
loc->node != loc->desktop->focus
? sel->active == OPTION_TRUE
: sel->active == OPTION_FALSE) {
return false;
}

if (sel->automatic != OPTION_NONE &&
loc->node->presel != NULL
? sel->automatic == OPTION_TRUE
Expand Down Expand Up @@ -1122,12 +1130,19 @@ bool desktop_matches(coordinates_t *loc, coordinates_t *ref, desktop_select_t *s
}

if (sel->focused != OPTION_NONE &&
loc->desktop != loc->monitor->desk
loc->desktop != mon->desk
? sel->focused == OPTION_TRUE
: sel->focused == OPTION_FALSE) {
return false;
}

if (sel->active != OPTION_NONE &&
loc->desktop != loc->monitor->desk
? sel->active == OPTION_TRUE
: sel->active == OPTION_FALSE) {
return false;
}

if (sel->urgent != OPTION_NONE &&
!is_urgent(loc->desktop)
? sel->urgent == OPTION_TRUE
Expand Down Expand Up @@ -1155,7 +1170,7 @@ bool monitor_matches(coordinates_t *loc, __attribute__((unused)) coordinates_t *
}

if (sel->focused != OPTION_NONE &&
mon != loc->monitor
loc->monitor != mon
? sel->focused == OPTION_TRUE
: sel->focused == OPTION_FALSE) {
return false;
Expand Down
Loading

0 comments on commit a94093b

Please sign in to comment.