Skip to content

Commit

Permalink
Add new selector modifiers: urgent and nonurgent
Browse files Browse the repository at this point in the history
  • Loading branch information
baskerville committed Jul 19, 2013
1 parent 229c351 commit 7606b0b
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 21 deletions.
16 changes: 14 additions & 2 deletions README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Select a window.

----
WINDOW_SEL := <window_id>
| (DIR|CYCLE_DIR|biggest|last|focused)[.floating|.tiled][.like|.unlike]
| (DIR|CYCLE_DIR|biggest|last|focused)[.floating|.tiled][.like|.unlike][.urgent|.nonurgent]
----

Primary Selectors
Expand Down Expand Up @@ -183,14 +183,20 @@ automatic::
manual::
Only consider windows in manual splitting mode (see *--presel*).

urgent::
Only consider urgent windows.

nonurgent::
Only consider nonurgent windows.

Desktop
~~~~~~~

Select a desktop.

----
DESKTOP_SEL := <desktop_name>
| (CYCLE_DIR|last|focused)[.occupied|.free]
| (CYCLE_DIR|last|focused)[.occupied|.free][.urgent|.nonurgent]
----

Primary Selectors
Expand All @@ -214,6 +220,12 @@ occupied::
free::
Only consider free desktops.

urgent::
Only consider urgent desktops.

nonurgent::
Only consider nonurgent desktops.

Monitor
~~~~~~~

Expand Down
28 changes: 24 additions & 4 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.78.1 <http://docbook.sf.net/>
.\" Date: 07/16/2013
.\" Date: 07/19/2013
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.7
.\" Language: English
.\"
.TH "BSPWM" "1" "07/16/2013" "Bspwm 0\&.7" "Bspwm Manual"
.TH "BSPWM" "1" "07/19/2013" "Bspwm 0\&.7" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -174,7 +174,7 @@ Select a window\&.
.\}
.nf
WINDOW_SEL := <window_id>
| (DIR|CYCLE_DIR|biggest|last|focused)[\&.floating|\&.tiled][\&.like|\&.unlike]
| (DIR|CYCLE_DIR|biggest|last|focused)[\&.floating|\&.tiled][\&.like|\&.unlike][\&.urgent|\&.nonurgent]
.fi
.if n \{\
.RE
Expand Down Expand Up @@ -252,6 +252,16 @@ manual
Only consider windows in manual splitting mode (see
\fB\-\-presel\fR)\&.
.RE
.PP
urgent
.RS 4
Only consider urgent windows\&.
.RE
.PP
nonurgent
.RS 4
Only consider nonurgent windows\&.
.RE
.RE
.SS "Desktop"
.sp
Expand All @@ -262,7 +272,7 @@ Select a desktop\&.
.\}
.nf
DESKTOP_SEL := <desktop_name>
| (CYCLE_DIR|last|focused)[\&.occupied|\&.free]
| (CYCLE_DIR|last|focused)[\&.occupied|\&.free][\&.urgent|\&.nonurgent]
.fi
.if n \{\
.RE
Expand Down Expand Up @@ -309,6 +319,16 @@ free
.RS 4
Only consider free desktops\&.
.RE
.PP
urgent
.RS 4
Only consider urgent desktops\&.
.RE
.PP
nonurgent
.RS 4
Only consider nonurgent desktops\&.
.RE
.RE
.SS "Monitor"
.sp
Expand Down
16 changes: 14 additions & 2 deletions doc/bspwm.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Select a window.

----
WINDOW_SEL := <window_id>
| (DIR|CYCLE_DIR|biggest|last|focused)[.floating|.tiled][.like|.unlike]
| (DIR|CYCLE_DIR|biggest|last|focused)[.floating|.tiled][.like|.unlike][.urgent|.nonurgent]
----

Primary Selectors
Expand Down Expand Up @@ -181,14 +181,20 @@ automatic::
manual::
Only consider windows in manual splitting mode (see *--presel*).

urgent::
Only consider urgent windows.

nonurgent::
Only consider nonurgent windows.

Desktop
~~~~~~~

Select a desktop.

----
DESKTOP_SEL := <desktop_name>
| (CYCLE_DIR|last|focused)[.occupied|.free]
| (CYCLE_DIR|last|focused)[.occupied|.free][.urgent|.nonurgent]
----

Primary Selectors
Expand All @@ -212,6 +218,12 @@ occupied::
free::
Only consider free desktops.

urgent::
Only consider urgent desktops.

nonurgent::
Only consider nonurgent desktops.

Monitor
~~~~~~~

Expand Down
23 changes: 17 additions & 6 deletions query.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
sel.type = CLIENT_TYPE_ALL;
sel.class = CLIENT_CLASS_ALL;
sel.mode = CLIENT_MODE_ALL;
sel.urgency = CLIENT_URGENCY_ALL;
char *tok;
while ((tok = strrchr(desc, CAT_CHR)) != NULL) {
tok[0] = '\0';
Expand All @@ -145,6 +146,10 @@ bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
sel.mode = CLIENT_MODE_AUTOMATIC;
} else if (streq("manual", tok)) {
sel.mode = CLIENT_MODE_MANUAL;
} else if (streq("urgent", tok)) {
sel.urgency = CLIENT_URGENCY_ON;
} else if (streq("nonurgent", tok)) {
sel.urgency = CLIENT_URGENCY_OFF;
}
}

