Mercurial > dwm-meillo
comparison client.c @ 708:a2d568a5cdb8
applied Sanders all5.patch (thanks for your weekend session, Sander!)
author | Anselm R. Garbe <arg@suckless.org> |
---|---|
date | Mon, 22 Jan 2007 10:22:58 +0100 |
parents | 399f08187c27 |
children | 6c2fcf88dd9f |
comparison
equal
deleted
inserted
replaced
707:c3c57faef013 | 708:a2d568a5cdb8 |
---|---|
77 XSendEvent(dpy, c->win, True, NoEventMask, &synev); | 77 XSendEvent(dpy, c->win, True, NoEventMask, &synev); |
78 } | 78 } |
79 | 79 |
80 void | 80 void |
81 focus(Client *c) { | 81 focus(Client *c) { |
82 Client *old; | 82 Client *old = sel; |
83 | 83 |
84 if(!issel || (c && !isvisible(c))) | 84 if(!issel || (c && !isvisible(c))) |
85 return; | 85 return; |
86 if(!sel) | 86 |
87 sel = c; | 87 if(old && old != c) { |
88 else if(sel != c) { | 88 grabbuttons(old, False); |
89 old = sel; | 89 XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]); |
90 sel = c; | |
91 if(old) { | |
92 grabbuttons(old, False); | |
93 XSetWindowBorder(dpy, old->win, dc.norm[ColBorder]); | |
94 } | |
95 } | 90 } |
96 if(c) { | 91 if(c) { |
97 detachstack(c); | 92 detachstack(c); |
98 c->snext = stack; | 93 c->snext = stack; |
99 stack = c; | 94 stack = c; |
101 XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]); | 96 XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]); |
102 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); | 97 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); |
103 } | 98 } |
104 else | 99 else |
105 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); | 100 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
101 sel = c; | |
106 drawstatus(); | 102 drawstatus(); |
107 } | 103 } |
108 | 104 |
109 Client * | 105 Client * |
110 getclient(Window w) { | 106 getclient(Window w) { |
132 Window trans; | 128 Window trans; |
133 | 129 |
134 c = emallocz(sizeof(Client)); | 130 c = emallocz(sizeof(Client)); |
135 c->tags = emallocz(ntags * sizeof(Bool)); | 131 c->tags = emallocz(ntags * sizeof(Bool)); |
136 c->win = w; | 132 c->win = w; |
137 c->border = 0; | |
138 c->x = wa->x; | 133 c->x = wa->x; |
139 c->y = wa->y; | 134 c->y = wa->y; |
140 c->w = wa->width; | 135 c->w = wa->width; |
141 c->h = wa->height; | 136 c->h = wa->height; |
137 if(c->w == sw && c->h == sh) { | |
138 c->border = 0; | |
139 c->x = sx; | |
140 c->y = sy; | |
141 } | |
142 else { | |
143 c->border = BORDERPX; | |
144 if(c->x < wax) | |
145 c->x = wax; | |
146 if(c->y < way) | |
147 c->y = way; | |
148 if(c->x + c->w + 2 * c->border > wax + waw) | |
149 c->x = wax + waw - c->w - 2 * c->border; | |
150 if(c->y + c->h + 2 * c->border > way + wah) | |
151 c->y = way + wah - c->h - 2 * c->border; | |
152 } | |
142 updatesizehints(c); | 153 updatesizehints(c); |
143 if(c->x + c->w + 2 * BORDERPX > sw) | |
144 c->x = sw - c->w - 2 * BORDERPX; | |
145 if(c->x < sx) | |
146 c->x = sx; | |
147 if(c->y + c->h + 2 * BORDERPX > sh) | |
148 c->y = sh - c->h - 2 * BORDERPX; | |
149 if(c->h != sh && c->y < bh) | |
150 c->y = bh; | |
151 c->proto = getproto(c->win); | 154 c->proto = getproto(c->win); |
152 XSelectInput(dpy, c->win, | 155 XSelectInput(dpy, c->win, |
153 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); | 156 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
154 XGetTransientForHint(dpy, c->win, &trans); | 157 XGetTransientForHint(dpy, c->win, &trans); |
155 grabbuttons(c, False); | 158 grabbuttons(c, False); |
168 focus(c); | 171 focus(c); |
169 arrange(); | 172 arrange(); |
170 } | 173 } |
171 | 174 |
172 void | 175 void |
173 resize(Client *c, Bool sizehints, Corner sticky) { | 176 resize(Client *c, Bool sizehints) { |
174 int bottom = c->y + c->h; | |
175 int right = c->x + c->w; | |
176 XWindowChanges wc; | 177 XWindowChanges wc; |
177 | 178 |
178 if(sizehints) { | 179 if(sizehints) { |
179 if(c->incw) | 180 if(c->incw) |
180 c->w -= (c->w - c->basew) % c->incw; | 181 c->w -= (c->w - c->basew) % c->incw; |
187 if(c->maxw && c->w > c->maxw) | 188 if(c->maxw && c->w > c->maxw) |
188 c->w = c->maxw; | 189 c->w = c->maxw; |
189 if(c->maxh && c->h > c->maxh) | 190 if(c->maxh && c->h > c->maxh) |
190 c->h = c->maxh; | 191 c->h = c->maxh; |
191 } | 192 } |
192 if(sticky == TopRight || sticky == BotRight) | 193 if(c->w == sw && c->h == sh) |
193 c->x = right - c->w; | 194 c->border = 0; |
194 if(sticky == BotLeft || sticky == BotRight) | 195 else |
195 c->y = bottom - c->h; | 196 c->border = BORDERPX; |
196 /* offscreen appearance fixes */ | 197 /* offscreen appearance fixes */ |
197 if(c->x + c->w < sx) | 198 if(c->x + c->w + 2 * c->border < sx) |
198 c->x = sx; | 199 c->x = sx; |
199 if(c->y + c->h < bh) | 200 if(c->y + c->h + 2 * c->border < sy) |
200 c->y = bh; | 201 c->y = sy; |
201 if(c->x > sw) | 202 if(c->x > sw) |
202 c->x = sw - c->w; | 203 c->x = sw - c->w - 2 * c->border; |
203 if(c->y > sh) | 204 if(c->y > sh) |
204 c->y = sh - c->h; | 205 c->y = sh - c->h - 2 * c->border; |
205 wc.x = c->x; | 206 wc.x = c->x; |
206 wc.y = c->y; | 207 wc.y = c->y; |
207 wc.width = c->w; | 208 wc.width = c->w; |
208 wc.height = c->h; | 209 wc.height = c->h; |
209 if(c->w == sw && c->h == sh) | 210 wc.border_width = c->border; |
210 wc.border_width = 0; | |
211 else | |
212 wc.border_width = BORDERPX; | |
213 XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); | 211 XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); |
214 configure(c); | 212 configure(c); |
215 XSync(dpy, False); | 213 XSync(dpy, False); |
216 } | 214 } |
217 | 215 |