]> git.sur5r.net Git - i3/i3/blobdiff - src/manage.c
nagbar: use less / vi as fallbacks for PAGER / EDITOR
[i3/i3] / src / manage.c
index fa948bec4540b332b852f542aeaba7556f2e4c5b..bcce8ab1fc502fb1779ec1f4147b59ec1a9fc893 100644 (file)
@@ -117,16 +117,14 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
         goto out;
     }
 
-    uint32_t mask = 0;
     uint32_t values[1];
 
     /* Set a temporary event mask for the new window, consisting only of
      * PropertyChange. We need to be notified of PropertyChanges because the
      * client can change its properties *after* we requested them but *before*
      * we actually reparented it and have set our final event mask. */
-    mask = XCB_CW_EVENT_MASK;
     values[0] = XCB_EVENT_MASK_PROPERTY_CHANGE;
-    xcb_change_window_attributes(conn, window, mask, values);
+    xcb_change_window_attributes(conn, window, XCB_CW_EVENT_MASK, values);
 
 #define GET_PROPERTY(atom, len) xcb_get_property_unchecked(conn, false, window, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, len)
 
@@ -219,8 +217,8 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
                 nc = con_descend_focused(workspace_get(assignment->dest.workspace, NULL));
                 DLOG("focused on ws %s: %p / %s\n", assignment->dest.workspace, nc, nc->name);
                 if (nc->type == CT_WORKSPACE)
-                    nc = tree_open_con(nc);
-                else nc = tree_open_con(nc->parent);
+                    nc = tree_open_con(nc, cwindow);
+                else nc = tree_open_con(nc->parent, cwindow);
             }
         /* TODO: handle assignments with type == A_TO_OUTPUT */
         } else {
@@ -229,13 +227,13 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
                 LOG("using current container, focused = %p, focused->name = %s\n",
                                 focused, focused->name);
                 nc = focused;
-            } else nc = tree_open_con(NULL);
+            } else nc = tree_open_con(NULL, cwindow);
         }
     } else {
         /* M_BELOW inserts the new window as a child of the one which was
          * matched (e.g. dock areas) */
         if (match != NULL && match->insert_where == M_BELOW) {
-            nc = tree_open_con(nc);
+            nc = tree_open_con(nc, cwindow);
         }
     }
 
@@ -251,7 +249,9 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
     free(name);
 
     Con *ws = con_get_workspace(nc);
-    Con *fs = (ws ? con_get_fullscreen_con(ws) : NULL);
+    Con *fs = (ws ? con_get_fullscreen_con(ws, CF_OUTPUT) : NULL);
+    if (fs == NULL)
+        fs = con_get_fullscreen_con(croot, CF_GLOBAL);
 
     if (fs == NULL) {
         DLOG("Not in fullscreen mode, focusing\n");
@@ -264,8 +264,13 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
          * focused (fullscreen) con. This way, the new container will be
          * focused after we return from fullscreen mode */
         Con *first = TAILQ_FIRST(&(nc->parent->focus_head));
-        TAILQ_REMOVE(&(nc->parent->focus_head), nc, focused);
-        TAILQ_INSERT_AFTER(&(nc->parent->focus_head), first, nc, focused);
+        if (first != nc) {
+            /* We only modify the focus stack if the container is not already
+             * the first one. This can happen when existing containers swallow
+             * new windows, for example when restarting. */
+            TAILQ_REMOVE(&(nc->parent->focus_head), nc, focused);
+            TAILQ_INSERT_AFTER(&(nc->parent->focus_head), first, nc, focused);
+        }
     }
 
     /* set floating if necessary */
@@ -288,7 +293,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
         if (config.popup_during_fullscreen == PDF_LEAVE_FULLSCREEN &&
             fs != NULL) {
             LOG("There is a fullscreen window, leaving fullscreen mode\n");
-            con_toggle_fullscreen(fs);
+            con_toggle_fullscreen(fs, CF_OUTPUT);
         }
     }
 
@@ -319,14 +324,13 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
         goto out;
     }
 
-    mask = XCB_CW_EVENT_MASK;
-    values[0] = CHILD_EVENT_MASK;
-    xcb_change_window_attributes(conn, window, mask, values);
+    values[0] = CHILD_EVENT_MASK & ~XCB_EVENT_MASK_ENTER_WINDOW;
+    xcb_change_window_attributes(conn, window, XCB_CW_EVENT_MASK, values);
     xcb_flush(conn);
 
     reply = xcb_get_property_reply(conn, state_cookie, NULL);
     if (xcb_reply_contains_atom(reply, A__NET_WM_STATE_FULLSCREEN))
-        con_toggle_fullscreen(nc);
+        con_toggle_fullscreen(nc, CF_OUTPUT);
 
     /* Put the client inside the save set. Upon termination (whether killed or
      * normal exit does not matter) of the window manager, these clients will