From: Michael Stapelberg Date: Fri, 12 Nov 2010 16:34:13 +0000 (+0100) Subject: don’t close workspaces which are still visible (multi-monitor) X-Git-Tag: tree-pr1~130 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c6c084faa5024a227c77a55397896b35b38f88fc;p=i3%2Fi3 don’t close workspaces which are still visible (multi-monitor) --- diff --git a/include/workspace.h b/include/workspace.h index 28b7e571..a2c1836e 100644 --- a/include/workspace.h +++ b/include/workspace.h @@ -34,6 +34,7 @@ Con *workspace_get(const char *num); * */ void workspace_set_name(Workspace *ws, const char *name); +#endif /** * Returns true if the workspace is currently visible. Especially important for @@ -41,9 +42,8 @@ void workspace_set_name(Workspace *ws, const char *name); * workspaces. * */ -bool workspace_is_visible(Workspace *ws); +bool workspace_is_visible(Con *ws); -#endif /** Switches to the given workspace */ void workspace_show(const char *num); diff --git a/src/workspace.c b/src/workspace.c index 81492240..06f742d7 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -80,6 +80,7 @@ void workspace_set_name(Workspace *ws, const char *name) { else ws->text_width = 0; ws->utf8_name = label; } +#endif /* * Returns true if the workspace is currently visible. Especially important for @@ -87,10 +88,14 @@ void workspace_set_name(Workspace *ws, const char *name) { * workspaces. * */ -bool workspace_is_visible(Workspace *ws) { - return (ws->output != NULL && ws->output->current_workspace == ws); +bool workspace_is_visible(Con *ws) { + Con *output = con_get_output(ws); + if (output == NULL) + return false; + Con *fs = con_get_fullscreen_con(output); + LOG("workspace visible? fs = %p, ws = %p\n", fs, ws); + return (fs == ws); } -#endif /* * XXX: we need to clean up all this recursive walking code. @@ -197,8 +202,11 @@ void workspace_show(const char *num) { if (TAILQ_EMPTY(&(old->nodes_head))) { - LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name); - tree_close(old, false); + /* check if this workspace is currently visible */ + if (!workspace_is_visible(old)) { + LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name); + tree_close(old, false); + } } con_focus(next);