]> git.lizzy.rs Git - bspwm.git/blobdiff - window.c
New setting: fit_monitor
[bspwm.git] / window.c
index b0693becf82d820799a6487e73dbf9a55712f53a..a1969968ac004af0e0181bf6d8f43ca3077a50c0 100644 (file)
--- a/window.c
+++ b/window.c
@@ -31,7 +31,6 @@
 #include "rule.h"
 #include "settings.h"
 #include "stack.h"
-#include "tag.h"
 #include "tree.h"
 #include "window.h"
 
@@ -50,8 +49,7 @@ void manage_window(monitor_t *m, desktop_t *d, xcb_window_t win)
         return;
 
     bool floating = false, fullscreen = false, locked = false, sticky = false, follow = false, transient = false, takes_focus = true, frame = false, private = false, manage = true;
-    unsigned int tags_field = 0;
-    handle_rules(win, &m, &d, &tags_field, &floating, &fullscreen, &locked, &sticky, &follow, &transient, &takes_focus, &frame, &private, &manage);
+    handle_rules(win, &m, &d, &floating, &fullscreen, &locked, &sticky, &follow, &transient, &takes_focus, &frame, &private, &manage);
 
     if (!manage) {
         disable_floating_atom(win);
@@ -63,7 +61,8 @@ void manage_window(monitor_t *m, desktop_t *d, xcb_window_t win)
 
     client_t *c = make_client(win);
     update_floating_rectangle(c);
-    c->tags_field = (tags_field == 0 ? d->tags_field : tags_field);
+    c->floating_rectangle.x += m->rectangle.x;
+    c->floating_rectangle.y += m->rectangle.y;
     c->frame = frame;
 
     xcb_icccm_get_wm_class_reply_t reply;
@@ -79,6 +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);
+    translate_position(m, m, n);
 
     disable_floating_atom(c->window);
     set_floating(n, floating);
@@ -92,32 +92,21 @@ void manage_window(monitor_t *m, desktop_t *d, xcb_window_t win)
     set_fullscreen(n, fullscreen);
     c->transient = transient;
 
-    tag_node(m, d, n, d, n->client->tags_field);
-
-    xcb_rectangle_t *frect = &n->client->floating_rectangle;
-    if (frect->x == 0 && frect->y == 0)
-        center(m->rectangle, frect);
-    fit_monitor(m, n->client);
-
     arrange(m, d);
 
     bool give_focus = (takes_focus && (d == mon->desk || follow));
 
-    if (is_visible(d, n)) {
-        if (give_focus)
-            focus_node(m, d, n);
-        else if (takes_focus)
-            pseudo_focus(d, n);
-        else
-            stack(n);
-    } else {
-        stack_under(n);
-    }
+    if (give_focus)
+        focus_node(m, d, n);
+    else if (takes_focus)
+        pseudo_focus(d, n);
+    else
+        stack(n, STACK_ABOVE);
 
     uint32_t values[] = {get_event_mask(n->client)};
     xcb_change_window_attributes(dpy, c->window, XCB_CW_EVENT_MASK, values);
 
-    if (visible && is_visible(d, n)) {
+    if (visible) {
         if (d == m->desk)
             window_show(n->client->window);
         else
@@ -274,17 +263,10 @@ pointer_state_t *make_pointer_state(void)
     p->node = p->vertical_fence = p->horizontal_fence = NULL;
     p->client = NULL;
     p->window = XCB_NONE;
+    p->action = ACTION_NONE;
     return p;
 }
 
-void center(xcb_rectangle_t a, xcb_rectangle_t *b)
-{
-    if (b->width < a.width)
-        b->x = a.x + (a.width - b->width) / 2;
-    if (b->height < a.height)
-        b->y = a.y + (a.height - b->height) / 2;
-}
-
 bool contains(xcb_rectangle_t a, xcb_rectangle_t b)
 {
     return (a.x <= b.x && (a.x + a.width) >= (b.x + b.width)
@@ -403,7 +385,7 @@ void set_fullscreen(node_t *n, bool value)
         ewmh_wm_state_add(c, ewmh->_NET_WM_STATE_FULLSCREEN);
     else
         ewmh_wm_state_remove(c, ewmh->_NET_WM_STATE_FULLSCREEN);
-    stack(n);
+    stack(n, STACK_ABOVE);
 }
 
 void set_floating(node_t *n, bool value)
@@ -426,7 +408,7 @@ void set_floating(node_t *n, bool value)
         rotate_brother(n);
     }
 
-    stack(n);
+    stack(n, STACK_ABOVE);
 }
 
 void set_locked(monitor_t *m, desktop_t *d, node_t *n, bool value)
@@ -676,8 +658,7 @@ void toggle_visibility(void)
         clear_input_focus();
     for (monitor_t *m = mon_head; m != NULL; m = m->next)
         for (node_t *n = first_extrema(m->desk->root); n != NULL; n = next_leaf(n, m->desk->root))
-            if (is_visible(m->desk, n))
-                window_set_visibility(n->client->window, visible);
+            window_set_visibility(n->client->window, visible);
     if (visible)
         update_input_focus();
 }