wm.c
changeset 10 703255003abb
parent 9 d567f430a81d
child 13 5cc5e55a132d
equal deleted inserted replaced
9:d567f430a81d 10:703255003abb
    18 Window root, barwin;
    18 Window root, barwin;
    19 Atom net_atom[NetLast];
    19 Atom net_atom[NetLast];
    20 Cursor cursor[CurLast];
    20 Cursor cursor[CurLast];
    21 XRectangle rect, barrect;
    21 XRectangle rect, barrect;
    22 Bool running = True;
    22 Bool running = True;
    23 Client *clients = NULL;
       
    24 
    23 
    25 char *bartext, tag[256];
    24 char *bartext, tag[256];
    26 int screen, sel_screen;
    25 int screen, sel_screen;
    27 
    26 
    28 /* draw structs */
       
    29 Brush brush = {0};
    27 Brush brush = {0};
       
    28 Client *clients = NULL;
    30 
    29 
    31 enum { WM_PROTOCOL_DELWIN = 1 };
    30 enum { WM_PROTOCOL_DELWIN = 1 };
    32 
    31 
    33 static Bool other_wm_running;
    32 static Bool other_wm_running;
       
    33 static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
    34 static int (*x_error_handler) (Display *, XErrorEvent *);
    34 static int (*x_error_handler) (Display *, XErrorEvent *);
    35 static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
       
    36 
    35 
    37 static void
    36 static void
    38 usage()
    37 usage()
    39 {
    38 {
    40 	fputs("usage: gridwm [-v]\n", stderr);
    39 	fputs("usage: gridwm [-v]\n", stderr);
    54 			if(!XGetWindowAttributes(dpy, wins[i], &wa))
    53 			if(!XGetWindowAttributes(dpy, wins[i], &wa))
    55 				continue;
    54 				continue;
    56 			if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
    55 			if(wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
    57 				continue;
    56 				continue;
    58 			if(wa.map_state == IsViewable)
    57 			if(wa.map_state == IsViewable)
    59 				manage(create_client(wins[i], &wa));
    58 				manage(wins[i], &wa);
    60 		}
    59 		}
    61 	}
    60 	}
    62 	if(wins)
    61 	if(wins)
    63 		XFree(wins);
    62 		XFree(wins);
    64 }
    63 }
    67  * There's no way to check accesses to destroyed windows, thus
    66  * There's no way to check accesses to destroyed windows, thus
    68  * those cases are ignored (especially on UnmapNotify's).
    67  * those cases are ignored (especially on UnmapNotify's).
    69  * Other types of errors call Xlib's default error handler, which
    68  * Other types of errors call Xlib's default error handler, which
    70  * calls exit().
    69  * calls exit().
    71  */
    70  */
    72 static int
    71 int
    73 error_handler(Display *dpy, XErrorEvent *error)
    72 error_handler(Display *dpy, XErrorEvent *error)
    74 {
    73 {
    75 	if(error->error_code == BadWindow
    74 	if(error->error_code == BadWindow
    76 			|| (error->request_code == X_SetInputFocus
    75 			|| (error->request_code == X_SetInputFocus
    77 				&& error->error_code == BadMatch)
    76 				&& error->error_code == BadMatch)