]> git.lizzy.rs Git - bspwm.git/blobdiff - restore.c
Implement private windows
[bspwm.git] / restore.c
index 42f0645f8c6c1d02952224955f39a843b8b3ffe9..4a91c9cbb3e31b558c11be70457e465109819027 100644 (file)
--- a/restore.c
+++ b/restore.c
@@ -1,3 +1,27 @@
+/* * Copyright (c) 2012-2013 Bastien Dejean
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ *  * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #include <ctype.h>
 #include <string.h>
 #include "bspwm.h"
@@ -5,6 +29,7 @@
 #include "ewmh.h"
 #include "history.h"
 #include "monitor.h"
+#include "window.h"
 #include "query.h"
 #include "settings.h"
 #include "stack.h"
@@ -60,17 +85,18 @@ void restore_tree(char *file_path)
             if (m == NULL)
                 continue;
             int wg;
-            unsigned int bw;
+            unsigned int tf, bw;
             char layout = 0, end = 0;
             name[0] = '\0';
             loc.desktop = NULL;
-            sscanf(line + level, "%s %u %i %c %c", name, &bw, &wg, &layout, &end);
+            sscanf(line + level, "%s %u %i %u %c %c", name, &bw, &wg, &tf, &layout, &end);
             locate_desktop(name, &loc);
             d = loc.desktop;
             if (d == NULL)
                 continue;
             d->border_width = bw;
             d->window_gap = wg;
+            d->tags_field = tf;
             if (layout == 'M')
                 d->layout = LAYOUT_MONOCLE;
             else if (layout == 'T')
@@ -111,14 +137,16 @@ void restore_tree(char *file_path)
             } else {
                 client_t *c = make_client(XCB_NONE);
                 num_clients++;
-                char floating, transient, fullscreen, urgent, locked, sticky, sd, sm, end = 0;
-                sscanf(line + level, "%c %s %X %u %hux%hu%hi%hi %c %c%c%c%c%c%c%c %c", &br, c->class_name, &c->window, &c->border_width, &c->floating_rectangle.width, &c->floating_rectangle.height, &c->floating_rectangle.x, &c->floating_rectangle.y, &sd, &floating, &transient, &fullscreen, &urgent, &locked, &sticky, &sm, &end);
+                char floating, transient, fullscreen, urgent, locked, sticky, frame, private, sd, sm, end = 0;
+                sscanf(line + level, "%c %s %X %u %u %hux%hu%hi%hi %c %c%c%c%c%c%c%c%c%c %c", &br, c->class_name, &c->window, &c->tags_field, &c->border_width, &c->floating_rectangle.width, &c->floating_rectangle.height, &c->floating_rectangle.x, &c->floating_rectangle.y, &sd, &floating, &transient, &fullscreen, &urgent, &locked, &sticky, &frame, &private, &sm, &end);
                 c->floating = (floating == '-' ? false : true);
                 c->transient = (transient == '-' ? false : true);
                 c->fullscreen = (fullscreen == '-' ? false : true);
                 c->urgent = (urgent == '-' ? false : true);
                 c->locked = (locked == '-' ? false : true);
                 c->sticky = (sticky == '-' ? false : true);
+                c->frame = (frame == '-' ? false : true);
+                c->private = (private == '-' ? false : true);
                 n->split_mode = (sm == '-' ? MODE_AUTOMATIC : MODE_MANUAL);
                 if (sd == 'U')
                     n->split_dir = DIR_UP;
@@ -132,7 +160,7 @@ void restore_tree(char *file_path)
                 if (end != 0)
                     d->focus = n;
                 if (c->sticky)
-                    num_sticky++;
+                    m->num_sticky++;
             }
             if (br == 'a')
                 n->birth_rotation = 90;
@@ -149,12 +177,14 @@ void restore_tree(char *file_path)
     for (monitor_t *m = mon_head; m != NULL; m = m->next)
         for (desktop_t *d = m->desk_head; d != NULL; d = d->next)
             for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root)) {
-                uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK_FFP : CLIENT_EVENT_MASK)};
+                uint32_t values[] = {get_event_mask(n->client)};
                 xcb_change_window_attributes(dpy, n->client->window, XCB_CW_EVENT_MASK, values);
-                if (n->client->floating) {
+                if (n->client->floating || !is_visible(d, n)) {
                     n->vacant = true;
                     update_vacant_state(n->parent);
                 }
+                if (n->client->private)
+                    update_privacy_level(n, true);
             }
     ewmh_update_current_desktop();
 }
@@ -223,11 +253,10 @@ void restore_stack(char *file_path)
     while (fgets(line, sizeof(line), snapshot) != NULL) {
         if (sscanf(line, "%X", &win) == 1) {
             coordinates_t loc;
-            if (win != XCB_NONE && !locate_window(win, &loc)) {
+            if (locate_window(win, &loc))
+                stack_insert_after(stack_tail, loc.node);
+            else
                 warn("Can't locate window 0x%X.\n", win);
-                continue;
-            }
-            stack_insert_after(stack_tail, loc.node);
         } else {
             warn("Can't parse stack entry: '%s'\n", line);
         }