Add rule consequence: split_ratio

Fixes #214
This commit is contained in:
Bastien Dejean 2015-02-21 10:14:27 +01:00
parent 5c1f76fdd6
commit 9f2065540e
5 changed files with 14 additions and 4 deletions

View file

@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 01/15/2015
.\" Date: 02/21/2015
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.8.9
.\" Language: English
.\"
.TH "BSPWM" "1" "01/15/2015" "Bspwm 0\&.8\&.9" "Bspwm Manual"
.TH "BSPWM" "1" "02/21/2015" "Bspwm 0\&.8\&.9" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -900,7 +900,7 @@ rule \fIOPTIONS\fR
\fBOptions\fR
.RS 4
.PP
\fB\-a\fR, \fB\-\-add\fR <class_name>|<instance_name>|* [\fB\-o\fR|\fB\-\-one\-shot\fR] [monitor=MONITOR_SEL|desktop=DESKTOP_SEL|window=WINDOW_SEL] [(floating|fullscreen|pseudo_tiled|locked|sticky|private|center|follow|manage|focus|border)=(on|off)] [split_dir=DIR]
\fB\-a\fR, \fB\-\-add\fR <class_name>|<instance_name>|* [\fB\-o\fR|\fB\-\-one\-shot\fR] [monitor=MONITOR_SEL|desktop=DESKTOP_SEL|window=WINDOW_SEL] [(floating|fullscreen|pseudo_tiled|locked|sticky|private|center|follow|manage|focus|border)=(on|off)] [split_dir=DIR] [split_ratio=RATIO]
.RS 4
Create a new rule\&.
.RE

View file

@ -552,7 +552,7 @@ rule 'OPTIONS'
Options
^^^^^^^
*-a*, *--add* <class_name>|<instance_name>|* [*-o*|*--one-shot*] [monitor=MONITOR_SEL|desktop=DESKTOP_SEL|window=WINDOW_SEL] [(floating|fullscreen|pseudo_tiled|locked|sticky|private|center|follow|manage|focus|border)=(on|off)] [split_dir=DIR]::
*-a*, *--add* <class_name>|<instance_name>|* [*-o*|*--one-shot*] [monitor=MONITOR_SEL|desktop=DESKTOP_SEL|window=WINDOW_SEL] [(floating|fullscreen|pseudo_tiled|locked|sticky|private|center|follow|manage|focus|border)=(on|off)] [split_dir=DIR] [split_ratio=RATIO]::
Create a new rule.
*-r*, *--remove* ^<n>|head|tail|<class_name>|<instance_name>|*...::

5
rule.c
View file

@ -280,6 +280,11 @@ void parse_key_value(char *key, char *value, rule_consequence_t *csq)
snprintf(csq->node_desc, sizeof(csq->node_desc), "%s", value);
} else if (streq("split_dir", key)) {
snprintf(csq->split_dir, sizeof(csq->split_dir), "%s", value);
} else if (streq("split_ratio", key)) {
double rat;
if (sscanf(value, "%lf", &rat) == 1 && rat > 0 && rat < 1) {
csq->split_ratio = rat;
}
} else if (parse_bool(value, &v)) {
if (streq("floating", key))
csq->floating = v;

View file

@ -273,6 +273,7 @@ typedef struct {
char desktop_desc[MAXLEN];
char node_desc[MAXLEN];
char split_dir[SMALEN];
double split_ratio;
uint16_t min_width;
uint16_t max_width;
uint16_t min_height;

View file

@ -118,6 +118,10 @@ void manage_window(xcb_window_t win, rule_consequence_t *csq, int fd)
}
}
if (csq->split_ratio != 0) {
f->split_ratio = csq->split_ratio;
}
client_t *c = make_client(win, csq->border ? d->border_width : 0);
update_floating_rectangle(c);
if (c->floating_rectangle.x == 0 && c->floating_rectangle.y == 0)