about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--client.c50
-rw-r--r--event.c20
-rw-r--r--kb.c2
-rw-r--r--mouse.c52
-rw-r--r--wm.h13
5 files changed, 67 insertions, 70 deletions
diff --git a/client.c b/client.c
index c11d5d5..b1b1417 100644
--- a/client.c
+++ b/client.c
@@ -44,6 +44,24 @@ update_name(Client *c)
 }
 
 void
+update_size(Client *c)
+{
+	XSizeHints size;
+	long msize;
+	if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
+		size.flags = PSize;
+	c->flags = size.flags;
+	c->basew = size.base_width;
+	c->baseh = size.base_height;
+	c->incw = size.width_inc;
+	c->inch = size.height_inc;
+	c->maxw = size.max_width;
+	c->maxh = size.max_height;
+	c->minw = size.min_width;
+	c->minh = size.min_height;
+}
+
+void
 focus(Client *c)
 {
 	Client **l;
@@ -62,31 +80,24 @@ manage(Window w, XWindowAttributes *wa)
 {
 	Client *c, **l;
 	XSetWindowAttributes twa;
-	long msize;
 
 	c = emallocz(sizeof(Client));
 	c->win = w;
-	c->r[RFloat].x = wa->x;
-	c->r[RFloat].y = wa->y;
-	c->r[RFloat].width = wa->width;
-	c->r[RFloat].height = wa->height;
+	c->x = wa->x;
+	c->y = wa->y;
+	c->w = wa->width;
+	c->h = wa->height;
+	update_size(c);
 	XSetWindowBorderWidth(dpy, c->win, 1);
 	XSelectInput(dpy, c->win, CLIENT_MASK);
 	XGetTransientForHint(dpy, c->win, &c->trans);
-	if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
-		c->size.flags = PSize;
-	c->fixedsize =
-		(c->size.flags & PMinSize && c->size.flags & PMaxSize
-		 && c->size.min_width == c->size.max_width
-		 && c->size.min_height == c->size.max_height);
 	update_name(c);
 	twa.override_redirect = 1;
 	twa.background_pixmap = ParentRelative;
 	twa.event_mask = ExposureMask;
 
-	c->title = XCreateWindow(dpy, root, c->r[RFloat].x, c->r[RFloat].y,
-			c->r[RFloat].width, barrect.height, 0,
-			DefaultDepth(dpy, screen), CopyFromParent,
+	c->title = XCreateWindow(dpy, root, c->x, c->y, c->w, barrect.height,
+			0, DefaultDepth(dpy, screen), CopyFromParent,
 			DefaultVisual(dpy, screen),
 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
 
@@ -110,15 +121,14 @@ resize(Client *c)
 {
 	XConfigureEvent e;
 
-	XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y,
-			c->r[RFloat].width, c->r[RFloat].height);
+	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->r[RFloat].x;
-	e.y = c->r[RFloat].y;
-	e.width = c->r[RFloat].width;
-	e.height = c->r[RFloat].height;
+	e.x = c->x;
+	e.y = c->y;
+	e.width = c->w;
+	e.height = c->h;
 	e.border_width = 0;
 	e.above = None;
 	e.override_redirect = False;
diff --git a/event.c b/event.c
index b8b39a4..84b0698 100644
--- a/event.c
+++ b/event.c
@@ -79,13 +79,13 @@ configurerequest(XEvent *e)
 	ev->value_mask &= ~CWSibling;
 	if((c = getclient(ev->window))) {
 		if(ev->value_mask & CWX)
-			c->r[RFloat].x = ev->x;
+			c->x = ev->x;
 		if(ev->value_mask & CWY)
-			c->r[RFloat].y = ev->y;
+			c->y = ev->y;
 		if(ev->value_mask & CWWidth)
-			c->r[RFloat].width = ev->width;
+			c->w = ev->width;
 		if(ev->value_mask & CWHeight)
-			c->r[RFloat].height = ev->height;
+			c->h = ev->height;
 	}
 
 	wc.x = ev->x;
@@ -179,7 +179,6 @@ static void
 propertynotify(XEvent *e)
 {
 	XPropertyEvent *ev = &e->xproperty;
-	long msize;
 	Client *c;
 
 	if(ev->state == PropertyDelete)
@@ -195,16 +194,9 @@ propertynotify(XEvent *e)
 			case XA_WM_TRANSIENT_FOR:
 				XGetTransientForHint(dpy, c->win, &c->trans);
 				break;
+				update_size(c);
 			case XA_WM_NORMAL_HINTS:
-				if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize)
-						|| !c->size.flags)
-					c->size.flags = PSize;
-				if(c->size.flags & PMinSize && c->size.flags & PMaxSize
-						&& c->size.min_width == c->size.max_width
-						&& c->size.min_height == c->size.max_height)
-					c->fixedsize = True;
-				else
-					c->fixedsize = False;
+				update_size(c);
 				break;
 		}
 		if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
diff --git a/kb.c b/kb.c
index 7caae15..b9cf1cb 100644
--- a/kb.c
+++ b/kb.c
@@ -8,7 +8,7 @@
 #include <X11/keysym.h>
 
 static const char *term[] = { 
-	"xterm", "-u8", "-bg", "black", "-fg", "white", "-fn",
+	"xterm", "-bg", "black", "-fg", "white", "-fn",
 	"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", 0 
 };
 
diff --git a/mouse.c b/mouse.c
index 07b533c..577f23c 100644
--- a/mouse.c
+++ b/mouse.c
@@ -16,22 +16,22 @@
 static void
 mmatch(Client *c, int x1, int y1, int x2, int y2)
 {
-	c->r[RFloat].width = abs(x1 - x2);
-	c->r[RFloat].height = abs(y1 - y2);
-	c->r[RFloat].width -=
-		(c->r[RFloat].width - c->size.base_width) % c->size.width_inc;
-	c->r[RFloat].height -=
-		(c->r[RFloat].height - c->size.base_height) % c->size.height_inc;
-	if(c->size.min_width && c->r[RFloat].width < c->size.min_width)
-		c->r[RFloat].width = c->size.min_width;
-	if(c->size.min_height && c->r[RFloat].height < c->size.min_height)
-		c->r[RFloat].height = c->size.min_height;
-	if(c->size.max_width && c->r[RFloat].width > c->size.max_width)
-		c->r[RFloat].width = c->size.max_width;
-	if(c->size.max_height && c->r[RFloat].height > c->size.max_height)
-		c->r[RFloat].height = c->size.max_height;
-	c->r[RFloat].x = (x1 <= x2) ? x1 : x1 - c->r[RFloat].width;
-	c->r[RFloat].y = (y1 <= y2) ? y1 : y1 - c->r[RFloat].height;
+	c->w = abs(x1 - x2);
+	c->h = abs(y1 - y2);
+	if(c->incw)
+		c->w -= (c->w - c->basew) % c->incw;
+	if(c->inch)
+		c->h -= (c->h - c->baseh) % c->inch;
+	if(c->minw && c->w < c->minw)
+		c->w = c->minw;
+	if(c->minh && c->h < c->minh)
+		c->h = c->minh;
+	if(c->maxw && c->w > c->maxw)
+		c->w = c->maxw;
+	if(c->maxh && c->h > c->maxh)
+		c->h = c->maxh;
+	c->x = (x1 <= x2) ? x1 : x1 - c->w;
+	c->y = (y1 <= y2) ? y1 : y1 - c->h;
 }
 
 void
@@ -40,14 +40,13 @@ mresize(Client *c)
 	XEvent ev;
 	int old_cx, old_cy;
 
-	old_cx = c->r[RFloat].x;
-	old_cy = c->r[RFloat].y;
+	old_cx = c->x;
+	old_cy = c->y;
 	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
 				None, cursor[CurResize], CurrentTime) != GrabSuccess)
 		return;
 	XGrabServer(dpy);
