New option for cancel: --all

This commit is contained in:
Bastien Dejean 2013-06-27 19:25:55 +02:00
parent a6e90f472a
commit 4e4d312ba5
8 changed files with 39 additions and 5 deletions

View file

@ -123,7 +123,7 @@ Messages
*presel* _left_|_right_|_up_|_down_ [_SPLIT_RATIO_]::
Switch to manual mode and select the splitting direction.
*cancel*::
*cancel* [*--all*]::
Switch to automatic mode.
*ratio* _VALUE_::

View file

@ -158,7 +158,7 @@ Return the list of rules\&.
Switch to manual mode and select the splitting direction\&.
.RE
.PP
\fBcancel\fR
\fBcancel\fR [\fB\-\-all\fR]
.RS 4
Switch to automatic mode\&.
.RE

View file

@ -121,7 +121,7 @@ Messages
*presel* _left_|_right_|_up_|_down_ [_SPLIT_RATIO_]::
Switch to manual mode and select the splitting direction.
*cancel*::
*cancel* [*--all*]::
Switch to automatic mode.
*ratio* _VALUE_::

View file

@ -163,8 +163,10 @@ void process_message(char *msg, char *rsp)
} else if (strcmp(cmd, "cancel") == 0) {
if (mon->desk->focus == NULL)
return;
mon->desk->focus->split_mode = MODE_AUTOMATIC;
window_draw_border(mon->desk->focus, true, true);
char *opt = strtok(NULL, TOK_SEP);
cancel_option_t o;
if (parse_cancel_option(opt, &o))
reset_mode(mon->desk, mon->desk->focus, o);
} else if (strcmp(cmd, "presel") == 0) {
if (mon->desk->focus == NULL || !is_tiled(mon->desk->focus->client) || mon->desk->layout != LAYOUT_TILED)
return;
@ -802,6 +804,18 @@ bool parse_swap_option(char *s, swap_option_t *o)
return false;
}
bool parse_cancel_option(char *s, cancel_option_t *o)
{
if (s == NULL) {
*o = CANCEL_OPTION_FOCUSED;
return true;
} else if (strcmp(s, "--all") == 0) {
*o = CANCEL_OPTION_ALL;
return true;
}
return false;
}
bool parse_rotate(char *s, rotate_t *r)
{
if (strcmp(s, "clockwise") == 0) {

View file

@ -17,6 +17,7 @@ bool parse_circulate_direction(char *, circulate_dir_t *);
bool parse_list_option(char *, list_option_t *);
bool parse_send_option(char *, send_option_t *);
bool parse_swap_option(char *, swap_option_t *);
bool parse_cancel_option(char *, cancel_option_t *);
bool parse_skip_client(char *, skip_client_t *);
bool parse_skip_desktop(char *, skip_desktop_t *);
bool parse_rotate(char *, rotate_t *);

13
tree.c
View file

@ -57,6 +57,19 @@ void change_layout(monitor_t *m, desktop_t *d, layout_t l)
put_status();
}
void reset_mode(desktop_t *d, node_t *n, cancel_option_t c)
{
if (c == CANCEL_OPTION_FOCUSED) {
n->split_mode = MODE_AUTOMATIC;
window_draw_border(mon->desk->focus, d->focus == n, true);
} else if (c == CANCEL_OPTION_ALL) {
for (node_t *a = first_extrema(d->root); a != NULL; a = next_leaf(a, d->root)) {
a->split_mode = MODE_AUTOMATIC;
window_draw_border(a, d->focus == a, true);
}
}
}
node_t *first_extrema(node_t *n)
{
if (n == NULL)

1
tree.h
View file

@ -11,6 +11,7 @@ bool is_first_child(node_t *);
bool is_second_child(node_t *);
void change_split_ratio(node_t *, value_change_t);
void change_layout(monitor_t *, desktop_t *, layout_t);
void reset_mode(desktop_t *, node_t *, cancel_option_t);
node_t *first_extrema(node_t *);
node_t *second_extrema(node_t *);
node_t *next_leaf(node_t *, node_t *);

View file

@ -51,6 +51,11 @@ typedef enum {
SWAP_OPTION_SWAP_FOCUS
} swap_option_t;
typedef enum {
CANCEL_OPTION_FOCUSED,
CANCEL_OPTION_ALL
} cancel_option_t;
typedef enum {
CLIENT_SKIP_NONE,
CLIENT_SKIP_FLOATING,