]> git.sur5r.net Git - i3/i3/commitdiff
Implement a command for hiding all floating windows (and showing them again)
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 19 Jun 2009 11:59:29 +0000 (13:59 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 19 Jun 2009 11:59:29 +0000 (13:59 +0200)
include/data.h
include/floating.h
src/commands.c
src/floating.c

index a31b6982572d9634b560644647a03b6cbcffef45..87dd49953fac816e95b85a0f45ef792946727294 100644 (file)
@@ -163,6 +163,8 @@ struct Workspace {
 
         /* Should clients on this workspace be automatically floating? */
         bool auto_float;
+        /* Are the floating clients on this workspace currently hidden? */
+        bool floating_hidden;
 
         Client *fullscreen_client;
 
index 020e91ff2a3a26d92513f43bfe9b84e2609580e2..edc11a95b77bb04e2170e07a6c6136635646598b 100644 (file)
@@ -52,4 +52,11 @@ void floating_focus_direction(xcb_connection_t *conn, Client *currently_focused,
  */
 void floating_move(xcb_connection_t *conn, Client *currently_focused, direction_t direction);
 
+/**
+ * Hides all floating clients (or show them if they are currently hidden) on
+ * the specified workspace.
+ *
+ */
+void floating_toggle_hide(xcb_connection_t *conn, Workspace *workspace);
+
 #endif
index d809c81a7c9beb8863c8c5fe3cdb41240d9af85a..fb3c5422ea273102d9c7fc79619cd031f358f4ae 100644 (file)
@@ -625,12 +625,9 @@ void show_workspace(xcb_connection_t *conn, int workspace) {
                         xcb_map_window(conn, client->frame);
 
         /* Map all floating clients */
-        SLIST_FOREACH(client, &(c_ws->focus_stack), focus_clients) {
-                if (client->floating <= FLOATING_USER_OFF)
-                        continue;
-
-                xcb_map_window(conn, client->frame);
-        }
+        if (!c_ws->floating_hidden)
+                TAILQ_FOREACH(client, &(c_ws->floating_clients), floating_clients)
+                        xcb_map_window(conn, client->frame);
 
         /* Map all stack windows, if any */
         struct Stack_Window *stack_win;
@@ -854,6 +851,12 @@ void parse_command(xcb_connection_t *conn, const char *command) {
                 return;
         }
 
+        if (command[0] == 'H') {
+                LOG("Hiding all floating windows\n");
+                floating_toggle_hide(conn, c_ws);
+                return;
+        }
+
         enum { WITH_WINDOW, WITH_CONTAINER, WITH_WORKSPACE } with = WITH_WINDOW;
 
         /* Is it a <with>? */
index fb5c95118ff8ea28dc81a06cb1c6df0c717f0ea3..c65f516ed2e67cb72c8bf27a7b257da381f65f4e 100644 (file)
@@ -355,3 +355,31 @@ void floating_move(xcb_connection_t *conn, Client *currently_focused, direction_
         fake_absolute_configure_notify(conn, currently_focused);
         /* fake_absolute_configure_notify flushes */
 }
+
+/*
+ * Hides all floating clients (or show them if they are currently hidden) on
+ * the specified workspace.
+ *
+ */
+void floating_toggle_hide(xcb_connection_t *conn, Workspace *workspace) {
+        Client *client;
+
+        workspace->floating_hidden = !workspace->floating_hidden;
+        LOG("floating_hidden is now: %d\n", workspace->floating_hidden);
+        TAILQ_FOREACH(client, &(workspace->floating_clients), floating_clients) {
+                if (workspace->floating_hidden)
+                        xcb_unmap_window(conn, client->frame);
+                else xcb_map_window(conn, client->frame);
+        }
+
+        /* If we just unmapped all floating windows we should ensure that the focus
+         * is set correctly, that ist, to the first non-floating client in stack */
+        if (workspace->floating_hidden)
+                SLIST_FOREACH(client, &(workspace->focus_stack), focus_clients)
+                        if (client->floating <= FLOATING_USER_OFF) {
+                                set_focus(conn, client, true);
+                                return;
+                        }
+
+        xcb_flush(conn);
+}