From: Justinien Bouron Date: Thu, 24 Aug 2017 19:04:23 +0000 (+0200) Subject: Add new monitor selector : pointed. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;ds=sidebyside;h=41dc94f63c1001be9716bc19228bf2c91eba68c8;p=bspwm.git Add new monitor selector : pointed. --- diff --git a/doc/bspwm.1 b/doc/bspwm.1 index 650f07d..cb9b072 100644 --- a/doc/bspwm.1 +++ b/doc/bspwm.1 @@ -384,7 +384,7 @@ Select a monitor\&. .RS 4 .\} .nf -MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|older|newer|focused|primary|^||)[\&.[!]occupied][\&.[!]focused] +MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|older|newer|focused|pointed|primary|^||)[\&.[!]occupied][\&.[!]focused] .fi .if n \{\ .RE @@ -428,6 +428,11 @@ focused Selects the currently focused monitor\&. .RE .PP +pointed +.RS 4 +Selects the monitor under the pointer\&. +.RE +.PP primary .RS 4 Selects the primary monitor\&. diff --git a/doc/bspwm.1.asciidoc b/doc/bspwm.1.asciidoc index e4b2de9..10cb37e 100644 --- a/doc/bspwm.1.asciidoc +++ b/doc/bspwm.1.asciidoc @@ -234,7 +234,7 @@ Monitor Select a monitor. ---- -MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|older|newer|focused|primary|^||)[.[!]occupied][.[!]focused] +MONITOR_SEL := [MONITOR_SEL#](DIR|CYCLE_DIR|last|older|newer|focused|pointed|primary|^||)[.[!]occupied][.[!]focused] ---- Descriptors @@ -258,6 +258,9 @@ newer:: focused:: Selects the currently focused monitor. +pointed:: + Selects the monitor under the pointer. + primary:: Selects the primary monitor. diff --git a/src/query.c b/src/query.c index 7498812..83c6cb5 100644 --- a/src/query.c +++ b/src/query.c @@ -33,6 +33,7 @@ #include "window.h" #include "tree.h" #include "query.h" +#include "geometry.h" void query_tree(FILE *rsp) { @@ -731,6 +732,15 @@ int monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst) if (monitor_matches(&loc, ref, sel)) { dst->monitor = mon; } + } else if (streq("pointed", desc)) { + xcb_point_t pointer; + query_pointer(NULL, &pointer); + for (monitor_t *m = mon_head; m != NULL; m = m->next) { + if (is_inside(pointer, m->rectangle)) { + dst->monitor = m; + break; + } + } } else if (parse_index(desc, &idx) && monitor_from_index(idx, dst)) { free(desc_copy); if (monitor_matches(dst, ref, sel)) {