]> git.lizzy.rs Git - bspwm.git/commitdiff
Add node descriptor: `smallest`
authorBastien Dejean <nihilhill@gmail.com>
Tue, 19 Jun 2018 08:14:09 +0000 (10:14 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Tue, 19 Jun 2018 08:14:09 +0000 (10:14 +0200)
Fixes #815.

contrib/zsh_completion
doc/bspwm.1
doc/bspwm.1.asciidoc
src/query.c
src/tree.c
src/tree.h
src/types.h

index 3e92a0126d35fee87a1a96d120846eaf9a0a4317..d66b9b2f87157b7b75ab3b8be354de48f97e6c3b 100644 (file)
@@ -134,7 +134,7 @@ _bspc() {
                dir=(north west south east) \
                cycle_dir=(next prev)
        local -a jump=($dir first second brother parent 1 2) \
-               node_desc=($dir $cycle_dir any last newest older newer focused pointed biggest) \
+               node_desc=($dir $cycle_dir any last newest older newer focused pointed biggest smallest) \
                node_mod=($node_state $flag $layer focused automatic local \
                active leaf window same_class descendant_of ancestor_of) \
                desktop_desc=($cycle_dir any last newest older newer focused) \
index 43bfc5ef6a75d392f67bf7218bf3115f50e4600c..ca04ae63089d9caa4270c8c79761255eea2df7ba 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: 04/25/2018
+.\"      Date: 06/19/2018
 .\"    Manual: Bspwm Manual
-.\"    Source: Bspwm 0.9.5
+.\"    Source: Bspwm 0.9.5-3-gdb5b0cd
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "04/25/2018" "Bspwm 0\&.9\&.5" "Bspwm Manual"
+.TH "BSPWM" "1" "06/19/2018" "Bspwm 0\&.9\&.5\-3\-gdb5b0cd" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -101,10 +101,10 @@ Select a node\&.
 .\}
 .nf
 NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|any|last|newest|
-                        older|newer|focused|pointed|
-                        biggest|<node_id>)[\&.[!]focused][\&.[!]automatic][\&.[!]local][\&.[!]active]
-                                          [\&.[!]leaf][\&.[!]window][\&.[!]STATE][\&.[!]FLAG][\&.[!]LAYER]
-                                          [\&.[!]same_class][\&.[!]descendant_of][\&.[!]ancestor_of]
+                        older|newer|focused|pointed|biggest|smallest
+                        <node_id>)[\&.[!]focused][\&.[!]automatic][\&.[!]local][\&.[!]active]
+                                  [\&.[!]leaf][\&.[!]window][\&.[!]STATE][\&.[!]FLAG][\&.[!]LAYER]
+                                  [\&.[!]same_class][\&.[!]descendant_of][\&.[!]ancestor_of]
 
 STATE := tiled|pseudo_tiled|floating|fullscreen
 
@@ -183,6 +183,11 @@ biggest
 Selects the biggest window\&.
 .RE
 .PP
+smallest
+.RS 4
+Selects the smallest window\&.
+.RE
+.PP
 <node_id>
 .RS 4
 Selects the node with the given ID\&.
index 48f076946b58ecb404af13c5d2ba516976968c65..18b3264fe7f2c7057b6f69629b5761ca6aa94dc0 100644 (file)
@@ -75,10 +75,10 @@ Select a node.
 
 ----
 NODE_SEL := [NODE_SEL#](DIR|CYCLE_DIR|PATH|any|last|newest|
-                        older|newer|focused|pointed|
-                        biggest|<node_id>)[.[!]focused][.[!]automatic][.[!]local][.[!]active]
-                                          [.[!]leaf][.[!]window][.[!]STATE][.[!]FLAG][.[!]LAYER]
-                                          [.[!]same_class][.[!]descendant_of][.[!]ancestor_of]
+                        older|newer|focused|pointed|biggest|smallest
+                        <node_id>)[.[!]focused][.[!]automatic][.[!]local][.[!]active]
+                                  [.[!]leaf][.[!]window][.[!]STATE][.[!]FLAG][.[!]LAYER]
+                                  [.[!]same_class][.[!]descendant_of][.[!]ancestor_of]
 
 STATE := tiled|pseudo_tiled|floating|fullscreen
 
