Mercurial > aewl
comparison client.c @ 687:a76799907854
removed client title bar
author | Anselm R. Garbe <arg@suckless.org> |
---|---|
date | Sun, 14 Jan 2007 22:27:29 +0100 |
parents | fd2ea58b0b94 |
children | 399f08187c27 |
comparison
equal
deleted
inserted
replaced
686:4fd68b1485eb | 687:a76799907854 |
---|---|
57 xerrordummy(Display *dsply, XErrorEvent *ee) { | 57 xerrordummy(Display *dsply, XErrorEvent *ee) { |
58 return 0; | 58 return 0; |
59 } | 59 } |
60 | 60 |
61 /* extern functions */ | 61 /* extern functions */ |
62 | |
63 void | |
64 ban(Client *c) { | |
65 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); | |
66 XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty); | |
67 } | |
68 | 62 |
69 void | 63 void |
70 configure(Client *c) { | 64 configure(Client *c) { |
71 XEvent synev; | 65 XEvent synev; |
72 | 66 |
119 if(c->win == w) | 113 if(c->win == w) |
120 return c; | 114 return c; |
121 return NULL; | 115 return NULL; |
122 } | 116 } |
123 | 117 |
124 Client * | |
125 getctitle(Window w) { | |
126 Client *c; | |
127 | |
128 for(c = clients; c; c = c->next) | |
129 if(c->twin == w) | |
130 return c; | |
131 return NULL; | |
132 } | |
133 | |
134 void | 118 void |
135 killclient(Arg *arg) { | 119 killclient(Arg *arg) { |
136 if(!sel) | 120 if(!sel) |
137 return; | 121 return; |
138 if(sel->proto & PROTODELWIN) | 122 if(sel->proto & PROTODELWIN) |
143 | 127 |
144 void | 128 void |
145 manage(Window w, XWindowAttributes *wa) { | 129 manage(Window w, XWindowAttributes *wa) { |
146 Client *c; | 130 Client *c; |
147 Window trans; | 131 Window trans; |
148 XSetWindowAttributes twa; | |
149 | 132 |
150 c = emallocz(sizeof(Client)); | 133 c = emallocz(sizeof(Client)); |
151 c->tags = emallocz(ntags * sizeof(Bool)); | 134 c->tags = emallocz(ntags * sizeof(Bool)); |
152 c->win = w; | 135 c->win = w; |
153 c->border = 0; | 136 c->border = 0; |
154 c->x = c->tx = wa->x; | 137 c->x = wa->x; |
155 c->y = c->ty = wa->y; | 138 c->y = wa->y; |
156 c->w = c->tw = wa->width; | 139 c->w = wa->width; |
157 c->h = wa->height; | 140 c->h = wa->height; |
158 c->th = bh; | |
159 updatesizehints(c); | 141 updatesizehints(c); |
160 if(c->x + c->w + 2 * BORDERPX > sw) | 142 if(c->x + c->w + 2 * BORDERPX > sw) |
161 c->x = sw - c->w - 2 * BORDERPX; | 143 c->x = sw - c->w - 2 * BORDERPX; |
162 if(c->x < sx) | 144 if(c->x < sx) |
163 c->x = sx; | 145 c->x = sx; |
167 c->y = bh; | 149 c->y = bh; |
168 c->proto = getproto(c->win); | 150 c->proto = getproto(c->win); |
169 XSelectInput(dpy, c->win, | 151 XSelectInput(dpy, c->win, |
170 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); | 152 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); |
171 XGetTransientForHint(dpy, c->win, &trans); | 153 XGetTransientForHint(dpy, c->win, &trans); |
172 twa.override_redirect = 1; | |
173 twa.background_pixmap = ParentRelative; | |
174 twa.event_mask = ExposureMask | EnterWindowMask; | |
175 c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, | |
176 0, DefaultDepth(dpy, screen), CopyFromParent, | |
177 DefaultVisual(dpy, screen), | |
178 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); | |
179 grabbuttons(c, False); | 154 grabbuttons(c, False); |
180 updatetitle(c); | 155 updatetitle(c); |
181 settags(c, getclient(trans)); | 156 settags(c, getclient(trans)); |
182 if(!c->isfloat) | 157 if(!c->isfloat) |
183 c->isfloat = trans || c->isfixed; | 158 c->isfloat = trans || c->isfixed; |
184 resizetitle(c); | |
185 if(clients) | 159 if(clients) |
186 clients->prev = c; | 160 clients->prev = c; |
187 c->next = clients; | 161 c->next = clients; |
188 c->snext = stack; | 162 c->snext = stack; |
189 stack = clients = c; | 163 stack = clients = c; |
190 ban(c); | 164 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
191 XMapWindow(dpy, c->win); | 165 XMapWindow(dpy, c->win); |
192 XMapWindow(dpy, c->twin); | |
193 if(isvisible(c)) | 166 if(isvisible(c)) |
194 focus(c); | 167 focus(c); |
195 arrange(); | 168 arrange(); |
196 } | 169 } |
197 | 170 |
226 c->y = bh; | 199 c->y = bh; |
227 if(c->x > sw) | 200 if(c->x > sw) |
228 c->x = sw - c->w; | 201 c->x = sw - c->w; |
229 if(c->y > sh) | 202 if(c->y > sh) |
230 c->y = sh - c->h; | 203 c->y = sh - c->h; |
231 resizetitle(c); | |
232 wc.x = c->x; | 204 wc.x = c->x; |
233 wc.y = c->y; | 205 wc.y = c->y; |
234 wc.width = c->w; | 206 wc.width = c->w; |
235 wc.height = c->h; | 207 wc.height = c->h; |
236 if(c->w == sw && c->h == sh) | 208 if(c->w == sw && c->h == sh) |
238 else | 210 else |
239 wc.border_width = BORDERPX; | 211 wc.border_width = BORDERPX; |
240 XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); | 212 XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); |
241 configure(c); | 213 configure(c); |
242 XSync(dpy, False); | 214 XSync(dpy, False); |
243 } | |
244 | |
245 void | |
246 resizetitle(Client *c) { | |
247 c->tw = textw(c->name); | |
248 if(c->tw > c->w) | |
249 c->tw = c->w + 2 * BORDERPX; | |
250 c->tx = c->x + c->w - c->tw + 2 * BORDERPX; | |
251 c->ty = c->y; | |
252 if(isvisible(c)) | |
253 XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th); | |
254 else | |
255 XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th); | |
256 } | 215 } |
257 | 216 |
258 void | 217 void |
259 updatesizehints(Client *c) { | 218 updatesizehints(Client *c) { |
260 long msize; | 219 long msize; |
329 if(sel == c) { | 288 if(sel == c) { |
330 for(nc = stack; nc && !isvisible(nc); nc = nc->snext); | 289 for(nc = stack; nc && !isvisible(nc); nc = nc->snext); |
331 focus(nc); | 290 focus(nc); |
332 } | 291 } |
333 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | 292 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
334 XDestroyWindow(dpy, c->twin); | |
335 free(c->tags); | 293 free(c->tags); |
336 free(c); | 294 free(c); |
337 XSync(dpy, False); | 295 XSync(dpy, False); |
338 XSetErrorHandler(xerror); | 296 XSetErrorHandler(xerror); |
339 XUngrabServer(dpy); | 297 XUngrabServer(dpy); |