243 XFlush(dpy); |
222 XFlush(dpy); |
244 |
223 |
245 if(other_wm_running) |
224 if(other_wm_running) |
246 error("gridwm: another window manager is already running\n"); |
225 error("gridwm: another window manager is already running\n"); |
247 |
226 |
248 spawn(dpy, cmdwallpaper); |
|
249 sx = sy = 0; |
227 sx = sy = 0; |
250 sw = DisplayWidth(dpy, screen); |
228 sw = DisplayWidth(dpy, screen); |
251 sh = DisplayHeight(dpy, screen); |
229 sh = DisplayHeight(dpy, screen); |
252 issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); |
230 issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); |
253 |
231 |
273 |
251 |
274 /* style */ |
252 /* style */ |
275 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); |
253 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); |
276 loadfont(dpy, &brush.font, FONT); |
254 loadfont(dpy, &brush.font, FONT); |
277 |
255 |
278 wa.override_redirect = 1; |
256 th = texth(&brush.font); |
279 wa.background_pixmap = ParentRelative; |
257 |
280 wa.event_mask = ExposureMask; |
258 brush.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen)); |
281 |
|
282 bx = by = 0; |
|
283 bw = sw; |
|
284 bh = texth(&brush.font); |
|
285 barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen), |
|
286 CopyFromParent, DefaultVisual(dpy, screen), |
|
287 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); |
|
288 XDefineCursor(dpy, barwin, cursor[CurNormal]); |
|
289 XMapRaised(dpy, barwin); |
|
290 |
|
291 brush.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); |
|
292 brush.gc = XCreateGC(dpy, root, 0, 0); |
259 brush.gc = XCreateGC(dpy, root, 0, 0); |
293 |
|
294 pipe_spawn(stext, sizeof(stext), dpy, cmdstatus); |
|
295 draw_bar(); |
|
296 |
260 |
297 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ |
261 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ |
298 | LeaveWindowMask; |
262 | LeaveWindowMask; |
299 wa.cursor = cursor[CurNormal]; |
263 wa.cursor = cursor[CurNormal]; |
300 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); |
264 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); |
301 |
265 |
302 arrange = grid; |
266 arrange = grid; |
303 scan_wins(); |
267 scan_wins(); |
304 |
268 |
305 while(running) { |
269 while(running) { |
306 if(XPending(dpy) > 0) { |
270 XNextEvent(dpy, &ev); |
307 XNextEvent(dpy, &ev); |
271 if(handler[ev.type]) |
308 if(handler[ev.type]) |
272 (handler[ev.type])(&ev); /* call handler */ |
309 (handler[ev.type]) (&ev); /* call handler */ |
|
310 continue; |
|
311 } |
|
312 FD_ZERO(&fds); |
|
313 FD_SET(ConnectionNumber(dpy), &fds); |
|
314 t = timeout; |
|
315 if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0) |
|
316 continue; |
|
317 else if(errno != EINTR) { |
|
318 pipe_spawn(stext, sizeof(stext), dpy, cmdstatus); |
|
319 draw_bar(); |
|
320 } |
|
321 } |
273 } |
322 |
274 |
323 cleanup(); |
275 cleanup(); |
324 XCloseDisplay(dpy); |
276 XCloseDisplay(dpy); |
325 |
277 |