]> git.lizzy.rs Git - bspwm.git/commitdiff
New setting: fit_monitor
authorBastien Dejean <nihilhill@gmail.com>
Wed, 23 Oct 2013 20:20:34 +0000 (22:20 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Wed, 23 Oct 2013 20:20:34 +0000 (22:20 +0200)
12 files changed:
contrib/bash_completion
contrib/zsh_completion
desktop.c
doc/bspwm.1
doc/bspwm.1.txt
messages.c
monitor.c
monitor.h
settings.c
settings.h
tree.c
window.c

index fffa1dc266598fbc6da18b2aba181e80f7d341ff..5a04e5c957765e4e4fa5cd618d08724471a222dc 100644 (file)
@@ -1,7 +1,7 @@
 _bspc() {
     local commands='window desktop monitor query pointer rule restore control config quit'
 
-    local settings='focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color focused_sticky_border_color normal_sticky_border_color focused_private_border_color active_private_border_color normal_private_border_color urgent_border_color focused_frame_opacity active_frame_opacity normal_frame_opacity border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio growth_factor borderless_monocle gapless_monocle focus_follows_pointer pointer_follows_monitor apply_floating_atom auto_alternate auto_cancel history_aware_focus honor_ewmh_focus'
+    local settings='focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color focused_sticky_border_color normal_sticky_border_color focused_private_border_color active_private_border_color normal_private_border_color urgent_border_color focused_frame_opacity active_frame_opacity normal_frame_opacity border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio growth_factor borderless_monocle gapless_monocle focus_follows_pointer pointer_follows_monitor apply_floating_atom auto_alternate auto_cancel history_aware_focus honor_ewmh_focus fit_monitor'
 
     COMPREPLY=()
 
index 97a4ee4d09ac11e8ac7345920c49e67ae7732c4f..4aa8eabc9beb01206653ab953e45a9ce544d8794 100644 (file)
@@ -3,7 +3,7 @@
 _bspc() {
     local -a commands settings
     commands=('window' 'desktop' 'monitor' 'query' 'pointer' 'rule' 'restore' 'control' 'config' 'quit')
-    settings=('focused_border_color' 'active_border_color' 'normal_border_color' 'presel_border_color' 'focused_locked_border_color' 'active_locked_border_color' 'normal_locked_border_color' 'focused_sticky_border_color' 'normal_sticky_border_color' 'focused_private_border_color' 'active_private_border_color' 'normal_private_border_color' 'urgent_border_color' 'focused_frame_opacity' 'active_frame_opacity' 'normal_frame_opacity' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'growth_factor' 'borderless_monocle' 'gapless_monocle' 'focus_follows_pointer' 'pointer_follows_monitor' 'apply_floating_atom' 'auto_alternate' 'auto_cancel' 'history_aware_focus' 'honor_ewmh_focus')
+    settings=('focused_border_color' 'active_border_color' 'normal_border_color' 'presel_border_color' 'focused_locked_border_color' 'active_locked_border_color' 'normal_locked_border_color' 'focused_sticky_border_color' 'normal_sticky_border_color' 'focused_private_border_color' 'active_private_border_color' 'normal_private_border_color' 'urgent_border_color' 'focused_frame_opacity' 'active_frame_opacity' 'normal_frame_opacity' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'growth_factor' 'borderless_monocle' 'gapless_monocle' 'focus_follows_pointer' 'pointer_follows_monitor' 'apply_floating_atom' 'auto_alternate' 'auto_cancel' 'history_aware_focus' 'honor_ewmh_focus' 'fit_monitor')
     if (( CURRENT == 2 )) ; then
         _values 'command' "$commands[@]"
     elif (( CURRENT == 3 )) ; then
index cf2bf11c01d1eb5f5104adc8b3a57ba2e695d37d..072f09aef84f3b4b58e127e7f6dbbf7255caef8c 100644 (file)
--- a/desktop.c
+++ b/desktop.c
@@ -93,7 +93,7 @@ void transfer_desktop(monitor_t *ms, monitor_t *md, desktop_t *d)
     }
 
     for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
-        fit_monitor(ms, md, n);
+        translate_position(ms, md, n);
 
     arrange(md, d);
 
@@ -252,9 +252,9 @@ void swap_desktops(monitor_t *m1, desktop_t *d1, monitor_t *m2, desktop_t *d2)
 
     if (m1 != m2) {
         for (node_t *n = first_extrema(d1->root); n != NULL; n = next_leaf(n, d1->root))
-            fit_monitor(m1, m2, n);
+            translate_position(m1, m2, n);
         for (node_t *n = first_extrema(d2->root); n != NULL; n = next_leaf(n, d2->root))
-            fit_monitor(m2, m1, n);
+            translate_position(m2, m1, n);
         history_swap_desktops(m1, d1, m2, d2);
         arrange(m1, d2);
         arrange(m2, d1);
index 98e52eaaf46a2df1bd0197dd52cb0e27fa73e327..084fedf21eb9fa230eaa29eda8f8a21be62f5e92 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: bspwm
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\"      Date: 10/20/2013
+.\"      Date: 10/23/2013
 .\"    Manual: Bspwm Manual
 .\"    Source: Bspwm 0.8.6
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "10/20/2013" "Bspwm 0\&.8\&.6" "Bspwm Manual"
+.TH "BSPWM" "1" "10/23/2013" "Bspwm 0\&.8\&.6" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1053,6 +1053,11 @@ atom of each window according to its floating state\&.
 .RS 4
 Honor EWMH requests to focus a window\&.
 .RE
+.PP
+\fIfit_monitor\fR
+.RS 4
+Keep floating windows inside their monitor\&.
+.RE
 .SS "Monitor Settings"
 .PP
 \fItop_padding\fR, \fIright_padding\fR, \fIbottom_padding\fR, \fIleft_padding\fR
index e55e0e612b40e575bd0b12fbc2d8f425e2bc6423..d011548d049db12b8eb6ea554e3aa08ab75545b5 100644 (file)
@@ -639,6 +639,9 @@ Global Settings
 'honor_ewmh_focus'::
     Honor EWMH requests to focus a window.
 
+'fit_monitor'::
+    Keep floating windows inside their monitor.
+
 Monitor Settings
 ~~~~~~~~~~~~~~~~
 
index b55b691ab3d0fbad7489060775d8d94adf2d63cd..29830506e855474f91f6b6459c242c7e4dd5d5d2 100644 (file)
@@ -931,6 +931,7 @@ bool set_setting(coordinates_t loc, char *name, char *value)
         SETBOOL(auto_cancel)
         SETBOOL(history_aware_focus)
         SETBOOL(honor_ewmh_focus)
+        SETBOOL(fit_monitor)
 #undef SETBOOL
     } else {
         return false;
@@ -1004,6 +1005,7 @@ bool get_setting(coordinates_t loc, char *name, char* rsp)
     GETBOOL(auto_cancel)
     GETBOOL(history_aware_focus)
     GETBOOL(honor_ewmh_focus)
+    GETBOOL(fit_monitor)
 #undef GETBOOL
     else
         return false;
index cee50e851ac408842f46d796e9ff156e3822f254..2a82f1f5124deb8dcd499673967c489d19fe2cdf 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -71,13 +71,15 @@ monitor_t *get_monitor_by_id(xcb_randr_output_t id)
     return NULL;
 }
 
-void fit_monitor(monitor_t *ms, monitor_t *md, node_t *n)
+void translate_position(monitor_t *ms, monitor_t *md, node_t *n)
 {
     if (frozen_pointer->action != ACTION_NONE)
         return;
+
     xcb_rectangle_t a = ms->rectangle;
     xcb_rectangle_t b = md->rectangle;
     xcb_rectangle_t *r = &n->client->floating_rectangle;
+
     if (ms != md) {
         double w = b.width;
         double h = b.height;
@@ -86,17 +88,20 @@ void fit_monitor(monitor_t *ms, monitor_t *md, node_t *n)
         r->x = b.x + dx;
         r->y = b.y + dy;
     }
-    if (r->x <= b.x || (r->x + r->width) >= (b.x + b.width)) {
-        if (r->width >= b.width)
-            r->x = b.x;
-        else
-            r->x = b.x + (b.width - r->width) / 2;
-    }
-    if (r->y <= b.y || (r->y + r->height) >= (b.y + b.height)) {
-        if (r->height >= b.height)
-            r->y = b.y;
-        else
-            r->y = b.y + (b.height - r->height) / 2;
+
+    if (fit_monitor) {
+        if (r->x <= b.x || (r->x + r->width) >= (b.x + b.width)) {
+            if (r->width >= b.width)
+                r->x = b.x;
+            else
+                r->x = b.x + (b.width - r->width) / 2;
+        }
+        if (r->y <= b.y || (r->y + r->height) >= (b.y + b.height)) {
+            if (r->height >= b.height)
+                r->y = b.y;
+            else
+                r->y = b.y + (b.height - r->height) / 2;
+        }
     }
 }
 
@@ -297,7 +302,7 @@ bool import_monitors(void)
                         update_root(mm);
                         for (desktop_t *d = mm->desk_head; d != NULL; d = d->next)
                             for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root))
-                                fit_monitor(mm, mm, n);
+                                translate_position(mm, mm, n);
                         arrange(mm, mm->desk);
                         mm->wired = true;
                         PRINTF("update monitor %s (0x%X)\n", mm->name, mm->id);
index 1933023b685fa40da4811372718438232ff90add..726784ccab0324d2ad13bd9b75f0762425d14983 100644 (file)
--- a/monitor.h
+++ b/monitor.h
@@ -30,7 +30,7 @@
 monitor_t *make_monitor(xcb_rectangle_t rect);
 monitor_t *find_monitor(char *name);
 monitor_t *get_monitor_by_id(xcb_randr_output_t id);
-void fit_monitor(monitor_t *ms, monitor_t *md, node_t *n);
+void translate_position(monitor_t *ms, monitor_t *md, node_t *n);
 void update_root(monitor_t *m);
 void focus_monitor(monitor_t *m);
 monitor_t *add_monitor(xcb_rectangle_t rect);
index a00ecec2f2d4d4f089a4cd1cf85f1b4ddbfaf562..99af2b93181baa1f020afb75108d89330ae0f3f9 100644 (file)
@@ -77,4 +77,5 @@ void load_settings(void)
     auto_cancel = AUTO_CANCEL;
     history_aware_focus = HISTORY_AWARE_FOCUS;
     honor_ewmh_focus = HONOR_EWMH_FOCUS;
+    fit_monitor = FIT_MONITOR;
 }
