]> git.lizzy.rs Git - bspwm.git/commitdiff
Allow (+|-)fraction in "node --ratio" command
authorOlmo Kramer <olmo.kramer@gmail.com>
Mon, 30 Jan 2017 16:43:56 +0000 (17:43 +0100)
committerOlmo Kramer <olmo.kramer@gmail.com>
Mon, 30 Jan 2017 16:43:56 +0000 (17:43 +0100)
doc/bspwm.1
doc/bspwm.1.asciidoc
src/messages.c

index 9bd9bc694e2845f486ad76847cc4f0e065a41fbd..4a0681cc15aeeb87f76c5f4ebf9389daaf6abbd9 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: bspwm
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
-.\"      Date: 12/21/2016
+.\"      Date: 01/30/2017
 .\"    Manual: Bspwm Manual
-.\"    Source: Bspwm 0.9.2-18-g0d34170
+.\"    Source: Bspwm 0.9.2-25-g048230e
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "12/21/2016" "Bspwm 0\&.9\&.2\-18\-g0d34170" "Bspwm Manual"
+.TH "BSPWM" "1" "01/30/2017" "Bspwm 0\&.9\&.2\-25\-g048230e" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -605,7 +605,7 @@ pixels horizontally and
 pixels vertically\&.
 .RE
 .PP
-\fB\-r\fR, \fB\-\-ratio\fR \fIRATIO\fR|(+|\-)\fIPIXELS\fR
+\fB\-r\fR, \fB\-\-ratio\fR \fIRATIO\fR|(+|\-)(\fIPIXELS\fR|\fIFRACTION\fR)
 .RS 4
 Set the splitting ratio of the selected node (0 <
 \fIRATIO\fR
index 992c569aec2189b260faa1e2149afd1b1ed56cd5..46a2b829bd2d28244c79e80b09cb99dccc485786 100644 (file)
@@ -367,7 +367,7 @@ Commands
 *-z*, *--resize* top|left|bottom|right|top_left|top_right|bottom_right|bottom_left 'dx' 'dy'::
        Resize the selected window by moving the given handle by 'dx' pixels horizontally and 'dy' pixels vertically.
 
-*-r*, *--ratio* 'RATIO'|(+|-)'PIXELS'::
+*-r*, *--ratio* 'RATIO'|(+|-)('PIXELS'|'FRACTION')::
        Set the splitting ratio of the selected node (0 < 'RATIO' < 1).
 
 *-R*, *--rotate* '90|270|180'::
index c7a6ade9e1bd9c97c940208170daec7e05f7a758..c3f72242fec703d786e008cc3e6592add6ebcfe2 100644 (file)
@@ -438,10 +438,15 @@ void cmd_node(char **args, int num, FILE *rsp)
                                break;
                        }
                        if ((*args)[0] == '+' || (*args)[0] == '-') {
-                               int pix;
-                               if (sscanf(*args, "%i", &pix) == 1) {
-                                       int max = (trg.node->split_type == TYPE_HORIZONTAL ? trg.node->rectangle.height : trg.node->rectangle.width);
-                                       double rat = ((max * trg.node->split_ratio) + pix) / max;
+                               float delta;
+                               if (sscanf(*args, "%f", &delta) == 1) {
+                                       double rat = trg.node->split_ratio;
+                                       if (delta > -1 && delta < 1) {
+                                               rat += delta;
+                                       } else {
+                                               int max = (trg.node->split_type == TYPE_HORIZONTAL ? trg.node->rectangle.height : trg.node->rectangle.width);
+                                               rat = ((max * rat) + delta) / max;
+                                       }
                                        if (rat > 0 && rat < 1) {
                                                set_ratio(trg.node, rat);
                                        } else {