diff options
Diffstat (limited to 'layout.c')
| -rw-r--r-- | layout.c | 40 |
1 files changed, 40 insertions, 0 deletions
| @@ -1,6 +1,9 @@ | |||
| 1 | /* See LICENSE file for copyright and license details. */ | 1 | /* See LICENSE file for copyright and license details. */ |
| 2 | #include "dwm.h" | 2 | #include "dwm.h" |
| 3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 4 | #include <string.h> | ||
| 5 | #include <X11/Xatom.h> | ||
| 6 | #include <X11/Xutil.h> | ||
| 4 | 7 | ||
| 5 | /* static */ | 8 | /* static */ |
| 6 | 9 | ||
| @@ -10,6 +13,7 @@ typedef struct { | |||
| 10 | } Layout; | 13 | } Layout; |
| 11 | 14 | ||
| 12 | unsigned int blw = 0; | 15 | unsigned int blw = 0; |
| 16 | static char prop[128]; | ||
| 13 | static unsigned int ltidx = 0; /* default */ | 17 | static unsigned int ltidx = 0; /* default */ |
| 14 | 18 | ||
| 15 | static void | 19 | static void |
| @@ -103,6 +107,28 @@ initlayouts(void) { | |||
| 103 | } | 107 | } |
| 104 | } | 108 | } |
| 105 | 109 | ||
| 110 | void | ||
| 111 | loaddwmprops(void) { | ||
| 112 | unsigned int i; | ||
| 113 | XTextProperty name; | ||
| 114 | |||
| 115 | /* check if window has set a property */ | ||
| 116 | name.nitems = 0; | ||
| 117 | XGetTextProperty(dpy, root, &name, dwmprops); | ||
| 118 | if(name.nitems && name.encoding == XA_STRING) { | ||
| 119 | strncpy(prop, (char *)name.value, sizeof prop - 1); | ||
| 120 | prop[sizeof prop - 1] = '\0'; | ||
| 121 | XFree(name.value); | ||
| 122 | for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++) | ||
| 123 | seltags[i] = prop[i] == '1'; | ||
| 124 | if(i < sizeof prop - 1 && prop[i] != '\0') { | ||
| 125 | i = prop[i] - '0'; | ||
| 126 | if(i < nlayouts) | ||
| 127 | ltidx = i; | ||
| 128 | } | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 106 | Client * | 132 | Client * |
| 107 | nexttiled(Client *c) { | 133 | nexttiled(Client *c) { |
| 108 | for(; c && (c->isfloating || !isvisible(c)); c = c->next); | 134 | for(; c && (c->isfloating || !isvisible(c)); c = c->next); |
| @@ -139,6 +165,19 @@ restack(void) { | |||
| 139 | } | 165 | } |
| 140 | 166 | ||
| 141 | void | 167 | void |
| 168 | savedwmprops(void) { | ||
| 169 | unsigned int i; | ||
| 170 | |||
| 171 | for(i = 0; i < ntags && i < sizeof prop - 1; i++) | ||
| 172 | prop[i] = seltags[i] ? '1' : '0'; | ||
| 173 | if(i < sizeof prop - 1) | ||
| 174 | prop[i++] = (char)ltidx; | ||
| 175 | prop[i] = '\0'; | ||
| 176 | XChangeProperty(dpy, root, dwmprops, XA_STRING, 8, | ||
| 177 | PropModeReplace, (unsigned char *)prop, i); | ||
| 178 | } | ||
| 179 | |||
| 180 | void | ||
| 142 | setlayout(const char *arg) { | 181 | setlayout(const char *arg) { |
| 143 | int i; | 182 | int i; |
| 144 | 183 | ||
| @@ -156,6 +195,7 @@ setlayout(const char *arg) { | |||
| 156 | arrange(); | 195 | arrange(); |
| 157 | else | 196 | else |
| 158 | drawstatus(); | 197 | drawstatus(); |
| 198 | savedwmprops(); | ||
| 159 | } | 199 | } |
| 160 | 200 | ||
| 161 | void | 201 | void |
