+ /* 'ws' may be invalid because of the assignments, e.g. when the user uses
+ * "move window to workspace 1", but had it assigned to workspace 2. */
+ ws = con_get_workspace(nc);
+
+ /* If this window was put onto an invisible workspace (via assignments), we
+ * render this workspace. It wouldn’t be rendered in our normal code path
+ * because only the visible workspaces get rendered.
+ *
+ * By rendering the workspace, we assign proper coordinates (read: not
+ * width=0, height=0) to the window, which is important for windows who
+ * actually use them to position their GUI elements, e.g. rhythmbox. */
+ if (ws && !workspace_is_visible(ws)) {
+ /* This is a bit hackish: we need to copy the content container’s rect
+ * to the workspace, because calling render_con() on the content
+ * container would also take the shortcut and not render the invisible
+ * workspace at all. However, just calling render_con() on the
+ * workspace isn’t enough either — it needs the rect. */
+ ws->rect = ws->parent->rect;
+ render_con(ws, true);
+ /* Disable setting focus, otherwise we’d move focus to an invisible
+ * workspace, which we generally prevent (e.g. in
+ * con_move_to_workspace). */
+ set_focus = false;
+ }
+ render_con(croot, false);
+
+ /* Send an event about window creation */
+ ipc_send_window_event("new", nc);
+
+ /* Defer setting focus after the 'new' event has been sent to ensure the
+ * proper window event sequence. */
+ if (set_focus) {
+ DLOG("Now setting focus.\n");
+ con_focus(nc);
+ }
+