aewl
diff client.c @ 95:5d88952cbf96
implemened distinguishing float/managed geometries of clients (works quite well)
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Tue, 18 Jul 2006 12:36:57 +0200 |
parents | 6efe82c775c9 |
children | a19556fe83b5 |
line diff
1.1 --- a/client.c Tue Jul 18 11:45:32 2006 +0200 1.2 +++ b/client.c Tue Jul 18 12:36:57 2006 +0200 1.3 @@ -16,16 +16,16 @@ 1.4 { 1.5 int i; 1.6 1.7 - c->tw = 0; 1.8 + c->bw = 0; 1.9 for(i = 0; i < TLast; i++) 1.10 if(c->tags[i]) 1.11 - c->tw += textw(c->tags[i]); 1.12 - c->tw += textw(c->name); 1.13 - if(c->tw > c->w) 1.14 - c->tw = c->w + 2; 1.15 - c->tx = c->x + c->w - c->tw + 2; 1.16 - c->ty = c->y; 1.17 - XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th); 1.18 + c->bw += textw(c->tags[i]); 1.19 + c->bw += textw(c->name); 1.20 + if(c->bw > *c->w) 1.21 + c->bw = *c->w + 2; 1.22 + c->bx = *c->x + *c->w - c->bw + 2; 1.23 + c->by = *c->y; 1.24 + XMoveResizeWindow(dpy, c->title, c->bx, c->by, c->bw, c->bh); 1.25 } 1.26 1.27 static int 1.28 @@ -39,8 +39,8 @@ 1.29 void 1.30 ban(Client *c) 1.31 { 1.32 - XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 1.33 - XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty); 1.34 + XMoveWindow(dpy, c->win, *c->x + 2 * sw, *c->y); 1.35 + XMoveWindow(dpy, c->title, c->bx + 2 * sw, c->by); 1.36 } 1.37 1.38 void 1.39 @@ -124,12 +124,12 @@ 1.40 case EastGravity: 1.41 case CenterGravity: 1.42 case WestGravity: 1.43 - dy = -(c->h / 2) + c->border; 1.44 + dy = -(*c->h / 2) + c->border; 1.45 break; 1.46 case SouthEastGravity: 1.47 case SouthGravity: 1.48 case SouthWestGravity: 1.49 - dy = -c->h; 1.50 + dy = -(*c->h); 1.51 break; 1.52 default: 1.53 break; 1.54 @@ -145,12 +145,12 @@ 1.55 case NorthGravity: 1.56 case CenterGravity: 1.57 case SouthGravity: 1.58 - dx = -(c->w / 2) + c->border; 1.59 + dx = -(*c->w / 2) + c->border; 1.60 break; 1.61 case NorthEastGravity: 1.62 case EastGravity: 1.63 case SouthEastGravity: 1.64 - dx = -(c->w + c->border); 1.65 + dx = -(*c->w + c->border); 1.66 break; 1.67 default: 1.68 break; 1.69 @@ -160,8 +160,8 @@ 1.70 dx = -dx; 1.71 dy = -dy; 1.72 } 1.73 - c->x += dx; 1.74 - c->y += dy; 1.75 + *c->x += dx; 1.76 + *c->y += dy; 1.77 } 1.78 1.79 void 1.80 @@ -198,13 +198,13 @@ 1.81 1.82 c = emallocz(sizeof(Client)); 1.83 c->win = w; 1.84 - c->tx = c->x = wa->x; 1.85 - c->ty = c->y = wa->y; 1.86 - if(c->y < bh) 1.87 - c->ty = c->y += bh; 1.88 - c->tw = c->w = wa->width; 1.89 - c->h = wa->height; 1.90 - c->th = bh; 1.91 + c->bx = c->fx = c->tx = wa->x; 1.92 + c->by = c->fy = c->ty = wa->y; 1.93 + if(c->fy < bh) 1.94 + c->by = c->fy = c->ty += bh; 1.95 + c->bw = c->fw = c->tw = wa->width; 1.96 + c->fh = c->th = wa->height; 1.97 + c->bh = bh; 1.98 c->border = 1; 1.99 c->proto = getproto(c->win); 1.100 setsize(c); 1.101 @@ -215,12 +215,11 @@ 1.102 twa.background_pixmap = ParentRelative; 1.103 twa.event_mask = ExposureMask; 1.104 1.105 - c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, 1.106 + c->title = XCreateWindow(dpy, root, c->bx, c->by, c->bw, c->bh, 1.107 0, DefaultDepth(dpy, screen), CopyFromParent, 1.108 DefaultVisual(dpy, screen), 1.109 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 1.110 1.111 - settitle(c); 1.112 settags(c); 1.113 1.114 c->next = clients; 1.115 @@ -239,7 +238,11 @@ 1.116 c->isfloat = trans 1.117 || ((c->maxw == c->minw) && (c->maxh == c->minh)); 1.118 1.119 + setgeom(c); 1.120 + settitle(c); 1.121 + 1.122 arrange(NULL); 1.123 + 1.124 /* mapping the window now prevents flicker */ 1.125 if(c->tags[tsel]) { 1.126 XMapRaised(dpy, c->win); 1.127 @@ -259,10 +262,10 @@ 1.128 { 1.129 if(!sel) 1.130 return; 1.131 - sel->x = sx; 1.132 - sel->y = sy + bh; 1.133 - sel->w = sw - 2 * sel->border; 1.134 - sel->h = sh - 2 * sel->border - bh; 1.135 + *sel->x = sx; 1.136 + *sel->y = sy + bh; 1.137 + *sel->w = sw - 2 * sel->border; 1.138 + *sel->h = sh - 2 * sel->border - bh; 1.139 higher(sel); 1.140 resize(sel, False); 1.141 } 1.142 @@ -286,32 +289,32 @@ 1.143 1.144 if(inc) { 1.145 if(c->incw) 1.146 - c->w -= (c->w - c->basew) % c->incw; 1.147 + *c->w -= (*c->w - c->basew) % c->incw; 1.148 if(c->inch) 1.149 - c->h -= (c->h - c->baseh) % c->inch; 1.150 + *c->h -= (*c->h - c->baseh) % c->inch; 1.151 } 1.152 - if(c->x > sw) /* might happen on restart */ 1.153 - c->x = sw - c->w; 1.154 - if(c->y > sh) 1.155 - c->ty = c->y = sh - c->h; 1.156 - if(c->minw && c->w < c->minw) 1.157 - c->w = c->minw; 1.158 - if(c->minh && c->h < c->minh) 1.159 - c->h = c->minh; 1.160 - if(c->maxw && c->w > c->maxw) 1.161 - c->w = c->maxw; 1.162 - if(c->maxh && c->h > c->maxh) 1.163 - c->h = c->maxh; 1.164 + if(*c->x > sw) /* might happen on restart */ 1.165 + *c->x = sw - *c->w; 1.166 + if(*c->y > sh) 1.167 + *c->y = sh - *c->h; 1.168 + if(c->minw && *c->w < c->minw) 1.169 + *c->w = c->minw; 1.170 + if(c->minh && *c->h < c->minh) 1.171 + *c->h = c->minh; 1.172 + if(c->maxw && *c->w > c->maxw) 1.173 + *c->w = c->maxw; 1.174 + if(c->maxh && *c->h > c->maxh) 1.175 + *c->h = c->maxh; 1.176 resizetitle(c); 1.177 XSetWindowBorderWidth(dpy, c->win, 1); 1.178 - XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); 1.179 + XMoveResizeWindow(dpy, c->win, *c->x, *c->y, *c->w, *c->h); 1.180 e.type = ConfigureNotify; 1.181 e.event = c->win; 1.182 e.window = c->win; 1.183 - e.x = c->x; 1.184 - e.y = c->y; 1.185 - e.width = c->w; 1.186 - e.height = c->h; 1.187 + e.x = *c->x; 1.188 + e.y = *c->y; 1.189 + e.width = *c->w; 1.190 + e.height = *c->h; 1.191 e.border_width = c->border; 1.192 e.above = None; 1.193 e.override_redirect = False; 1.194 @@ -320,6 +323,23 @@ 1.195 } 1.196 1.197 void 1.198 +setgeom(Client *c) 1.199 +{ 1.200 + if((arrange == dotile) && !c->isfloat) { 1.201 + c->x = &c->tx; 1.202 + c->y = &c->ty; 1.203 + c->w = &c->tw; 1.204 + c->h = &c->th; 1.205 + } 1.206 + else { 1.207 + c->x = &c->fx; 1.208 + c->y = &c->fy; 1.209 + c->w = &c->fw; 1.210 + c->h = &c->fh; 1.211 + } 1.212 +} 1.213 + 1.214 +void 1.215 setsize(Client *c) 1.216 { 1.217 XSizeHints size;