summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-06-04 11:50:48 +0200
committerAnselm R. Garbe <arg@suckless.org>2007-06-04 11:50:48 +0200
commit83aa110c6fabbf5f5a14b698a6ca22072cb80629 (patch)
treec79a56f48a11a72a551cf3a9a628362579d11095
parentapplied anudots [un]ban repair patch (diff)
downloaddwm-83aa110c6fabbf5f5a14b698a6ca22072cb80629.tar.gz
dwm-83aa110c6fabbf5f5a14b698a6ca22072cb80629.zip
added an creatnotify event handler
Diffstat (limited to '')
-rw-r--r--client.c62
-rw-r--r--dwm.h4
-rw-r--r--event.c14
-rw-r--r--layout.c16
4 files changed, 56 insertions, 40 deletions
diff --git a/client.c b/client.c
index 06bc9d8..68d10a7 100644
--- a/client.c
+++ b/client.c
@@ -97,6 +97,14 @@ attach(Client *c) {
97} 97}
98 98
99void 99void
100ban(Client *c) {
101 if (c->isbanned)
102 return;
103 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
104 c->isbanned = True;
105}
106
107void
100configure(Client *c) { 108configure(Client *c) {
101 XConfigureEvent ce; 109 XConfigureEvent ce;
102 110
@@ -299,6 +307,37 @@ togglefloating(const char *arg) {
299} 307}
300 308
301void 309void
310unban(Client *c) {
311 if (!c->isbanned)
312 return;
313 XMoveWindow(dpy, c->win, c->x, c->y);
314 c->isbanned = False;
315}
316
317void
318unmanage(Client *c) {
319 XWindowChanges wc;
320
321 wc.border_width = c->oldborder;
322 /* The server grab construct avoids race conditions. */
323 XGrabServer(dpy);
324 XSetErrorHandler(xerrordummy);
325 XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
326 detach(c);
327 detachstack(c);
328 if(sel == c)
329 focus(NULL);
330 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
331 setclientstate(c, WithdrawnState);
332 free(c->tags);
333 free(c);
334 XSync(dpy, False);
335 XSetErrorHandler(xerror);
336 XUngrabServer(dpy);
337 lt->arrange();
338}
339
340void
302updatesizehints(Client *c) { 341updatesizehints(Client *c) {
303 long msize; 342 long msize;
304 XSizeHints size; 343 XSizeHints size;
@@ -376,26 +415,3 @@ updatetitle(Client *c) {
376 c->name[sizeof c->name - 1] = '\0'; 415 c->name[sizeof c->name - 1] = '\0';
377 XFree(name.value); 416 XFree(name.value);
378} 417}
379
380void
381unmanage(Client *c) {
382 XWindowChanges wc;
383
384 wc.border_width = c->oldborder;
385 /* The server grab construct avoids race conditions. */
386 XGrabServer(dpy);
387 XSetErrorHandler(xerrordummy);
388 XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
389 detach(c);
390 detachstack(c);
391 if(sel == c)
392 focus(NULL);
393 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
394 setclientstate(c, WithdrawnState);
395 free(c->tags);
396 free(c);
397 XSync(dpy, False);
398 XSetErrorHandler(xerror);
399 XUngrabServer(dpy);
400 lt->arrange();
401}
diff --git a/dwm.h b/dwm.h
index bd190c6..999f027 100644
--- a/dwm.h
+++ b/dwm.h
@@ -96,6 +96,7 @@ extern Window root, barwin;
96 96
97/* client.c */ 97/* client.c */
98void attach(Client *c); /* attaches c to global client list */ 98void attach(Client *c); /* attaches c to global client list */
99void ban(Client *c); /* bans c */
99void configure(Client *c); /* send synthetic configure event */ 100void configure(Client *c); /* send synthetic configure event */
100void detach(Client *c); /* detaches c from global client list */ 101void detach(Client *c); /* detaches c from global client list */
101void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */ 102void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */
@@ -104,9 +105,10 @@ void manage(Window w, XWindowAttributes *wa); /* manage new client */
104void resize(Client *c, int x, int y, 105void resize(Client *c, int x, int y,
105 int w, int h, Bool sizehints); /* resize with given coordinates c*/ 106 int w, int h, Bool sizehints); /* resize with given coordinates c*/
106void togglefloating(const char *arg); /* toggles sel between floating/tiled state */ 107void togglefloating(const char *arg); /* toggles sel between floating/tiled state */
108void unban(Client *c); /* unbans c */
109void unmanage(Client *c); /* destroy c */
107void updatesizehints(Client *c); /* update the size hint variables of c */ 110void updatesizehints(Client *c); /* update the size hint variables of c */
108void updatetitle(Client *c); /* update the name of c */ 111void updatetitle(Client *c); /* update the name of c */
109void unmanage(Client *c); /* destroy c */
110 112
111/* draw.c */ 113/* draw.c */
112void drawstatus(void); /* draw the bar */ 114void drawstatus(void); /* draw the bar */
diff --git a/event.c b/event.c
index ad4e271..949812f 100644
--- a/event.c
+++ b/event.c
@@ -225,6 +225,19 @@ configurenotify(XEvent *e) {
225} 225}
226 226
227static void 227static void
228createnotify(XEvent *e) {
229 static XWindowAttributes wa;
230 XCreateWindowEvent *ev = &e->xcreatewindow;
231
232 if(!XGetWindowAttributes(dpy, ev->window, &wa))
233 return;
234 if(wa.override_redirect)
235 return;
236 if(!getclient(ev->window) && (wa.map_state == IsViewable))
237 manage(ev->window, &wa);
238}
239
240static void
228destroynotify(XEvent *e) { 241destroynotify(XEvent *e) {
229 Client *c; 242 Client *c;
230 XDestroyWindowEvent *ev = &e->xdestroywindow; 243 XDestroyWindowEvent *ev = &e->xdestroywindow;
@@ -350,6 +363,7 @@ void (*handler[LASTEvent]) (XEvent *) = {
350 [ButtonPress] = buttonpress, 363 [ButtonPress] = buttonpress,
351 [ConfigureRequest] = configurerequest, 364 [ConfigureRequest] = configurerequest,
352 [ConfigureNotify] = configurenotify, 365 [ConfigureNotify] = configurenotify,
366 [CreateNotify] = createnotify,
353 [DestroyNotify] = destroynotify, 367 [DestroyNotify] = destroynotify,
354 [EnterNotify] = enternotify, 368 [EnterNotify] = enternotify,
355 [LeaveNotify] = leavenotify, 369 [LeaveNotify] = leavenotify,
diff --git a/layout.c b/layout.c
index 0706c62..acf0a8e 100644
--- a/layout.c
+++ b/layout.c
@@ -12,22 +12,6 @@ static unsigned int masterw = MASTERWIDTH;
12static unsigned int nmaster = NMASTER; 12static unsigned int nmaster = NMASTER;
13 13
14static void 14static void
15ban(Client *c) {
16 if (c->isbanned)
17 return;
18 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
19 c->isbanned = True;
20}
21
22static void
23unban(Client *c) {
24 if (!c->isbanned)
25 return;
26 XMoveWindow(dpy, c->win, c->x, c->y);
27 c->isbanned = False;
28}
29
30static void
31tile(void) { 15tile(void) {
32 unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; 16 unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
33 Client *c; 17 Client *c;