]> git.lizzy.rs Git - bspwm.git/blobdiff - desktop.c
Loop example: fix indentation
[bspwm.git] / desktop.c
index e16fab0062ee428d17cfaba89a7ce64094adb9d6..a76dec27441b581c1eceb19b1bb75e573897fda8 100644 (file)
--- a/desktop.c
+++ b/desktop.c
@@ -1,16 +1,15 @@
-/*
- * Copyright (c) 2012-2014, Bastien Dejean
+/* Copyright (c) 2012, 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:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright notice, this
  *    list of conditions and the following disclaimer.
  * 2. 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
  * 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.
- * 
- * The views and conclusions contained in the software and documentation are those
- * of the authors and should not be interpreted as representing official policies,
- * either expressed or implied, of the FreeBSD Project.
  */
 
 #include <stdlib.h>
@@ -36,6 +31,7 @@
 #include "tree.h"
 #include "window.h"
 #include "desktop.h"
+#include "settings.h"
 
 void focus_desktop(monitor_t *m, desktop_t *d)
 {
@@ -77,7 +73,7 @@ void change_layout(monitor_t *m, desktop_t *d, layout_t l)
 {
        d->layout = l;
        arrange(m, d);
-       if (d == mon->desk)
+       if (d == m->desk)
                put_status();
 }
 
@@ -120,14 +116,19 @@ desktop_t *make_desktop(const char *name)
                snprintf(d->name, sizeof(d->name), "%s%d", DEFAULT_DESK_NAME, ++desktop_uid);
        else
                snprintf(d->name, sizeof(d->name), "%s", name);
-       d->layout = LAYOUT_TILED;
        d->prev = d->next = NULL;
        d->root = d->focus = NULL;
+       initialize_desktop(d);
+       return d;
+}
+
+void initialize_desktop(desktop_t *d)
+{
+       d->layout = LAYOUT_TILED;
        d->top_padding = d->right_padding = d->bottom_padding = d->left_padding = 0;
-       d->window_gap = WINDOW_GAP;
-       d->border_width = BORDER_WIDTH;
+       d->window_gap = window_gap;
+       d->border_width = border_width;
        d->floating = false;
-       return d;
 }
 
 void insert_desktop(monitor_t *m, desktop_t *d)
@@ -187,6 +188,7 @@ void remove_desktop(monitor_t *m, desktop_t *d)
        empty_desktop(d);
        free(d);
        num_desktops--;
+       ewmh_update_current_desktop();
        ewmh_update_number_of_desktops();
        ewmh_update_desktop_names();
        put_status();