about summary refs log tree commit diff stats
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
parent5a1a2edf0e584e660e16d2e01094851e0f9161e2 (diff)
downloaddwm-83aa110c6fabbf5f5a14b698a6ca22072cb80629.tar.gz
added an creatnotify event handler
-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) {
 }
 
 void
+ban(Client *c) {
+	if (c->isbanned)
+		return;
+	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+	c->isbanned = True;
+}
+
+void
 configure(Client *c) {
 	XConfigureEvent ce;
 
@@ -299,6 +307,37 @@ togglefloating(const char *arg) {
 }
 
 void
+unban(Client *c) {
+	if (!c->isbanned)
+		return;
+	XMoveWindow(dpy, c->win, c->x, c->y);
+	c->isbanned = False;
+}
+
+void
+unmanage(Client *c) {
+	XWindowChanges wc;
+
+	wc.border_width = c->oldborder;
+	/* The server grab construct avoids race conditions. */
+	XGrabServer(dpy);
+	XSetErrorHandler(xerrordummy);
+	XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
+	detach(c);
+	detachstack(c);
+	if(sel == c)
+		focus(NULL);
+	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
+	setclientstate(c, WithdrawnState);
+	free(c->tags);
+	free(c);
+	XSync(dpy, False);
+	XSetErrorHandler(xerror);
+	XUngrabServer(dpy);
+	lt->arrange();
+}
+
+void
 updatesizehints(Client *c) {
 	long msize;
 	XSizeHints size;
@@ -376,26 +415,3 @@ updatetitle(Client *c) {
 	c->name[sizeof c->name - 1] = '\0';
 	XFree(name.value);
 }
-
-void
-unmanage(Client *c) {
-	XWindowChanges wc;
-
-	wc.border_width = c->oldborder;
-	/* The server grab construct avoids race conditions. */
-	XGrabServer(dpy);
-	XSetErrorHandler(xerrordummy);
-	XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
-	detach(c);
-	detachstack(c);
-	if(sel == c)
-		focus(NULL);
-	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
-	setclientstate(c, WithdrawnState);
-	free(c->tags);
-	free(c);
-	XSync(dpy, False);
-	XSetErrorHandler(xerror);
-	XUngrabServer(dpy);
-	lt->arrange();
-}
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;
 
 /* client.c */
 void attach(Client *c);			/* attaches c to global client list */
+void ban(Client *c);			/* bans c */
 void configure(Client *c);		/* send synthetic configure event */
 void detach(Client *c);			/* detaches c from global client list */
 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 */
 void resize(Client *c, int x, int y,
 		int w, int h, Bool sizehints);	/* resize with given coordinates c*/
 void togglefloating(const char *arg);	/* toggles sel between floating/tiled state */
+void unban(Client *c);			/* unbans c */
+void unmanage(Client *c);		/* destroy c */
 void updatesizehints(Client *c);	/* update the size hint variables of c */
 void updatetitle(Client *c);		/* update the name of c */
-void unmanage(Client *c);		/* destroy c */
 
 /* draw.c */
 void 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) {
 }
 
 static void
+createnotify(XEvent *e) {
+	static XWindowAttributes wa;
+	XCreateWindowEvent *ev = &e->xcreatewindow;
+
+	if(!XGetWindowAttributes(dpy, ev->window, &wa))
+		return;
+	if(wa.override_redirect)
+		return;
+	if(!getclient(ev->window) && (wa.map_state == IsViewable))
+		manage(ev->window, &wa);
+}
+
+static void
 destroynotify(XEvent *e) {
 	Client *c;
 	XDestroyWindowEvent *ev = &e->xdestroywindow;
@@ -350,6 +363,7 @@ void (*handler[LASTEvent]) (XEvent *) = {
 	[ButtonPress] = buttonpress,
 	[ConfigureRequest] = configurerequest,
 	[ConfigureNotify] = configurenotify,
+	[CreateNotify] = createnotify,
 	[DestroyNotify] = destroynotify,
 	[EnterNotify] = enternotify,
 	[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;
 static unsigned int nmaster = NMASTER;
 
 static void
-ban(Client *c) {
-	if (c->isbanned)
-		return;
-	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
-	c->isbanned = True;
-}
-
-static void
-unban(Client *c) {
-	if (!c->isbanned)
-		return;
-	XMoveWindow(dpy, c->win, c->x, c->y);
-	c->isbanned = False;
-}
-
-static void
 tile(void) {
 	unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
 	Client *c;
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750