diff options
| -rw-r--r-- | client.c | 62 | ||||
| -rw-r--r-- | dwm.h | 4 | ||||
| -rw-r--r-- | event.c | 14 | ||||
| -rw-r--r-- | layout.c | 16 |
4 files changed, 56 insertions, 40 deletions
| @@ -97,6 +97,14 @@ attach(Client *c) { | |||
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | void | 99 | void |
| 100 | ban(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 | |||
| 107 | void | ||
| 100 | configure(Client *c) { | 108 | configure(Client *c) { |
| 101 | XConfigureEvent ce; | 109 | XConfigureEvent ce; |
| 102 | 110 | ||
| @@ -299,6 +307,37 @@ togglefloating(const char *arg) { | |||
| 299 | } | 307 | } |
| 300 | 308 | ||
| 301 | void | 309 | void |
| 310 | unban(Client *c) { | ||
| 311 | if (!c->isbanned) | ||
| 312 | return; | ||
| 313 | XMoveWindow(dpy, c->win, c->x, c->y); | ||
| 314 | c->isbanned = False; | ||
| 315 | } | ||
| 316 | |||
| 317 | void | ||
| 318 | unmanage(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 | |||
| 340 | void | ||
| 302 | updatesizehints(Client *c) { | 341 | updatesizehints(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 | |||
| 380 | void | ||
| 381 | unmanage(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 | } | ||
| @@ -96,6 +96,7 @@ extern Window root, barwin; | |||
| 96 | 96 | ||
| 97 | /* client.c */ | 97 | /* client.c */ |
| 98 | void attach(Client *c); /* attaches c to global client list */ | 98 | void attach(Client *c); /* attaches c to global client list */ |
| 99 | void ban(Client *c); /* bans c */ | ||
| 99 | void configure(Client *c); /* send synthetic configure event */ | 100 | void configure(Client *c); /* send synthetic configure event */ |
| 100 | void detach(Client *c); /* detaches c from global client list */ | 101 | void detach(Client *c); /* detaches c from global client list */ |
| 101 | void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */ | 102 | void 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 */ | |||
| 104 | void resize(Client *c, int x, int y, | 105 | void 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*/ |
| 106 | void togglefloating(const char *arg); /* toggles sel between floating/tiled state */ | 107 | void togglefloating(const char *arg); /* toggles sel between floating/tiled state */ |
| 108 | void unban(Client *c); /* unbans c */ | ||
| 109 | void unmanage(Client *c); /* destroy c */ | ||
| 107 | void updatesizehints(Client *c); /* update the size hint variables of c */ | 110 | void updatesizehints(Client *c); /* update the size hint variables of c */ |
| 108 | void updatetitle(Client *c); /* update the name of c */ | 111 | void updatetitle(Client *c); /* update the name of c */ |
| 109 | void unmanage(Client *c); /* destroy c */ | ||
| 110 | 112 | ||
| 111 | /* draw.c */ | 113 | /* draw.c */ |
| 112 | void drawstatus(void); /* draw the bar */ | 114 | void drawstatus(void); /* draw the bar */ |
| @@ -225,6 +225,19 @@ configurenotify(XEvent *e) { | |||
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | static void | 227 | static void |
| 228 | createnotify(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 | |||
| 240 | static void | ||
| 228 | destroynotify(XEvent *e) { | 241 | destroynotify(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, |
| @@ -12,22 +12,6 @@ static unsigned int masterw = MASTERWIDTH; | |||
| 12 | static unsigned int nmaster = NMASTER; | 12 | static unsigned int nmaster = NMASTER; |
| 13 | 13 | ||
| 14 | static void | 14 | static void |
| 15 | ban(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 | |||
| 22 | static void | ||
| 23 | unban(Client *c) { | ||
| 24 | if (!c->isbanned) | ||
| 25 | return; | ||
| 26 | XMoveWindow(dpy, c->win, c->x, c->y); | ||
| 27 | c->isbanned = False; | ||
| 28 | } | ||
| 29 | |||
| 30 | static void | ||
| 31 | tile(void) { | 15 | tile(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; |
