dwm-meillo

diff wm.c @ 5:e5018cae273f

added several other stuff
author Anselm R. Garbe <garbeam@wmii.de>
date Mon, 10 Jul 2006 22:16:48 +0200
parents e969f3575b7a
children e0cefb3981c8
line diff
     1.1 --- a/wm.c	Mon Jul 10 19:47:35 2006 +0200
     1.2 +++ b/wm.c	Mon Jul 10 22:16:48 2006 +0200
     1.3 @@ -15,15 +15,15 @@
     1.4  
     1.5  /* X structs */
     1.6  Display *dpy;
     1.7 -Window root;
     1.8 -XRectangle rect;
     1.9 -Pixmap pmap;
    1.10 -Atom wm_atom[WMLast];
    1.11 -Atom net_atom[NetLast];
    1.12 +Window root, barwin;
    1.13 +Atom wm_atom[WMLast], net_atom[NetLast];
    1.14  Cursor cursor[CurLast];
    1.15 +XRectangle rect, barrect;
    1.16 +Bool running = True;
    1.17  
    1.18 +char *bartext, *shell;
    1.19  int screen, sel_screen;
    1.20 -unsigned int kmask, numlock_mask;
    1.21 +unsigned int lock_mask, numlock_mask;
    1.22  
    1.23  /* draw structs */
    1.24  Brush brush = {0};
    1.25 @@ -166,7 +166,7 @@
    1.26  	}
    1.27  	XFreeModifiermap(modmap);
    1.28  
    1.29 -	kmask = 255 & ~(numlock_mask | LockMask);
    1.30 +	lock_mask = 255 & ~(numlock_mask | LockMask);
    1.31  }
    1.32  
    1.33  static void
    1.34 @@ -187,6 +187,7 @@
    1.35  	XSetWindowAttributes wa;
    1.36  	unsigned int mask;
    1.37  	Window w;
    1.38 +	XEvent ev;
    1.39  
    1.40  	/* command line args */
    1.41  	for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
    1.42 @@ -218,6 +219,9 @@
    1.43  	if(other_wm_running)
    1.44  		error("gridwm: another window manager is already running\n");
    1.45  
    1.46 +	if(!(shell = getenv("SHELL")))
    1.47 +		shell = "/bin/sh";
    1.48 +
    1.49  	rect.x = rect.y = 0;
    1.50  	rect.width = DisplayWidth(dpy, screen);
    1.51  	rect.height = DisplayHeight(dpy, screen);
    1.52 @@ -244,18 +248,41 @@
    1.53  
    1.54  	init_lock_keys();
    1.55  
    1.56 -	pmap = XCreatePixmap(dpy, root, rect.width, rect.height,
    1.57 +	brush.drawable = XCreatePixmap(dpy, root, rect.width, rect.height,
    1.58  			DefaultDepth(dpy, screen));
    1.59 +	brush.gc = XCreateGC(dpy, root, 0, 0);
    1.60 +
    1.61 +	/* style */
    1.62 +	loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
    1.63 +	loadfont(dpy, &brush.font, FONT);
    1.64 +
    1.65 +	wa.override_redirect = 1;
    1.66 +	wa.background_pixmap = ParentRelative;
    1.67 +	wa.event_mask = ExposureMask;
    1.68 +
    1.69 +	barrect = rect;
    1.70 +	barrect.height = labelheight(&brush.font);
    1.71 +	barrect.y = rect.height - barrect.height;
    1.72 +	barwin = XCreateWindow(dpy, root, barrect.x, barrect.y,
    1.73 +			barrect.width, barrect.height, 0, DefaultDepth(dpy, screen),
    1.74 +			CopyFromParent, DefaultVisual(dpy, screen),
    1.75 +			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
    1.76 +	bartext = 0;
    1.77 +	XDefineCursor(dpy, barwin, cursor[CurNormal]);
    1.78 +	XMapRaised(dpy, barwin);
    1.79 +	draw_bar();
    1.80  
    1.81  	wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
    1.82  	wa.cursor = cursor[CurNormal];
    1.83  	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
    1.84  
    1.85 -	/* style */
    1.86 -	loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
    1.87 -	loadfont(dpy, &brush.font, FONT);
    1.88 +	scan_wins();
    1.89  
    1.90 -	scan_wins();
    1.91 +	while(running) {
    1.92 +		XNextEvent(dpy, &ev);
    1.93 +		if(handler[ev.type])
    1.94 +			(handler[ev.type]) (&ev); /* call handler */
    1.95 +	}
    1.96  
    1.97  	cleanup();
    1.98  	XCloseDisplay(dpy);