dwm.c
changeset 1390 c0534213fc52
parent 1389 b4e7c220422d
child 1391 1409113e7808
equal deleted inserted replaced
1389:b4e7c220422d 1390:c0534213fc52
   127 	Bool isfloating;
   127 	Bool isfloating;
   128 } Rule;
   128 } Rule;
   129 
   129 
   130 /* function declarations */
   130 /* function declarations */
   131 static void applyrules(Client *c);
   131 static void applyrules(Client *c);
       
   132 static void applysizehints(Client *c, int *w, int *h);
   132 static void arrange(void);
   133 static void arrange(void);
   133 static void attach(Client *c);
   134 static void attach(Client *c);
   134 static void attachstack(Client *c);
   135 static void attachstack(Client *c);
   135 static void buttonpress(XEvent *e);
   136 static void buttonpress(XEvent *e);
   136 static void checkotherwm(void);
   137 static void checkotherwm(void);
   269 	if(!c->tags)
   270 	if(!c->tags)
   270 		c->tags = tagset[seltags];
   271 		c->tags = tagset[seltags];
   271 }
   272 }
   272 
   273 
   273 void
   274 void
       
   275 applysizehints(Client *c, int *w, int *h) {
       
   276 	Bool baseismin;
       
   277 
       
   278 	/* see last two sentences in ICCCM 4.1.2.3 */
       
   279 	baseismin = c->basew == c->minw && c->baseh == c->minh;
       
   280 
       
   281 	/* set minimum possible */
       
   282 	*w = MAX(1, *w);
       
   283 	*h = MAX(1, *h);
       
   284 
       
   285 	if(!baseismin) { /* temporarily remove base dimensions */
       
   286 		*w -= c->basew;
       
   287 		*h -= c->baseh;
       
   288 	}
       
   289 
       
   290 	/* adjust for aspect limits */
       
   291 	if(c->mina > 0 && c->maxa > 0) {
       
   292 		if(c->maxa < (float)*w / *h)
       
   293 			*w = *h * c->maxa;
       
   294 		else if(c->mina < (float)*h / *w)
       
   295 			*h = *w * c->mina;
       
   296 	}
       
   297 
       
   298 	if(baseismin) { /* increment calculation requires this */
       
   299 		*w -= c->basew;
       
   300 		*h -= c->baseh;
       
   301 	}
       
   302 
       
   303 	/* adjust for increment value */
       
   304 	if(c->incw)
       
   305 		*w -= *w % c->incw;
       
   306 	if(c->inch)
       
   307 		*h -= *h % c->inch;
       
   308 
       
   309 	/* restore base dimensions */
       
   310 	*w += c->basew;
       
   311 	*h += c->baseh;
       
   312 
       
   313 	*w = MAX(*w, c->minw);
       
   314 	*h = MAX(*h, c->minh);
       
   315 
       
   316 	if(c->maxw)
       
   317 		*w = MIN(*w, c->maxw);
       
   318 
       
   319 	if(c->maxh)
       
   320 		*h = MIN(*h, c->maxh);
       
   321 }
       
   322 
       
   323 void
   274 arrange(void) {
   324 arrange(void) {
   275 	unsigned int nt;
   325 	unsigned int nt;
   276 	Client *c;
   326 	Client *c;
   277 
   327 
   278 	for(nt = 0, c = nexttiled(clients); c; c = nexttiled(c->next), nt++);
   328 	for(nt = 0, c = nexttiled(clients); c; c = nexttiled(c->next), nt++);
  1036 
  1086 
  1037 void
  1087 void
  1038 resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
  1088 resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
  1039 	XWindowChanges wc;
  1089 	XWindowChanges wc;
  1040 
  1090 
  1041 	if(sizehints) {
  1091 	if(sizehints)
  1042 		/* see last two sentences in ICCCM 4.1.2.3 */
  1092 		applysizehints(c, &w, &h);
  1043 		Bool baseismin = c->basew == c->minw && c->baseh == c->minh;
       
  1044 
       
  1045 		/* set minimum possible */
       
  1046 		w = MAX(1, w);
       
  1047 		h = MAX(1, h);
       
  1048 
       
  1049 		if(!baseismin) { /* temporarily remove base dimensions */
       
  1050 			w -= c->basew;
       
  1051 			h -= c->baseh;
       
  1052 		}
       
  1053 
       
  1054 		/* adjust for aspect limits */
       
  1055 		if(c->mina > 0 && c->maxa > 0) {
       
  1056 			if(c->maxa < (float)w / h)
       
  1057 				w = h * c->maxa;
       
  1058 			else if(c->mina < (float)h / w)
       
  1059 				h = w * c->mina;
       
  1060 		}
       
  1061 
       
  1062 		if(baseismin) { /* increment calculation requires this */
       
  1063 			w -= c->basew;
       
  1064 			h -= c->baseh;
       
  1065 		}
       
  1066 
       
  1067 		/* adjust for increment value */
       
  1068 		if(c->incw)
       
  1069 			w -= w % c->incw;
       
  1070 		if(c->inch)
       
  1071 			h -= h % c->inch;
       
  1072 
       
  1073 		/* restore base dimensions */
       
  1074 		w += c->basew;
       
  1075 		h += c->baseh;
       
  1076 
       
  1077 		w = MAX(w, c->minw);
       
  1078 		h = MAX(h, c->minh);
       
  1079 
       
  1080 		if(c->maxw)
       
  1081 			w = MIN(w, c->maxw);
       
  1082 
       
  1083 		if(c->maxh)
       
  1084 			h = MIN(h, c->maxh);
       
  1085 	}
       
  1086 	if(w <= 0 || h <= 0)
  1093 	if(w <= 0 || h <= 0)
  1087 		return;
  1094 		return;
  1088 	if(x > sx + sw)
  1095 	if(x > sx + sw)
  1089 		x = sw - WIDTH(c);
  1096 		x = sw - WIDTH(c);
  1090 	if(y > sy + sh)
  1097 	if(y > sy + sh)