]> git.lizzy.rs Git - bspwm.git/commitdiff
New setting: 'adaptative_raise'
authorBastien Dejean <nihilhill@gmail.com>
Thu, 13 Dec 2012 13:00:45 +0000 (14:00 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Thu, 13 Dec 2012 13:00:45 +0000 (14:00 +0100)
README.md
bspwm.1
messages.c
settings.c
settings.h
tree.c
window.c
window.h

index 75d328a382259129a513af8a14513a5fa832fd14..fa18eb0490f626afe50f4f75f7aa2dd7137c0dda 100644 (file)
--- a/README.md
+++ b/README.md
@@ -269,6 +269,9 @@ Colors are either [X color names](http://en.wikipedia.org/wiki/X11_color_names)
     focus_follows_mouse
         Wether to focus the window under the mouse pointer.
 
+    adaptative_raise
+        Prevent floating windows from being raised when they might cover other floating windows.
+
 ## Mouse Bindings
 
     button_modifier + left mouse button
diff --git a/bspwm.1 b/bspwm.1
index 043f2d92625da13a5b1490da1a68ba986ff098eb..4b3a344ee4f2651a298509e5c1b2c96c50a374b5 100644 (file)
--- a/bspwm.1
+++ b/bspwm.1
@@ -308,6 +308,9 @@ Whether to remove gaps for tiled windows in monocle mode.
 .TP
 .I focus_follows_mouse
 Wether to focus the window under the mouse pointer.
+.TP
+.I adaptative_raise
+Prevent floating windows from being raised when they might cover other floating windows.
 .SH MOUSE BINDINGS
 .TP
 .I button_modifier + left mouse button
index 12a650a0510d88815e783ace07b9048e6fb21c58..a897345be806f43c49b37b9a4d13f9e62f254e62 100644 (file)
@@ -408,6 +408,10 @@ void set_setting(char *name, char *value, char *rsp)
         bool b;
         if (parse_bool(value, &b))
             focus_follows_mouse = b;
+    } else if (strcmp(name, "adaptative_raise") == 0) {
+        bool b;
+        if (parse_bool(value, &b))
+            adaptative_raise = b;
     } else if (strcmp(name, "wm_name") == 0) {
         strncpy(wm_name, value, sizeof(wm_name));
         ewmh_update_wm_name();
@@ -493,6 +497,8 @@ void get_setting(char *name, char* rsp)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(gapless_monocle));
     else if (strcmp(name, "focus_follows_mouse") == 0)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_follows_mouse));
+    else if (strcmp(name, "adaptative_raise") == 0)
+        snprintf(rsp, BUFSIZ, "%s", BOOLSTR(adaptative_raise));
     else if (strcmp(name, "wm_name") == 0)
         snprintf(rsp, BUFSIZ, "%s", wm_name);
     else if (strcmp(name, "button_modifier") == 0)
index 0bfaa9caf2b29568795679b8b6a88a0c47e176dc..4fef401d6b555bfbb7496521585ab3313b6bb377 100644 (file)
@@ -69,4 +69,5 @@ void load_settings(void)
     borderless_monocle = BORDERLESS_MONOCLE;
     gapless_monocle = GAPLESS_MONOCLE;
     focus_follows_mouse = FOCUS_FOLLOWS_MOUSE;
+    adaptative_raise = ADAPTATIVE_RAISE;
 }
index 391659d28db25677f3c556675cb55338f2434436..54d336c5482b8d51a3acd6139b8321d1523a07d6 100644 (file)
@@ -30,6 +30,7 @@
 #define BORDERLESS_MONOCLE   false
 #define GAPLESS_MONOCLE      false
 #define FOCUS_FOLLOWS_MOUSE  false
+#define ADAPTATIVE_RAISE     false
 
 char focused_border_color[MAXLEN];
 char active_border_color[MAXLEN];
@@ -63,6 +64,7 @@ int window_gap;
 bool borderless_monocle;
 bool gapless_monocle;
 bool focus_follows_mouse;
+bool adaptative_raise;
 
 char wm_name[MAXLEN];
 unsigned int button_modifier;
diff --git a/tree.c b/tree.c
index 4472682a8c9936d548c1fcf4f0f5f4a7817b1ba2..43b17c259f155b1d12fc24fa71bc3165902cf890 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -428,10 +428,12 @@ void focus_node(monitor_t *m, desktop_t *d, node_t *n, bool is_mapped)
         xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, n->client->window, XCB_CURRENT_TIME);
     }
 
-    if (!is_tiled(n->client))
-        window_raise(n->client->window);
-    else
+    if (!is_tiled(n->client)) {
+        if (!adaptative_raise || !might_cover(d, n))
+            window_raise(n->client->window);
+    } else {
         window_pseudo_raise(d, n->client->window);
+    }
 
     if (d->focus != n) {
         d->last_focus = d->focus;
index 8d567b3778886810572955b95fd3759ac22a8f10..f65c0e83cd41278f7408f6d3f29c44f0079a64e0 100644 (file)
--- a/window.c
+++ b/window.c
 #include "rules.h"
 #include "window.h"
 
+bool contains(xcb_rectangle_t a, xcb_rectangle_t b)
+{
+    return (a.x <= b.x && (a.x + a.width) >= (b.x + b.width)
+            && a.y <= b.y && (a.y + a.height) >= (b.y + b.height));
+}
+
+bool might_cover(desktop_t *d, node_t *n)
+{
+    for (node_t *f = first_extrema(d->root); f != NULL; f = next_leaf(f))
+        if (f != n && is_floating(f->client) && contains(n->client->floating_rectangle, f->client->floating_rectangle))
+            return true;
+    return false;
+}
+
 bool locate_window(xcb_window_t win, window_location_t *loc)
 {
     for (monitor_t *m = mon_head; m != NULL; m = m->next)
index 6a4e2f57f6ef597f00e275031888c6fa7c5e040e..801fc208c95bbb3f8c55cb9df37ddeb6571cfd3d 100644 (file)
--- a/window.h
+++ b/window.h
@@ -6,6 +6,8 @@
 #include <xcb/xcb_event.h>
 #include "types.h"
 
+bool contains(xcb_rectangle_t, xcb_rectangle_t);
+bool might_cover(desktop_t *, node_t *);
 bool locate_window(xcb_window_t, window_location_t *);
 bool locate_desktop(char *, desktop_location_t *);
 bool is_inside(monitor_t *, xcb_point_t);