]> git.sur5r.net Git - i3/i3/blobdiff - src/manage.c
Replace strncpy call with memcpy when result is not NUL-terminated
[i3/i3] / src / manage.c
index e35965481a9cb046b971c1717a3f8fb963316607..d591df154a04abbac2f4695fd8e52f7d31f15a42 100644 (file)
@@ -219,7 +219,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
         LOG("This window is of type dock\n");
         Output *output = get_output_containing(geom->x, geom->y);
         if (output != NULL) {
-            DLOG("Starting search at output %s\n", output->name);
+            DLOG("Starting search at output %s\n", output_primary_name(output));
             search_at = output->con;
         }
 
@@ -265,13 +265,9 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
 
             Con *assigned_ws = NULL;
             if (assignment->type == A_TO_WORKSPACE_NUMBER) {
-                Con *output = NULL;
                 long parsed_num = ws_name_to_number(assignment->dest.workspace);
 
-                /* This will only work for workspaces that already exist. */
-                TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
-                    GREP_FIRST(assigned_ws, output_get_content(output), child->num == parsed_num);
-                }
+                assigned_ws = get_existing_workspace_by_num(parsed_num);
             }
             /* A_TO_WORKSPACE type assignment or fallback from A_TO_WORKSPACE_NUMBER
              * when the target workspace number does not exist yet. */
@@ -322,6 +318,10 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
             } else
                 nc = tree_open_con(NULL, cwindow);
         }
+
+        if ((assignment = assignment_for(cwindow, A_TO_OUTPUT))) {
+            con_move_to_output_name(nc, assignment->dest.output, true);
+        }
     } else {
         /* M_BELOW inserts the new window as a child of the one which was
          * matched (e.g. dock areas) */
@@ -384,7 +384,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
              * needed e.g. for LibreOffice Impress multi-monitor
              * presentations to work out of the box. */
             if (output != NULL)
-                con_move_to_output(nc, output);
+                con_move_to_output(nc, output, false);
             con_toggle_fullscreen(nc, CF_OUTPUT);
         }
         fs = NULL;
@@ -642,7 +642,7 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
      * proper window event sequence. */
     if (set_focus && nc->mapped) {
         DLOG("Now setting focus.\n");
-        con_focus(nc);
+        con_activate(nc);
     }
 
     tree_render();
@@ -664,5 +664,4 @@ geom_out:
     free(geom);
 out:
     free(attr);
-    return;
 }