@@ -127,6 +127,9 @@ pointed::
 biggest::
        Selects the biggest window.
 
+smallest::
+       Selects the smallest window.
+
 <node_id>::
        Selects the node with the given ID.
 
index f679593a572cc34330d30aa6484251c84b5d5834..3d99a17000248647d29093b433dace41cba12450 100644 (file)
@@ -533,7 +533,9 @@ int node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
        } else if (streq("newest", desc)) {
                history_find_newest_node(ref, dst, &sel);
        } else if (streq("biggest", desc)) {
-               find_biggest(ref, dst, &sel);
+               find_by_area(AREA_BIGGEST, ref, dst, &sel);
+       } else if (streq("smallest", desc)) {
+               find_by_area(AREA_SMALLEST, ref, dst, &sel);
        } else if (streq("pointed", desc)) {
                xcb_window_t win = XCB_NONE;
                query_pointer(&win, NULL);
index 2d0cc98e071575569d14db24514e036c88d0d32a..3af5b6658adf30eccb991a7e9f4baa409b020189 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdbool.h>
+#include <limits.h>
 #include "bspwm.h"
 #include "desktop.h"
 #include "ewmh.h"
@@ -1042,9 +1043,14 @@ int tiled_count(node_t *n)
        return cnt;
 }
 
-void find_biggest(coordinates_t *ref, coordinates_t *dst, node_select_t *sel)
+void find_by_area(area_peak_t ap, coordinates_t *ref, coordinates_t *dst, node_select_t *sel)
 {
-       unsigned int b_area = 0;
+       unsigned int p_area;
+       if (ap == AREA_BIGGEST) {
+               p_area = 0;
+       } else {
+               p_area = UINT_MAX;
+       }
 
        for (monitor_t *m = mon_head; m != NULL; m = m->next) {
                for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
@@ -1054,9 +1060,9 @@ void find_biggest(coordinates_t *ref, coordinates_t *dst, node_select_t *sel)
                                        continue;
                                }
                                unsigned int f_area = node_area(d, f);
-                               if (f_area > b_area) {
+                               if ((ap == AREA_BIGGEST && f_area > p_area) || (ap == AREA_SMALLEST && f_area < p_area)) {
                                        *dst = loc;
-                                       b_area = f_area;
+                                       p_area = f_area;
                                }
                        }
                }
index 05501f484568e5deed8692d64014ff11d9f9ba42..8e0293a01bcb484f4cf4be515528a0ebb0bf62fd 100644 (file)
@@ -71,7 +71,7 @@ bool find_any_node_in(monitor_t *m, desktop_t *d, node_t *n, coordinates_t *ref,
 void find_nearest_neighbor(coordinates_t *ref, coordinates_t *dst, direction_t dir, node_select_t *sel);
 unsigned int node_area(desktop_t *d, node_t *n);
 int tiled_count(node_t *n);
-void find_biggest(coordinates_t *ref, coordinates_t *dst, node_select_t *sel);
+void find_by_area(area_peak_t ap, coordinates_t *ref, coordinates_t *dst, node_select_t *sel);
 void rotate_tree(node_t *n, int deg);
 void rotate_tree_rec(node_t *n, int deg);
 void rotate_brother(node_t *n);
index 1703d2181b804e00d57f21cd74f1a1883c55cb6e..4f936b5438c26b368a767db066a86ebd6b50bcbf 100644 (file)
@@ -144,6 +144,11 @@ typedef enum {
        TIGHTNESS_HIGH,
 } tightness_t;
 
+typedef enum {
+       AREA_BIGGEST,
+       AREA_SMALLEST,
+} area_peak_t;
+
 typedef enum {
        STATE_TRANSITION_ENTER = 1 << 0,
        STATE_TRANSITION_EXIT = 1 << 1,