about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R. Garbe <arg@suckless.org>2007-02-07 12:37:06 +0100
committerAnselm R. Garbe <arg@suckless.org>2007-02-07 12:37:06 +0100
commit28ffff801bb0137ec3fe4093afc4fb29784b17ec (patch)
tree2072e2465fb0b3cbf4f3241a096de99752e79be1
parent44ef3f5a07753ecaeacc2fb180e90bf4479ab975 (diff)
downloaddwm-28ffff801bb0137ec3fe4093afc4fb29784b17ec.tar.gz
replaced getproto with a saner function, now old-school artifacts of WM times in the early 90s completely disappeared, no punned pointer warning anymore ;)
-rw-r--r--client.c18
-rw-r--r--config.mk4
-rw-r--r--dwm.h7
-rw-r--r--event.c4
-rw-r--r--main.c18
5 files changed, 20 insertions, 31 deletions
diff --git a/client.c b/client.c
index 50e8a94..e37b9e6 100644
--- a/client.c
+++ b/client.c
@@ -120,11 +120,26 @@ getclient(Window w) {
 	return NULL;
 }
 
+Bool
+isprotodel(Client *c) {
+	int i, n;
+	Atom *protocols;
+	Bool ret = False;
+
+	if(XGetWMProtocols(dpy, c->win, &protocols, &n)) {
+		for(i = 0; !ret && i < n; i++)
+			if(protocols[i] == wmatom[WMDelete])
+				ret = True;
+		XFree(protocols);
+	}
+	return ret;
+}
+
 void
 killclient(Arg *arg) {
 	if(!sel)
 		return;
-	if(sel->proto & PROTODELWIN)
+	if(isprotodel(sel))
 		sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
 	else
 		XKillClient(dpy, sel->win);
@@ -159,7 +174,6 @@ manage(Window w, XWindowAttributes *wa) {
 			c->y = way;
 	}
 	updatesizehints(c);
-	c->proto = getproto(c->win);
 	XSelectInput(dpy, c->win,
 		StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
 	XGetTransientForHint(dpy, c->win, &trans);
diff --git a/config.mk b/config.mk
index 338632d..2e5630a 100644
--- a/config.mk
+++ b/config.mk
@@ -17,8 +17,8 @@ LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
 # flags
 CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
 LDFLAGS = ${LIBS}
-#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
-#LDFLAGS = -g ${LIBS}
+CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
+LDFLAGS = -g ${LIBS}
 
 # Solaris
 #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
diff --git a/dwm.h b/dwm.h
index a7053c5..674ab1e 100644
--- a/dwm.h
+++ b/dwm.h
@@ -36,8 +36,6 @@
 
 /* mask shorthands, used in event.c and client.c */
 #define BUTTONMASK		(ButtonPressMask | ButtonReleaseMask)
-/* other stuff used in different places */
-#define PROTODELWIN		1
 
 enum { NetSupported, NetWMName, NetLast };		/* EWMH atoms */
 enum { WMProtocols, WMDelete, WMState, WMLast };	/* default atoms */
@@ -69,14 +67,13 @@ typedef struct {
 typedef struct Client Client;
 struct Client {
 	char name[256];
-	int proto;
 	int x, y, w, h;
 	int rx, ry, rw, rh; /* revert geometry */
 	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
 	int minax, minay, maxax, maxay;
 	long flags; 
 	unsigned int border;
-	Bool isfloat, isfixed, ismax;
+	Bool isfixed, isfloat, ismax;
 	Bool *tags;
 	Client *next;
 	Client *prev;
@@ -105,6 +102,7 @@ extern Window root, barwin;
 extern void configure(Client *c);		/* send synthetic configure event */
 extern void focus(Client *c);			/* focus c, c may be NULL */
 extern Client *getclient(Window w);		/* return client of w */
+extern Bool isprotodel(Client *c);		/* returns True if c->win supports wmatom[WMDelete] */
 extern void killclient(Arg *arg);		/* kill c nicely */
 extern void manage(Window w, XWindowAttributes *wa);	/* manage new client */
 extern void resize(Client *c, Bool sizehints);	/* resize c*/
@@ -123,7 +121,6 @@ extern void grabkeys(void);			/* grab all keys defined in config.h */
 extern void procevent(void);			/* process pending X events */
 
 /* main.c */
-extern int getproto(Window w);			/* return protocol mask of WMProtocols property of w */
 extern void quit(Arg *arg);			/* quit dwm nicely */
 extern void sendevent(Window w, Atom a, long value);	/* send synthetic event to w */
 extern int xerror(Display *dsply, XErrorEvent *ee);	/* dwm's X error handler */
diff --git a/event.c b/event.c
index 418e986..c66aa72 100644
--- a/event.c
+++ b/event.c
@@ -308,10 +308,6 @@ propertynotify(XEvent *e) {
 	if(ev->state == PropertyDelete)
 		return; /* ignore */
 	if((c = getclient(ev->window))) {
-		if(ev->atom == wmatom[WMProtocols]) {
-			c->proto = getproto(c->win);
-			return;
-		}
 		switch (ev->atom) {
 			default: break;
 			case XA_WM_TRANSIENT_FOR:
diff --git a/main.c b/main.c
index 97fdbaf..da95d95 100644
--- a/main.c
+++ b/main.c
@@ -172,24 +172,6 @@ xerrorstart(Display *dsply, XErrorEvent *ee) {
 
 /* extern */
 
-int
-getproto(Window w) {
-	int i, format, protos, status;
-	unsigned long extra, res;
-	Atom *protocols, real;
-
-	protos = 0;
-	status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L, False,
-			XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols);
-	if(status != Success || protocols == 0)
-		return protos;
-	for(i = 0; i < res; i++)
-		if(protocols[i] == wmatom[WMDelete])
-			protos |= PROTODELWIN;
-	free(protocols);
-	return protos;
-}
-
 void
 sendevent(Window w, Atom a, long value) {
 	XEvent e;
ef='#n422'>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