diff options
Diffstat (limited to 'wm.c')
| -rw-r--r-- | wm.c | 51 |
1 files changed, 39 insertions, 12 deletions
| @@ -15,15 +15,15 @@ | |||
| 15 | 15 | ||
| 16 | /* X structs */ | 16 | /* X structs */ |
| 17 | Display *dpy; | 17 | Display *dpy; |
| 18 | Window root; | 18 | Window root, barwin; |
| 19 | XRectangle rect; | 19 | Atom wm_atom[WMLast], net_atom[NetLast]; |
| 20 | Pixmap pmap; | ||
| 21 | Atom wm_atom[WMLast]; | ||
| 22 | Atom net_atom[NetLast]; | ||
| 23 | Cursor cursor[CurLast]; | 20 | Cursor cursor[CurLast]; |
| 21 | XRectangle rect, barrect; | ||
| 22 | Bool running = True; | ||
| 24 | 23 | ||
| 24 | char *bartext, *shell; | ||
| 25 | int screen, sel_screen; | 25 | int screen, sel_screen; |
| 26 | unsigned int kmask, numlock_mask; | 26 | unsigned int lock_mask, numlock_mask; |
| 27 | 27 | ||
| 28 | /* draw structs */ | 28 | /* draw structs */ |
| 29 | Brush brush = {0}; | 29 | Brush 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 | ||
| 172 | static void | 172 | static 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 | ||