Expand Down Expand Up @@ -183,15 +188,20 @@ bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
bool desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
{
desktop_select_t sel;
sel = DESKTOP_ALL;
sel.status = DESKTOP_STATUS_ALL;
sel.urgency = DESKTOP_URGENCY_ALL;
char *tok;
while ((tok = strrchr(desc, CAT_CHR)) != NULL) {
tok[0] = '\0';
tok++;
if (streq("free", tok)) {
sel = DESKTOP_FREE;
sel.status = DESKTOP_STATUS_FREE;
} else if (streq("occupied", tok)) {
sel = DESKTOP_OCCUPIED;
sel.status = DESKTOP_STATUS_OCCUPIED;
} else if (streq("urgent", tok)) {
sel.urgency = DESKTOP_URGENCY_ON;
} else if (streq("nonurgent", tok)) {
sel.urgency = DESKTOP_URGENCY_OFF;
}
}

Expand Down Expand Up @@ -221,15 +231,16 @@ bool desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
bool monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
{
desktop_select_t sel;
sel = DESKTOP_ALL;
sel.status = DESKTOP_STATUS_ALL;
sel.urgency = DESKTOP_URGENCY_ALL;
char *tok;
while ((tok = strrchr(desc, CAT_CHR)) != NULL) {
tok[0] = '\0';
tok++;
if (streq("free", tok)) {
sel = DESKTOP_FREE;
sel.status = DESKTOP_STATUS_FREE;
} else if (streq("occupied", tok)) {
sel = DESKTOP_OCCUPIED;
sel.status = DESKTOP_STATUS_OCCUPIED;
}
}

Expand Down
26 changes: 23 additions & 3 deletions tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,39 @@ bool node_matches(node_t *c, node_t *t, client_select_t sel)
: sel.mode == CLIENT_MODE_MANUAL)
return false;

if (sel.urgency != CLIENT_URGENCY_ALL &&
t->client->urgent
? sel.urgency == CLIENT_URGENCY_OFF
: sel.urgency == CLIENT_URGENCY_ON
) return false;

return true;
}

bool desktop_matches(desktop_t *t, desktop_select_t sel) {
if (sel != DESKTOP_ALL &&
if (sel.status != DESKTOP_STATUS_ALL &&
t->root == NULL
? sel == DESKTOP_OCCUPIED
: sel == DESKTOP_FREE
? sel.status == DESKTOP_STATUS_OCCUPIED
: sel.status == DESKTOP_STATUS_FREE
) return false;

if (sel.urgency != DESKTOP_URGENCY_ALL &&
is_urgent(t)
? sel.urgency == DESKTOP_URGENCY_OFF
: sel.urgency == DESKTOP_URGENCY_ON
) return false;

return true;
}

bool is_urgent(desktop_t *d)
{
for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
if (n->client->urgent)
return true;
return false;
}

void change_split_ratio(node_t *n, value_change_t chg)
{
n->split_ratio = pow(n->split_ratio,
Expand Down
1 change: 1 addition & 0 deletions tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ bool is_tiled(client_t *);
bool is_floating(client_t *);
bool is_first_child(node_t *);
bool is_second_child(node_t *);
bool is_urgent(desktop_t *);
void change_split_ratio(node_t *, value_change_t);
void change_layout(monitor_t *, desktop_t *, layout_t);
void reset_mode(coordinates_t *);
Expand Down
25 changes: 21 additions & 4 deletions types.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,23 @@ typedef enum {
CLIENT_CLASS_DIFFER
} client_class_t;


typedef enum {
CLIENT_MODE_ALL,
CLIENT_MODE_AUTOMATIC,
CLIENT_MODE_MANUAL
} client_mode_t;

typedef enum {
CLIENT_URGENCY_ALL,
CLIENT_URGENCY_ON,
CLIENT_URGENCY_OFF
} client_urgency_t;

typedef struct {
client_type_t type;
client_class_t class;
client_mode_t mode;
client_urgency_t urgency;
} client_select_t;

typedef enum {
Expand All @@ -68,9 +74,20 @@ typedef enum {
} state_alter_t;

typedef enum {
DESKTOP_ALL,
DESKTOP_FREE,
DESKTOP_OCCUPIED
DESKTOP_STATUS_ALL,
DESKTOP_STATUS_FREE,
DESKTOP_STATUS_OCCUPIED
} desktop_status_t;

typedef enum {
DESKTOP_URGENCY_ALL,
DESKTOP_URGENCY_ON,
DESKTOP_URGENCY_OFF
} desktop_urgency_t;

typedef struct {
desktop_status_t status;
desktop_urgency_t urgency;
} desktop_select_t;

typedef enum {
Expand Down

0 comments on commit 7606b0b

Please sign in to comment.