dwm.c
changeset 1432 dda54561d777
parent 1431 5b2240f2d21f
child 1433 a725636d4d81
equal deleted inserted replaced
1431:5b2240f2d21f 1432:dda54561d777
  1044 
  1044 
  1045 	if(!(c = malloc(sizeof(Client))))
  1045 	if(!(c = malloc(sizeof(Client))))
  1046 		die("fatal: could not malloc() %u bytes\n", sizeof(Client));
  1046 		die("fatal: could not malloc() %u bytes\n", sizeof(Client));
  1047 	*c = cz;
  1047 	*c = cz;
  1048 	c->win = w;
  1048 	c->win = w;
  1049 	c->mon = selmon;
  1049 
       
  1050 	if(XGetTransientForHint(dpy, w, &trans))
       
  1051 		t = wintoclient(trans);
       
  1052 	if(t) {
       
  1053 		c->mon = t->mon;
       
  1054 		c->tags = t->tags;
       
  1055 	}
       
  1056 	else {
       
  1057 		c->mon = selmon;
       
  1058 		applyrules(c);
       
  1059 	}
  1050 
  1060 
  1051 	/* geometry */
  1061 	/* geometry */
  1052 	c->x = wa->x + selmon->wx;
  1062 	c->x = wa->x + c->mon->wx;
  1053 	c->y = wa->y + selmon->wy;
  1063 	c->y = wa->y + c->mon->wy;
  1054 	c->w = wa->width;
  1064 	c->w = wa->width;
  1055 	c->h = wa->height;
  1065 	c->h = wa->height;
  1056 	c->oldbw = wa->border_width;
  1066 	c->oldbw = wa->border_width;
  1057 	if(c->w == selmon->mw && c->h == selmon->mh) {
  1067 	if(c->w == c->mon->mw && c->h == c->mon->mh) {
  1058 		c->x = selmon->mx;
  1068 		c->x = c->mon->mx;
  1059 		c->y = selmon->my;
  1069 		c->y = c->mon->my;
  1060 		c->bw = 0;
  1070 		c->bw = 0;
  1061 	}
  1071 	}
  1062 	else {
  1072 	else {
  1063 		if(c->x + WIDTH(c) > selmon->mx + selmon->mw)
  1073 		if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
  1064 			c->x = selmon->mx + selmon->mw - WIDTH(c);
  1074 			c->x = c->mon->mx + c->mon->mw - WIDTH(c);
  1065 		if(c->y + HEIGHT(c) > selmon->my + selmon->mh)
  1075 		if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh)
  1066 			c->y = selmon->my + selmon->mh - HEIGHT(c);
  1076 			c->y = c->mon->my + c->mon->mh - HEIGHT(c);
  1067 		c->x = MAX(c->x, selmon->mx);
  1077 		c->x = MAX(c->x, c->mon->mx);
  1068 		/* only fix client y-offset, if the client center might cover the bar */
  1078 		/* only fix client y-offset, if the client center might cover the bar */
  1069 		c->y = MAX(c->y, ((c->mon->by == 0) && (c->x + (c->w / 2) >= c->mon->wx)
  1079 		c->y = MAX(c->y, ((c->mon->by == 0) && (c->x + (c->w / 2) >= c->mon->wx)
  1070 		           && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : selmon->my);
  1080 		           && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
  1071 		c->bw = borderpx;
  1081 		c->bw = borderpx;
  1072 	}
  1082 	}
  1073 
  1083 
  1074 	wc.border_width = c->bw;
  1084 	wc.border_width = c->bw;
  1075 	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
  1085 	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
  1077 	configure(c); /* propagates border_width, if size doesn't change */
  1087 	configure(c); /* propagates border_width, if size doesn't change */
  1078 	updatesizehints(c);
  1088 	updatesizehints(c);
  1079 	XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
  1089 	XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
  1080 	grabbuttons(c, False);
  1090 	grabbuttons(c, False);
  1081 	updatetitle(c);
  1091 	updatetitle(c);
  1082 	if(XGetTransientForHint(dpy, w, &trans))
       
  1083 		t = wintoclient(trans);
       
  1084 	if(t)
       
  1085 		c->tags = t->tags;
       
  1086 	else
       
  1087 		applyrules(c);
       
  1088 	if(!c->isfloating)
  1092 	if(!c->isfloating)
  1089 		c->isfloating = trans != None || c->isfixed;
  1093 		c->isfloating = trans != None || c->isfixed;
  1090 	if(c->isfloating)
  1094 	if(c->isfloating)
  1091 		XRaiseWindow(dpy, c->win);
  1095 		XRaiseWindow(dpy, c->win);
  1092 	attach(c);
  1096 	attach(c);