dwm.c
changeset 1343 f4707b7bd3a2
parent 1342 a2f37186527c
child 1344 ba02dda36aee
equal deleted inserted replaced
1342:a2f37186527c 1343:f4707b7bd3a2
    22  * Keys and tagging rules are organized as arrays and defined in config.h.
    22  * Keys and tagging rules are organized as arrays and defined in config.h.
    23  *
    23  *
    24  * To understand everything else, start reading main().
    24  * To understand everything else, start reading main().
    25  */
    25  */
    26 #include <errno.h>
    26 #include <errno.h>
       
    27 #include <locale.h>
    27 #include <stdarg.h>
    28 #include <stdarg.h>
    28 #include <stdio.h>
    29 #include <stdio.h>
    29 #include <stdlib.h>
    30 #include <stdlib.h>
    30 #include <string.h>
    31 #include <string.h>
    31 #include <unistd.h>
    32 #include <unistd.h>
  1044 	readin = running = False;
  1045 	readin = running = False;
  1045 }
  1046 }
  1046 
  1047 
  1047 void
  1048 void
  1048 resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
  1049 resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
  1049 	float a;
       
  1050 	XWindowChanges wc;
  1050 	XWindowChanges wc;
  1051 
  1051 
  1052 	if(sizehints) {
  1052 	if(sizehints) {
  1053 		/* see last two sentences in ICCCM 4.1.2.3 */
  1053 		/* see last two sentences in ICCCM 4.1.2.3 */
  1054 		Bool baseismin = c->basew == c->minw && c->baseh == c->minh;
  1054 		Bool baseismin = c->basew == c->minw && c->baseh == c->minh;
  1062 			h -= c->baseh;
  1062 			h -= c->baseh;
  1063 		}
  1063 		}
  1064 
  1064 
  1065 		/* adjust for aspect limits */
  1065 		/* adjust for aspect limits */
  1066 		if(c->mina > 0 && c->maxa > 0) {
  1066 		if(c->mina > 0 && c->maxa > 0) {
  1067 			a = (float) w/h;
  1067 			if(c->maxa < (float)(w / h))
  1068 			if(a > c->maxa)
       
  1069 				w = h * c->maxa;
  1068 				w = h * c->maxa;
  1070 			else if(a < c->mina)
  1069 			else if(c->mina < (float)(h / w))
  1071 				h = w / c->mina;
  1070 				h = w * c->mina;
  1072 		}
  1071 		}
  1073 
  1072 
  1074 		if(baseismin) { /* increment calculation requires this */
  1073 		if(baseismin) { /* increment calculation requires this */
  1075 			w -= c->basew;
  1074 			w -= c->basew;
  1076 			h -= c->baseh;
  1075 			h -= c->baseh;
  1710 	if(argc == 2 && !strcmp("-v", argv[1]))
  1709 	if(argc == 2 && !strcmp("-v", argv[1]))
  1711 		die("dwm-"VERSION", © 2006-2008 dwm engineers, see LICENSE for details\n");
  1710 		die("dwm-"VERSION", © 2006-2008 dwm engineers, see LICENSE for details\n");
  1712 	else if(argc != 1)
  1711 	else if(argc != 1)
  1713 		die("usage: dwm [-v]\n");
  1712 		die("usage: dwm [-v]\n");
  1714 
  1713 
  1715 	if(!XSupportsLocale())
  1714 	if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
  1716 		fprintf(stderr, "warning: no locale support\n");
  1715 		fprintf(stderr, "warning: no locale support\n");
  1717 
  1716 
  1718 	if(!(dpy = XOpenDisplay(0)))
  1717 	if(!(dpy = XOpenDisplay(0)))
  1719 		die("dwm: cannot open display\n");
  1718 		die("dwm: cannot open display\n");
  1720 
  1719