X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=main.c;h=6de4f8ac54f6bc8562851a688d10976aa11ace72;hb=dddd58a8cdc9ffd9f207c45316e9f9a28b4bf519;hp=5e7b4a63601f78978402ba04aae566eb4e36de23;hpb=15abade2720158fd35dcf59aa2cd5cbb325a849c;p=dwm.git diff --git a/main.c b/main.c index 5e7b4a6..6de4f8a 100644 --- a/main.c +++ b/main.c @@ -19,12 +19,11 @@ char stext[1024]; Bool *seltag; -int bx, by, bw, bh, bmw, mw, screen, sx, sy, sw, sh; +int bx, by, bw, bh, bmw, master, screen, sx, sy, sw, sh; unsigned int ntags, numlockmask; Atom wmatom[WMLast], netatom[NetLast]; Bool running = True; Bool issel = True; -Bool maximized = False; Client *clients = NULL; Client *sel = NULL; Client *stack = NULL; @@ -39,8 +38,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *); static Bool otherwm, readin; static void -cleanup() -{ +cleanup(void) { close(STDIN_FILENO); while(sel) { resize(sel, True, TopLeft); @@ -60,8 +58,7 @@ cleanup() } static void -scan() -{ +scan(void) { unsigned int i, num; Window *wins, d1, d2; XWindowAttributes wa; @@ -82,8 +79,7 @@ scan() } static void -setup() -{ +setup(void) { int i, j; unsigned int mask; Window w; @@ -112,7 +108,8 @@ setup() } XFree(modmap); - wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask; + wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask + | EnterWindowMask | LeaveWindowMask; wa.cursor = cursor[CurNormal]; XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); @@ -131,12 +128,15 @@ setup() dc.status[ColBG] = getcolor(STATUSBGCOLOR); dc.status[ColFG] = getcolor(STATUSFGCOLOR); setfont(FONT); - - bmw = textw(FLOATSYMBOL) > textw(TILESYMBOL) ? textw(FLOATSYMBOL) : textw(TILESYMBOL); + + bmw = textw(VSTACKSYMBOL) > textw(BSTACKSYMBOL) ? + textw(VSTACKSYMBOL) : textw(BSTACKSYMBOL); + bmw = bmw > textw(FLOATSYMBOL) ? + bmw : textw(FLOATSYMBOL); sx = sy = 0; sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); - mw = (sw * MASTERW) / 100; + master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100; bx = by = 0; bw = sw; @@ -163,8 +163,7 @@ setup() * is already running. */ static int -xerrorstart(Display *dsply, XErrorEvent *ee) -{ +xerrorstart(Display *dsply, XErrorEvent *ee) { otherwm = True; return -1; } @@ -172,8 +171,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee) /* extern */ int -getproto(Window w) -{ +getproto(Window w) { int i, format, protos, status; unsigned long extra, res; Atom *protocols, real; @@ -191,8 +189,7 @@ getproto(Window w) } void -sendevent(Window w, Atom a, long value) -{ +sendevent(Window w, Atom a, long value) { XEvent e; e.type = ClientMessage; @@ -206,35 +203,33 @@ sendevent(Window w, Atom a, long value) } void -quit(Arg *arg) -{ +quit(Arg *arg) { readin = running = False; } /* * There's no way to check accesses to destroyed windows, thus those cases are * ignored (especially on UnmapNotify's). Other types of errors call Xlibs - * default error handler, which calls exit(). + * default error handler, which may call exit. */ int -xerror(Display *dpy, XErrorEvent *ee) -{ +xerror(Display *dpy, XErrorEvent *ee) { if(ee->error_code == BadWindow || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable) || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) - || (ee->request_code == X_GrabKey && ee->error_code == BadAccess)) + || (ee->request_code == X_GrabKey && ee->error_code == BadAccess) + || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)) return 0; fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", ee->request_code, ee->error_code); - return xerrorxlib(dpy, ee); /* may call exit() */ + return xerrorxlib(dpy, ee); /* may call exit */ } int -main(int argc, char *argv[]) -{ +main(int argc, char *argv[]) { int r, xfd; fd_set rd;