summaryrefslogtreecommitdiffstats
path: root/wm.c
diff options
context:
space:
mode:
Diffstat (limited to 'wm.c')
-rw-r--r--wm.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/wm.c b/wm.c
index c8bb0a4..b8b3053 100644
--- a/wm.c
+++ b/wm.c
@@ -15,15 +15,15 @@
15 15
16/* X structs */ 16/* X structs */
17Display *dpy; 17Display *dpy;
18Window root; 18Window root, barwin;
19XRectangle rect; 19Atom wm_atom[WMLast], net_atom[NetLast];
20Pixmap pmap;
21Atom wm_atom[WMLast];
22Atom net_atom[NetLast];
23Cursor cursor[CurLast]; 20Cursor cursor[CurLast];
21XRectangle rect, barrect;
22Bool running = True;
24 23
24char *bartext, *shell;
25int screen, sel_screen; 25int screen, sel_screen;
26unsigned int kmask, numlock_mask; 26unsigned int lock_mask, numlock_mask;
27 27
28/* draw structs */ 28/* draw structs */
29Brush brush = {0}; 29Brush brush = {0};
@@ -166,7 +166,7 @@ init_lock_keys()
166 } 166 }
167 XFreeModifiermap(modmap); 167 XFreeModifiermap(modmap);
168 168
169 kmask = 255 & ~(numlock_mask | LockMask); 169 lock_mask = 255 & ~(numlock_mask | LockMask);
170} 170}
171 171
172static void 172static void
@@ -187,6 +187,7 @@ main(int argc, char *argv[])
187 XSetWindowAttributes wa; 187 XSetWindowAttributes wa;
188 unsigned int mask; 188 unsigned int mask;
189 Window w; 189 Window w;
190 XEvent ev;
190 191
191 /* command line args */ 192 /* command line args */
192 for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) { 193 for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
@@ -218,6 +219,9 @@ main(int argc, char *argv[])
218 if(other_wm_running) 219 if(other_wm_running)
219 error("gridwm: another window manager is already running\n"); 220 error("gridwm: another window manager is already running\n");
220 221
222 if(!(shell = getenv("SHELL")))
223 shell = "/bin/sh";
224
221 rect.x = rect.y = 0; 225 rect.x = rect.y = 0;
222 rect.width = DisplayWidth(dpy, screen); 226 rect.width = DisplayWidth(dpy, screen);
223 rect.height = DisplayHeight(dpy, screen); 227 rect.height = DisplayHeight(dpy, screen);
@@ -244,19 +248,42 @@ main(int argc, char *argv[])
244 248
245 init_lock_keys(); 249 init_lock_keys();
246 250
247 pmap = XCreatePixmap(dpy, root, rect.width, rect.height, 251 brush.drawable = XCreatePixmap(dpy, root, rect.width, rect.height,
248 DefaultDepth(dpy, screen)); 252 DefaultDepth(dpy, screen));
249 253 brush.gc = XCreateGC(dpy, root, 0, 0);
250 wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
251 wa.cursor = cursor[CurNormal];
252 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
253 254
254 /* style */ 255 /* style */
255 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); 256 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
256 loadfont(dpy, &brush.font, FONT); 257 loadfont(dpy, &brush.font, FONT);
257 258
259 wa.override_redirect = 1;
260 wa.background_pixmap = ParentRelative;
261 wa.event_mask = ExposureMask;
262
263 barrect = rect;
264 barrect.height = labelheight(&brush.font);
265 barrect.y = rect.height - barrect.height;
266 barwin = XCreateWindow(dpy, root, barrect.x, barrect.y,
267 barrect.width, barrect.height, 0, DefaultDepth(dpy, screen),
268 CopyFromParent, DefaultVisual(dpy, screen),
269 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
270 bartext = 0;
271 XDefineCursor(dpy, barwin, cursor[CurNormal]);
272 XMapRaised(dpy, barwin);
273 draw_bar();
274
275 wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
276 wa.cursor = cursor[CurNormal];
277 XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
278
258 scan_wins(); 279 scan_wins();
259 280
281 while(running) {
282 XNextEvent(dpy, &ev);
283 if(handler[ev.type])
284 (handler[ev.type]) (&ev); /* call handler */
285 }
286
260 cleanup(); 287 cleanup();
261 XCloseDisplay(dpy); 288 XCloseDisplay(dpy);
262 289