added an creatnotify event handler
83aa110c
4 file(s) · +56 −40
| 97 | 97 | } |
|
| 98 | 98 | ||
| 99 | 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 | 108 | configure(Client *c) { |
|
| 101 | 109 | XConfigureEvent ce; |
|
| 102 | 110 | ||
| 299 | 307 | } |
|
| 300 | 308 | ||
| 301 | 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 | 341 | updatesizehints(Client *c) { |
|
| 303 | 342 | long msize; |
|
| 304 | 343 | XSizeHints size; |
|
| 376 | 415 | c->name[sizeof c->name - 1] = '\0'; |
|
| 377 | 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 | 96 | ||
| 97 | 97 | /* client.c */ |
|
| 98 | 98 | void attach(Client *c); /* attaches c to global client list */ |
|
| 99 | + | void ban(Client *c); /* bans c */ |
|
| 99 | 100 | void configure(Client *c); /* send synthetic configure event */ |
|
| 100 | 101 | void detach(Client *c); /* detaches c from global client list */ |
|
| 101 | 102 | void focus(Client *c); /* focus c if visible && !NULL, or focus top visible */ |
|
| 104 | 105 | void resize(Client *c, int x, int y, |
|
| 105 | 106 | int w, int h, Bool sizehints); /* resize with given coordinates c*/ |
|
| 106 | 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 | 110 | void updatesizehints(Client *c); /* update the size hint variables of c */ |
|
| 108 | 111 | void updatetitle(Client *c); /* update the name of c */ |
|
| 109 | - | void unmanage(Client *c); /* destroy c */ |
|
| 110 | 112 | ||
| 111 | 113 | /* draw.c */ |
|
| 112 | 114 | void drawstatus(void); /* draw the bar */ |
|
| 225 | 225 | } |
|
| 226 | 226 | ||
| 227 | 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 | 241 | destroynotify(XEvent *e) { |
|
| 229 | 242 | Client *c; |
|
| 230 | 243 | XDestroyWindowEvent *ev = &e->xdestroywindow; |
|
| 350 | 363 | [ButtonPress] = buttonpress, |
|
| 351 | 364 | [ConfigureRequest] = configurerequest, |
|
| 352 | 365 | [ConfigureNotify] = configurenotify, |
|
| 366 | + | [CreateNotify] = createnotify, |
|
| 353 | 367 | [DestroyNotify] = destroynotify, |
|
| 354 | 368 | [EnterNotify] = enternotify, |
|
| 355 | 369 | [LeaveNotify] = leavenotify, |
|
| 12 | 12 | static unsigned int nmaster = NMASTER; |
|
| 13 | 13 | ||
| 14 | 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 | 15 | tile(void) { |
|
| 32 | 16 | unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; |
|
| 33 | 17 | Client *c; |