X-Git-Url: https://git.xinqibao.xyz/dwm.git/blobdiff_plain/1d852259526e41ebaad7325ee42c118b1cc12f71..dc5c070c44d9af434405c8d6538abd06299d3298:/client.c

diff --git a/client.c b/client.c
index 6f6ed99..f4ed1a0 100644
--- a/client.c
+++ b/client.c
@@ -3,7 +3,6 @@
  * See LICENSE file for license details.
  */
 #include "dwm.h"
-
 #include <stdlib.h>
 #include <string.h>
 #include <X11/Xatom.h>
@@ -19,7 +18,7 @@ resizetitle(Client *c)
 	c->tw = 0;
 	for(i = 0; i < TLast; i++)
 		if(c->tags[i])
-			c->tw += textw(c->tags[i]);
+			c->tw += textw(tags[i]);
 	c->tw += textw(c->name);
 	if(c->tw > c->w)
 		c->tw = c->w + 2;
@@ -219,12 +218,13 @@ manage(Window w, XWindowAttributes *wa)
 	c->h = wa->height;
 	c->th = bh;
 
-	if(c->y < bh)
+	c->border = 0;
+	setsize(c);
+
+	if(c->h != sh && c->y < bh)
 		c->y = c->ty = bh;
 
-	c->border = 1;
 	c->proto = getproto(c->win);
-	setsize(c);
 	XSelectInput(dpy, c->win,
 		StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
 	XGetTransientForHint(dpy, c->win, &trans);
@@ -237,8 +237,6 @@ manage(Window w, XWindowAttributes *wa)
 			DefaultVisual(dpy, screen),
 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
 
-	settags(c);
-
 	if(clients)
 		clients->prev = c;
 	c->next = clients;
@@ -251,11 +249,11 @@ manage(Window w, XWindowAttributes *wa)
 	XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK,
 			GrabModeAsync, GrabModeSync, None, None);
 
+	settags(c);
 	if(!c->isfloat)
-		c->isfloat = trans || (c->maxw && c->minw &&
-				(c->maxw == c->minw) && (c->maxh == c->minh));
-
-
+		c->isfloat = trans
+			|| (c->maxw && c->minw &&
+				c->maxw == c->minw && c->maxh == c->minh);
 	settitle(c);
 	arrange(NULL);
 
@@ -271,7 +269,8 @@ resize(Client *c, Bool sizehints, Corner sticky)
 {
 	int bottom = c->y + c->h;
 	int right = c->x + c->w;
-	XConfigureEvent e;
+	/*XConfigureEvent e;*/
+	XWindowChanges wc;
 
 	if(sizehints) {
 		if(c->incw)
@@ -287,30 +286,25 @@ resize(Client *c, Bool sizehints, Corner sticky)
 		if(c->maxh && c->h > c->maxh)
 			c->h = c->maxh;
 	}
-	if(c->x > sw) /* might happen on restart */
-		c->x = sw - c->w;
-	if(c->y > sh)
-		c->y = sh - c->h;
+	if(c->x > right) /* might happen on restart */
+		c->x = right - c->w;
+	if(c->y > bottom)
+		c->y = bottom - c->h;
 	if(sticky == TopRight || sticky == BotRight)
 		c->x = right - c->w;
 	if(sticky == BotLeft || sticky == BotRight)
 		c->y = bottom - c->h;
 
 	resizetitle(c);
-	XSetWindowBorderWidth(dpy, c->win, 1);
-	XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
-
-	e.type = ConfigureNotify;
-	e.event = c->win;
-	e.window = c->win;
-	e.x = c->x;
-	e.y = c->y;
-	e.width = c->w;
-	e.height = c->h;
-	e.border_width = c->border;
-	e.above = None;
-	e.override_redirect = False;
-	XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e);
+	wc.x = c->x;
+	wc.y = c->y;
+	wc.width = c->w;
+	wc.height = c->h;
+	if(c->w == sw && c->h == sh)
+		wc.border_width = 0;
+	else
+		wc.border_width = 1;
+	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
 	XSync(dpy, False);
 }
 
@@ -397,8 +391,8 @@ togglemax(Arg *arg)
 		oh = sel->h;
 		sel->x = sx;
 		sel->y = sy + bh;
-		sel->w = sw - 2 * sel->border;
-		sel->h = sh - 2 * sel->border - bh;
+		sel->w = sw - 2;
+		sel->h = sh - 2 - bh;
 
 		higher(sel);
 		resize(sel, False, TopLeft);