]> git.sur5r.net Git - i3/i3/commitdiff
Restore geometry of all windows before exiting/restarting (Thanks Sasha)
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 2 Mar 2010 14:25:08 +0000 (15:25 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 2 Mar 2010 14:25:08 +0000 (15:25 +0100)
This fixes ticket #185

include/manage.h
src/commands.c
src/manage.c
src/util.c

index 65542d91c088ad0253c46365d8a89cda50aaa7cf..9c87a08ef64fda93ce66d46668026f6dda4d4023 100644 (file)
 void manage_existing_windows(xcb_connection_t *conn, xcb_property_handlers_t
                              *prophs, xcb_window_t root);
 
+/**
+ * Restores the geometry of each window by reparenting it to the root window
+ * at the position of its frame.
+ *
+ * This is to be called *only* before exiting/restarting i3 because of evil
+ * side-effects which are to be expected when continuing to run i3.
+ *
+ */
+void restore_geometry(xcb_connection_t *conn);
+
 /**
  * Do some sanity checks and then reparent the window.
  *
index cdd82513a6ddb17062b00c7d0d23054b007456d0..3aab9b82fc53458a7f37e4cad48293aad7b6e6b3 100644 (file)
@@ -32,6 +32,7 @@
 #include "resize.h"
 #include "log.h"
 #include "sighandler.h"
+#include "manage.h"
 
 bool focus_window_in_container(xcb_connection_t *conn, Container *container, direction_t direction) {
         /* If this container is empty, we’re done */
@@ -977,6 +978,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
         /* Is it an <exit>? */
         if (STARTS_WITH(command, "exit")) {
                 LOG("User issued exit-command, exiting without error.\n");
+                restore_geometry(global_conn);
                 exit(EXIT_SUCCESS);
         }
 
index 93ae48659ff8b525895fc436c95af5a25a728758..c4118641f4bdc914450637738e4960ce0a5658c1 100644 (file)
@@ -63,6 +63,28 @@ void manage_existing_windows(xcb_connection_t *conn, xcb_property_handlers_t *pr
         free(cookies);
 }
 
+/*
+ * Restores the geometry of each window by reparenting it to the root window
+ * at the position of its frame.
+ *
+ * This is to be called *only* before exiting/restarting i3 because of evil
+ * side-effects which are to be expected when continuing to run i3.
+ *
+ */
+void restore_geometry(xcb_connection_t *conn) {
+        Workspace *ws;
+        Client *client;
+        DLOG("Restoring geometry\n");
+
+        TAILQ_FOREACH(ws, workspaces, workspaces)
+                SLIST_FOREACH(client, &(ws->focus_stack), focus_clients)
+                        xcb_reparent_window(conn, client->child, root,
+                                            client->rect.x, client->rect.y);
+
+        /* Make sure our changes reach the X server, we restart/exit now */
+        xcb_flush(conn);
+}
+
 /*
  * Do some sanity checks and then reparent the window.
  *
index 2f8225c0f493707625bfca9f85eef446206fe654..a25a9dcf3eaefe9772e53ee55d80298f27e258f0 100644 (file)
@@ -33,6 +33,7 @@
 #include "client.h"
 #include "log.h"
 #include "ewmh.h"
+#include "manage.h"
 
 static iconv_t conversion_descriptor = 0;
 struct keyvalue_table_head by_parent = TAILQ_HEAD_INITIALIZER(by_parent);
@@ -504,6 +505,8 @@ static char **append_argument(char **original, char *argument) {
  *
  */
 void i3_restart() {
+        restore_geometry(global_conn);
+
         LOG("restarting \"%s\"...\n", start_argv[0]);
         /* make sure -a is in the argument list or append it */
         start_argv = append_argument(start_argv, "-a");