From c6c084faa5024a227c77a55397896b35b38f88fc Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 12 Nov 2010 17:34:13 +0100 Subject: [PATCH] =?utf8?q?don=E2=80=99t=20close=20workspaces=20which=20are?= =?utf8?q?=20still=20visible=20(multi-monitor)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- include/workspace.h | 4 ++-- src/workspace.c | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) 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); -- 2.39.5