-	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
-			c->r[RFloat].width, c->r[RFloat].height);
+	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
 	for(;;) {
 		XMaskEvent(dpy, MouseMask, &ev);
 		switch(ev.type) {
@@ -55,7 +54,7 @@ mresize(Client *c)
 		case MotionNotify:
 			XUngrabServer(dpy);
 			mmatch(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y);
-			XResizeWindow(dpy, c->win, c->r[RFloat].width, c->r[RFloat].height);
+			XResizeWindow(dpy, c->win, c->w, c->h);
 			XGrabServer(dpy);
 			break;
 		case ButtonRelease:
@@ -75,8 +74,8 @@ mmove(Client *c)
 	unsigned int dui;
 	Window dummy;
 
-	old_cx = c->r[RFloat].x;
-	old_cy = c->r[RFloat].y;
+	old_cx = c->x;
+	old_cy = c->y;
 	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
 				None, cursor[CurMove], CurrentTime) != GrabSuccess)
 		return;
@@ -88,10 +87,9 @@ mmove(Client *c)
 		default: break;
 		case MotionNotify:
 			XUngrabServer(dpy);
-			c->r[RFloat].x = old_cx + (ev.xmotion.x - x1);
-			c->r[RFloat].y = old_cy + (ev.xmotion.y - y1);
-			XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y,
-					c->r[RFloat].width, c->r[RFloat].height);
+			c->x = old_cx + (ev.xmotion.x - x1);
+			c->y = old_cy + (ev.xmotion.y - y1);
+			XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
 			XGrabServer(dpy);
 			break;
 		case ButtonRelease:
diff --git a/wm.h b/wm.h
index b647a3e..a24b40d 100644
--- a/wm.h
+++ b/wm.h
@@ -21,19 +21,15 @@ enum { NetSupported, NetWMName, NetLast };
 /* cursor */
 enum { CurNormal, CurResize, CurMove, CurInput, CurLast };
 
-/* rects */
-enum { RFloat, RGrid, RLast };
-
 struct Client {
-	char name[256];
-	char tag[256];
+	char name[256], tag[256];
 	int proto;
-	Bool fixedsize;
+	int x, y, w, h;
+	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+	long flags; 
 	Window win;
 	Window trans;
 	Window title;
-	XSizeHints size;
-	XRectangle r[RLast];
 	Client *next;
 	Client *snext;
 };
@@ -75,6 +71,7 @@ extern void focus(Client *c);
 extern void update_name(Client *c);
 extern void draw_client(Client *c);
 extern void resize(Client *c);
+extern void update_size(Client *c);
 
 /* event.c */
 extern unsigned int discard_events(long even_mask);
ef='#n196'>196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
410
411
412
413
414
415
416
417
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