* screen 1 and you just plugged in screen 1).
*
*/
-void workspace_assign_to(Workspace *ws, Output *screen);
+void workspace_assign_to(Workspace *ws, Output *screen, bool hide_it);
/**
* Initializes the given workspace if it is not already initialized. The given
current_row = c_ws->current_row;
current_col = c_ws->current_col;
DLOG("We're now on output %p\n", output);
+
+ /* While usually this function is only called when the user switches
+ * to a different output using his mouse (and thus the output is
+ * empty), it may be that the following race condition occurs:
+ * 1) the user actives a new output (say VGA1).
+ * 2) the cursor is sent to the first pixel of the new VGA1, thus
+ * generating an enter_notify for the screen (the enter_notify
+ * is not yet received by i3).
+ * 3) i3 requeries screen configuration and maps a workspace onto the
+ * new output.
+ * 4) the enter_notify event arrives and c_ws is set to the new
+ * workspace but the existing windows on the new workspace are not
+ * focused.
+ *
+ * Therefore, we re-set the focus here to be sure it’s correct. */
+ Client *first_client = SLIST_FIRST(&(c_ws->focus_stack));
+ if (first_client != NULL)
+ set_focus(global_conn, first_client, true);
}
/*
workspace->output = output;
output->current_workspace = workspace;
+ /* Copy rect for the workspace */
+ memcpy(&(workspace->rect), &(output->rect), sizeof(Rect));
+
+ /* Map clients on the workspace, if any */
+ workspace_map_clients(conn, workspace);
+
/* Create a xoutput for each output */
Rect bar_rect = {output->rect.x,
output->rect.y + output->rect.height - (font->height + 6),
if (ws->output != output)
continue;
- workspace_assign_to(ws, first);
+ workspace_assign_to(ws, first, true);
if (!needs_init)
continue;
initialize_output(conn, first, ws);
* output 1 and you just plugged in output 1).
*
*/
-void workspace_assign_to(Workspace *ws, Output *output) {
+void workspace_assign_to(Workspace *ws, Output *output, bool hide_it) {
Client *client;
bool empty = true;
bool visible = workspace_is_visible(ws);
render_workspace(global_conn, output, ws);
/* …unless we want to see them at the moment, we should hide that workspace */
- if (visible)
+ if (visible && !hide_it)
return;
workspace_unmap_clients(global_conn, ws);
if (old_output != NULL && ws->output == old_output)
return;
- workspace_assign_to(ws, ws->output);
+ workspace_assign_to(ws, ws->output, false);
}
/*