summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'client.c')
-rw-r--r--client.c50
1 files changed, 7 insertions, 43 deletions
diff --git a/client.c b/client.c
index c03770b..9dd08b1 100644
--- a/client.c
+++ b/client.c
@@ -1,14 +1,11 @@
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> 4#include <X11/Xatom.h>
6#include <X11/Xutil.h> 5#include <X11/Xutil.h>
7 6
8/* static */ 7/* static */
9 8
10static char buf[128];
11
12static void 9static void
13attachstack(Client *c) { 10attachstack(Client *c) {
14 c->snext = stack; 11 c->snext = stack;
@@ -102,10 +99,8 @@ void
102ban(Client *c) { 99ban(Client *c) {
103 if(c->isbanned) 100 if(c->isbanned)
104 return; 101 return;
105 XUnmapWindow(dpy, c->win); 102 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
106 setclientstate(c, IconicState);
107 c->isbanned = True; 103 c->isbanned = True;
108 c->unmapped++;
109} 104}
110 105
111void 106void
@@ -181,21 +176,6 @@ killclient(const char *arg) {
181 XKillClient(dpy, sel->win); 176 XKillClient(dpy, sel->win);
182} 177}
183 178
184Bool
185getprops(Client *c) {
186 unsigned int i;
187 Bool result = False;
188
189 if(gettextprop(c->win, dwmprops, buf, sizeof buf)) {
190 for(i = 0; i < ntags && i < sizeof buf - 1 && buf[i] != '\0'; i++)
191 if((c->tags[i] = buf[i] == '1'))
192 result = True;
193 if(i < sizeof buf - 1 && buf[i] != '\0')
194 c->isfloating = buf[i] == '1';
195 }
196 return result;
197}
198
199void 179void
200manage(Window w, XWindowAttributes *wa) { 180manage(Window w, XWindowAttributes *wa) {
201 unsigned int i; 181 unsigned int i;
@@ -242,15 +222,14 @@ manage(Window w, XWindowAttributes *wa) {
242 if(t) 222 if(t)
243 for(i = 0; i < ntags; i++) 223 for(i = 0; i < ntags; i++)
244 c->tags[i] = t->tags[i]; 224 c->tags[i] = t->tags[i];
245 if(!getprops(c)) 225 applyrules(c);
246 applyrules(c);
247 if(!c->isfloating) 226 if(!c->isfloating)
248 c->isfloating = (rettrans == Success) || c->isfixed; 227 c->isfloating = (rettrans == Success) || c->isfixed;
249 setprops(c);
250 attach(c); 228 attach(c);
251 attachstack(c); 229 attachstack(c);
252 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */ 230 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */
253 ban(c); 231 ban(c);
232 XMapWindow(dpy, c->win);
254 arrange(); 233 arrange();
255} 234}
256 235
@@ -318,29 +297,15 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
318} 297}
319 298
320void 299void
321setprops(Client *c) {
322 unsigned int i;
323
324 for(i = 0; i < ntags && i < sizeof buf - 1; i++)
325 buf[i] = c->tags[i] ? '1' : '0';
326 if(i < sizeof buf - 1)
327 buf[i++] = c->isfloating ? '1' : '0';
328 buf[i] = '\0';
329 XChangeProperty(dpy, c->win, dwmprops, XA_STRING, 8,
330 PropModeReplace, (unsigned char *)buf, i);
331}
332
333void
334unban(Client *c) { 300unban(Client *c) {
335 if(!c->isbanned) 301 if(!c->isbanned)
336 return; 302 return;
337 XMapWindow(dpy, c->win); 303 XMoveWindow(dpy, c->win, c->x, c->y);
338 setclientstate(c, NormalState);
339 c->isbanned = False; 304 c->isbanned = False;
340} 305}
341 306
342void 307void
343unmanage(Client *c, long state) { 308unmanage(Client *c) {
344 XWindowChanges wc; 309 XWindowChanges wc;
345 310
346 wc.border_width = c->oldborder; 311 wc.border_width = c->oldborder;
@@ -353,14 +318,13 @@ unmanage(Client *c, long state) {
353 if(sel == c) 318 if(sel == c)
354 focus(NULL); 319 focus(NULL);
355 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 320 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
356 setclientstate(c, state); 321 setclientstate(c, WithdrawnState);
357 free(c->tags); 322 free(c->tags);
358 free(c); 323 free(c);
359 XSync(dpy, False); 324 XSync(dpy, False);
360 XSetErrorHandler(xerror); 325 XSetErrorHandler(xerror);
361 XUngrabServer(dpy); 326 XUngrabServer(dpy);
362 if(state != NormalState) 327 arrange();
363 arrange();
364} 328}
365 329
366void 330void