index ba90177b96abf0a0b5f072daaff79446baf8c090..673308de2365a8a6130d2f59be0b94ed2e9afdce 100644 (file)
@@ -62,6 +62,7 @@
 #define AUTO_CANCEL              false
 #define APPLY_FLOATING_ATOM      false
 #define HONOR_EWMH_FOCUS         false
+#define FIT_MONITOR              false
 
 char focused_border_color[MAXLEN];
 char active_border_color[MAXLEN];
@@ -94,6 +95,7 @@ bool auto_alternate;
 bool auto_cancel;
 bool history_aware_focus;
 bool honor_ewmh_focus;
+bool fit_monitor;
 
 void run_config(void);
 void load_settings(void);
diff --git a/tree.c b/tree.c
index 56e7e354edf809f882d7b8e6ee2b6945613f81e1..9f2cb3011f4f1baae0c30dad4985b927ab90a9b0 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -968,8 +968,8 @@ bool swap_nodes(monitor_t *m1, desktop_t *d1, node_t *n1, monitor_t *m2, desktop
             d2->focus = n1;
 
         if (m1 != m2) {
-            fit_monitor(m2, m1, n2);
-            fit_monitor(m1, m2, n1);
+            translate_position(m2, m1, n2);
+            translate_position(m1, m2, n1);
         }
 
         ewmh_set_wm_desktop(n1, d2);
@@ -1007,7 +1007,7 @@ bool transfer_node(monitor_t *ms, desktop_t *ds, node_t *ns, monitor_t *md, desk
     insert_node(md, dd, ns, nd);
 
     if (md != ms)
-        fit_monitor(ms, md, ns);
+        translate_position(ms, md, ns);
 
     if (ds != dd) {
         ewmh_set_wm_desktop(ns, dd);
index 58208ef18db1579b0395556b1b0eb0936ca13e1d..a1969968ac004af0e0181bf6d8f43ca3077a50c0 100644 (file)
--- a/window.c
+++ b/window.c
@@ -78,7 +78,7 @@ void manage_window(monitor_t *m, desktop_t *d, xcb_window_t win)
     n->client = c;
 
     insert_node(m, d, n, d->focus);
-    fit_monitor(m, m, n);
+    translate_position(m, m, n);
 
     disable_floating_atom(c->window);
     set_floating(n, floating);