]> git.sur5r.net Git - i3/i3/commitdiff
Place dock clients on the output corresponding to their geometry request
authorMichael Stapelberg <michael@stapelberg.de>
Mon, 21 Feb 2011 00:28:29 +0000 (01:28 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Mon, 21 Feb 2011 00:28:29 +0000 (01:28 +0100)
include/con.h
src/con.c
src/manage.c

index e8944b62875c16de091a3cc8c5d709cdf5633517..8faf43fc22edceae13bb638a9813a3f186c9aaee 100644 (file)
@@ -83,11 +83,11 @@ Con *con_by_window_id(xcb_window_t window);
 Con *con_by_frame_id(xcb_window_t frame);
 
 /**
- * Returns the first container which wants to swallow this window
+ * Returns the first container below 'con' which wants to swallow this window
  * TODO: priority
  *
  */
-Con *con_for_window(i3Window *window, Match **store_match);
+Con *con_for_window(Con *con, i3Window *window, Match **store_match);
 
 /**
  * Returns the number of children of this container.
index b1e652a28f8499616e5caf34f1a6b29d0df22224..31affbbce415365d66494d85708d7e55078d82ae 100644 (file)
--- a/src/con.c
+++ b/src/con.c
@@ -365,24 +365,41 @@ Con *con_by_frame_id(xcb_window_t frame) {
 }
 
 /*
- * Returns the first container which wants to swallow this window
+ * Returns the first container below 'con' which wants to swallow this window
  * TODO: priority
  *
  */
-Con *con_for_window(i3Window *window, Match **store_match) {
-    Con *con;
+Con *con_for_window(Con *con, i3Window *window, Match **store_match) {
+    Con *child;
     Match *match;
-    DLOG("searching con for window %p\n", window);
+    DLOG("searching con for window %p starting at con %p\n", window, con);
     DLOG("class == %s\n", window->class_class);
 
-    TAILQ_FOREACH(con, &all_cons, all_cons)
-        TAILQ_FOREACH(match, &(con->swallow_head), matches) {
+    TAILQ_FOREACH(child, &(con->nodes_head), nodes) {
+        TAILQ_FOREACH(match, &(child->swallow_head), matches) {
             if (!match_matches_window(match, window))
                 continue;
             if (store_match != NULL)
                 *store_match = match;
-            return con;
+            return child;
         }
+        Con *result = con_for_window(child, window, store_match);
+        if (result != NULL)
+            return result;
+    }
+
+    TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
+        TAILQ_FOREACH(match, &(child->swallow_head), matches) {
+            if (!match_matches_window(match, window))
+                continue;
+            if (store_match != NULL)
+                *store_match = match;
+            return child;
+        }
+        Con *result = con_for_window(child, window, store_match);
+        if (result != NULL)
+            return result;
+    }
 
     return NULL;
 }
index 6b77ec9deb5c0a1347b371e65010a60231133e57..5b60e44cdb1a2fba0bf73ba1c8ce7c7e904bbc38 100644 (file)
@@ -160,8 +160,18 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
 
     /* TODO: assignments */
     /* TODO: two matches for one container */
+
     /* See if any container swallows this new window */
-    nc = con_for_window(cwindow, &match);
+    Con *search_at = croot;
+    if (cwindow->dock) {
+        /* for dock windows, we start the search at the appropriate output */
+        Output *output = get_output_containing(geom->x, geom->y);
+        if (output != NULL) {
+            DLOG("Starting search at output %s\n", output->name);
+            search_at = output->con;
+        }
+    }
+    nc = con_for_window(search_at, cwindow, &match);
     if (nc == NULL) {
         if (focused->type == CT_CON && con_accepts_window(focused)) {
             LOG("using current container, focused = %p, focused->name = %s\n",