From: Michael Stapelberg Date: Sun, 2 Aug 2009 20:31:52 +0000 (+0200) Subject: Bugfix: Don’t hide assigned clients to inactive but visible workspaces (Thanks xeen) X-Git-Tag: 3.c~35 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7cfe5207553feefd6fc4597a73c2af15b61bffb7;p=i3%2Fi3 Bugfix: Don’t hide assigned clients to inactive but visible workspaces (Thanks xeen) --- diff --git a/include/workspace.h b/include/workspace.h index 2b41a527..9c69e55b 100644 --- a/include/workspace.h +++ b/include/workspace.h @@ -24,4 +24,12 @@ */ void workspace_set_name(Workspace *ws, const char *name); +/** + * Returns true if the workspace is currently visible. Especially important for + * multi-monitor environments, as they can have multiple currenlty active + * workspaces. + * + */ +bool workspace_is_visible(Workspace *ws); + #endif diff --git a/src/commands.c b/src/commands.c index 74f8f2a6..16b2152a 100644 --- a/src/commands.c +++ b/src/commands.c @@ -27,6 +27,7 @@ #include "floating.h" #include "xcb.h" #include "config.h" +#include "workspace.h" bool focus_window_in_container(xcb_connection_t *conn, Container *container, direction_t direction) { /* If this container is empty, we’re done */ @@ -490,10 +491,8 @@ static void move_floating_window_to_workspace(xcb_connection_t *conn, Client *cl floating_assign_to_workspace(client, t_ws); - bool target_invisible = t_ws->screen->current_workspace != t_ws->num; - /* If we’re moving it to an invisible screen, we need to unmap it */ - if (target_invisible) { + if (!workspace_is_visible(t_ws)) { LOG("This workspace is not visible, unmapping\n"); xcb_unmap_window(conn, client->frame); } else { @@ -515,7 +514,7 @@ static void move_floating_window_to_workspace(xcb_connection_t *conn, Client *cl render_layout(conn); - if (!target_invisible) + if (workspace_is_visible(t_ws)) set_focus(conn, client, true); } @@ -575,10 +574,8 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa container->currently_focused = to_focus; to_container->currently_focused = current_client; - bool target_invisible = (to_container->workspace->screen->current_workspace != to_container->workspace->num); - /* If we’re moving it to an invisible screen, we need to unmap it */ - if (target_invisible) { + if (!workspace_is_visible(to_container->workspace)) { LOG("This workspace is not visible, unmapping\n"); xcb_unmap_window(conn, current_client->frame); } else { @@ -593,7 +590,7 @@ static void move_current_window_to_workspace(xcb_connection_t *conn, int workspa render_layout(conn); - if (!target_invisible) + if (workspace_is_visible(to_container->workspace)) set_focus(conn, current_client, true); } diff --git a/src/manage.c b/src/manage.c index 5d246833..12d96c8c 100644 --- a/src/manage.c +++ b/src/manage.c @@ -29,6 +29,7 @@ #include "manage.h" #include "floating.h" #include "client.h" +#include "workspace.h" /* * Go through all existing windows (if the window manager is restarted) and manage them @@ -325,7 +326,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child, break; } - LOG("Changin container/workspace and unmapping the client\n"); + LOG("Changing container/workspace and unmapping the client\n"); Workspace *t_ws = &(workspaces[assign->workspace-1]); if (t_ws->screen == NULL) { LOG("initializing new workspace, setting num to %d\n", assign->workspace); @@ -338,7 +339,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child, new->workspace = t_ws; old_focused = new->container->currently_focused; - map_frame = false; + map_frame = workspace_is_visible(t_ws); break; } } diff --git a/src/workspace.c b/src/workspace.c index d3de73e4..1e2aaf4f 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -45,3 +45,13 @@ void workspace_set_name(Workspace *ws, const char *name) { free(label); } + +/* + * Returns true if the workspace is currently visible. Especially important for + * multi-monitor environments, as they can have multiple currenlty active + * workspaces. + * + */ +bool workspace_is_visible(Workspace *ws) { + return (ws->screen->current_workspace == ws->num); +}