wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 375b59eefdd1595f782e0d461f376872c8090e04
parent 6336612d9c1b90908e5eadfbbf1708c51d5acc38
Author: Kris Maglione <jg@suckless.org>
Date:   Fri,  6 Apr 2007 15:29:24 -0400

Cleanup LICENSE and README. Some minor changes from last night that I can't remember.

Diffstat:
LICENSE | 7+------
README | 2+-
cmd/wmii/event.c | 1+
cmd/wmii/fs.c | 46+++++++++++++++++-----------------------------
cmd/wmii/mouse.c | 90++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
cmd/wmii9menu.c | 2--
cmd/wmiir.c | 4++--
7 files changed, 74 insertions(+), 78 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -1,10 +1,5 @@ -MIT/X Consortium License - +© 2006-2007 Kris Maglione <fbsdaemon@gmail.com> © 2003-2006 Anselm R. Garbe <garbeam at suckless dot org> -© 2005-2006 Georg Neis <gn at suckless dot org> -© 2006 Sander van Dijk <sander at suckless dot org> -© 2006-2007 Kris Maglione <bsdaemon at comcast dot net> -© 2006 Denis Grelich <denisg at suckless dot org> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/README b/README @@ -85,5 +85,5 @@ The following people have contributed especially to wmii in various ways: References ---------- -[1] http://suckless.org +[1] http://www.suckless.org/ [2] http://www.cs.bell-labs.com/sys/man/5/INDEX.html diff --git a/cmd/wmii/event.c b/cmd/wmii/event.c @@ -446,6 +446,7 @@ check_x_event(IxpConn *c) { if(verbose) printevent(&ev); dispatch_event(&ev); + /* Hack to alleviate an apparant Xlib bug */ XPending(blz.dpy); } } diff --git a/cmd/wmii/fs.c b/cmd/wmii/fs.c @@ -73,9 +73,11 @@ static char /* Global Vars */ /***************/ FileId *free_fileid; -Ixp9Req *pending_event_reads; -Ixp9Req *outgoing_event_reads; -FidLink *pending_event_fids; +/* Pending, outgoing reads on /event */ +Ixp9Req *peventread, *oeventread; +/* Fids for /event with pending reads */ +FidLink *peventfid; + Ixp9Srv p9srv = { .open= fs_open, .walk= fs_walk, @@ -122,9 +124,6 @@ dirtab_tag[]= {{".", QTDIR, FsDTag, 0500|P9_DMDIR }, {"ctl", QTAPPEND, FsFTctl, 0600|P9_DMAPPEND }, {"index", QTFILE, FsFTindex, 0400 }, {nil}}; -/* Writing the lists separately and using an array of their references - * removes the need for casting and allows for C90 conformance, - * since otherwise we would need to use compound literals */ static Dirtab *dirtab[] = { [FsRoot] = dirtab_root, [FsDBars] = dirtab_bars, @@ -135,11 +134,6 @@ static Dirtab *dirtab[] = { }; /* Utility Functions */ -/*********************/ - -/* get_file/free_file save and reuse old FileId structs - * since so many of them are needed for so many - * purposes */ static FileId * get_file() { FileId *temp; @@ -167,8 +161,7 @@ free_file(FileId *f) { free_fileid = f; } -/* This function's name belies it's true purpose. It increases - * the reference counts of the FileId list */ +/* Increase the reference counts of the FileId list */ static void clone_files(FileId *f) { for(; f; f=f->next) @@ -311,8 +304,8 @@ respond_event(Ixp9Req *r) { respond(r, nil); f->content.buf = nil; }else{ - r->aux = pending_event_reads; - pending_event_reads = r; + r->aux = peventread; + peventread = r; } } @@ -329,17 +322,17 @@ write_event(char *format, ...) { va_end(ap); if(!(len = strlen(buffer))) return; - for(f=pending_event_fids; f; f=f->next) { + for(f=peventfid; f; f=f->next) { fi = f->fid->aux; slen = fi->content.buf ? strlen(fi->content.buf) : 0; fi->content.buf = (char *) erealloc(fi->content.buf, slen + len + 1); (fi->content.buf)[slen] = '\0'; strcat(fi->content.buf, buffer); } - outgoing_event_reads = pending_event_reads; - pending_event_reads = nil; - while((req = outgoing_event_reads)) { - outgoing_event_reads = outgoing_event_reads->aux; + oeventread = peventread; + peventread = nil; + while((req = oeventread)) { + oeventread = oeventread->aux; respond_event(req); } } @@ -361,8 +354,6 @@ dostat(Stat *s, uint len, FileId *f) { s->muid = user; } -/* lookup_file */ -/***************/ /* All lookups and directory organization should be performed through * lookup_file, mostly through the dirtabs[] tree. */ static FileId * @@ -508,7 +499,6 @@ verify_file(FileId *f) { } /* Service Functions */ -/*********************/ void fs_attach(Ixp9Req *r) { FileId *f = get_file(); @@ -826,8 +816,8 @@ fs_open(Ixp9Req *r) { case FsFEvent: fl = emallocz(sizeof(FidLink)); fl->fid = r->fid; - fl->next = pending_event_fids; - pending_event_fids = fl; + fl->next = peventfid; + peventfid = fl; break; } if((r->ifcall.mode&3) == P9_OEXEC) { @@ -855,7 +845,6 @@ fs_create(Ixp9Req *r) { switch(f->tab.type) { default: - /* XXX: This should be taken care of by the library */ respond(r, Enoperm); return; case FsDBars: @@ -890,7 +879,6 @@ fs_remove(Ixp9Req *r) { switch(f->tab.type) { default: - /* XXX: This should be taken care of by the library */ respond(r, Enoperm); return; case FsFBar: @@ -937,7 +925,7 @@ fs_clunk(Ixp9Req *r) { draw_bar(screen); break; case FsFEvent: - for(fl=&pending_event_fids; *fl; fl=&(*fl)->next) + for(fl=&peventfid; *fl; fl=&(*fl)->next) if((*fl)->fid == r->fid) { ft = *fl; *fl = (*fl)->next; @@ -955,7 +943,7 @@ void fs_flush(Ixp9Req *r) { Ixp9Req **i, **j; - for(i=&pending_event_reads; i != &outgoing_event_reads; i=&outgoing_event_reads) + for(i=&peventread; i != &oeventread; i=&oeventread) for(j=i; *j; j=(Ixp9Req **)&(*j)->aux) if(*j == r->oldreq) { *j = (*j)->aux; diff --git a/cmd/wmii/mouse.c b/cmd/wmii/mouse.c @@ -63,9 +63,10 @@ rect_morph_xy(XRectangle *rect, int dx, int dy, BlitzAlign *mask) { typedef struct { XRectangle *rects; int num; - int x1, y1, x2, y2; + int x1, y1; + int x2, y2; + int dx, dy; BlitzAlign mask; - int *delta; } SnapArgs; static void @@ -78,44 +79,48 @@ snap_line(SnapArgs *a) { if(!(r_east(&a->rects[i]) < a->x1) || (a->rects[i].x > a->x2)) { - if(abs(a->rects[i].y - a->y1) <= abs(*a->delta)) - *a->delta = a->rects[i].y - a->y1; + if(abs(a->rects[i].y - a->y1) <= abs(a->dy)) + a->dy = a->rects[i].y - a->y1; t_xy = r_south(&a->rects[i]); - if(abs(t_xy - a->y1) < abs(*a->delta)) - *a->delta = t_xy - a->y1; + if(abs(t_xy - a->y1) < abs(a->dy)) + a->dy = t_xy - a->y1; } } } else if (a->mask & (EAST|WEST)) { - /* This is the same as above, tr/xy/yx/, - * s/width/height/, s/height/width/ */ for(i=0; i < a->num; i++) { if(!(r_south(&a->rects[i]) < a->y1) || (a->rects[i].y > a->y2)) { - if(abs(a->rects[i].x - a->x1) <= abs(*a->delta)) - *a->delta = a->rects[i].x - a->x1; + if(abs(a->rects[i].x - a->x1) <= abs(a->dx)) + a->dx = a->rects[i].x - a->x1; t_xy = r_east(&a->rects[i]); - if(abs(t_xy - a->x1) < abs(*a->delta)) - *a->delta = t_xy - a->x1; + if(abs(t_xy - a->x1) < abs(a->dx)) + a->dx = t_xy - a->x1; } } } } +/* Returns a gravity for increment handling. It's normally the opposite of the mask + * (the directions that we're resizing in), unless a snap occurs, in which case, it's the + * direction of the snap. + */ BlitzAlign snap_rect(XRectangle *rects, int num, XRectangle *current, BlitzAlign *mask, int snap) { - SnapArgs a = { rects, num, 0, 0, 0, 0, *mask, nil }; - int dx, dy; + SnapArgs a = { 0, }; BlitzAlign ret; - - dx = dy = snap + 1; + + a.rects = rects; + a.num = num; + a.mask = *mask; + a.dx = snap + 1; + a.dy = snap + 1; a.x1 = current->x; a.x2 = r_east(current); - a.delta = &dy; if(*mask & NORTH) { a.y2 = a.y1 = current->y; snap_line(&a); @@ -127,7 +132,6 @@ snap_rect(XRectangle *rects, int num, XRectangle *current, BlitzAlign *mask, int a.y1 = current->y; a.y2 = r_south(current); - a.delta = &dx; if(*mask & EAST) { a.x1 = a.x2 = r_east(current); snap_line(&a); @@ -137,17 +141,20 @@ snap_rect(XRectangle *rects, int num, XRectangle *current, BlitzAlign *mask, int snap_line(&a); } - rect_morph_xy(current, - abs(dx) <= snap ? dx : 0, - abs(dy) <= snap ? dy : 0, - mask); - - ret = *mask; - if(abs(dx) <= snap) + ret = CENTER; + if(abs(a.dx) > snap) + a.dx = 0; + else ret ^= EAST|WEST; - if(abs(dy) <= snap) + + if(abs(a.dy) > snap) + a.dy = 0; + else ret ^= NORTH|SOUTH; - return ret ^ CENTER; + + rect_morph_xy(current, a.dx, a.dy, mask); + + return ret ^ *mask; } static void @@ -273,14 +280,21 @@ do_move: focus(frame->client, True); } +void +querypointer(Window w, int *x, int *y) { + Window dummy; + uint ui; + int i; + + XQueryPointer(blz.dpy, w, &dummy, &dummy, &i, &i, x, y, &ui); +} + static void do_managed_move(Client *c) { XRectangle frect, ofrect; - Window dummy; XEvent ev; Frame *f; - uint di; - int x, y, i; + int x, y; focus(c, False); f = c->sel; @@ -291,7 +305,7 @@ do_managed_move(Client *c) { return; XGrabServer(blz.dpy); - XQueryPointer(blz.dpy, blz.root, &dummy, &dummy, &i, &i, &x, &y, &di); + querypointer(blz.root, &x, &y); find_droppoint(f, x, y, &frect, False); draw_xor_border(&frect); @@ -320,7 +334,7 @@ do_managed_move(Client *c) { } break; case Expose: - (handler[Expose])(&ev); + dispatch_event(&ev); break; default: break; } @@ -334,8 +348,8 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) { Cursor cur; XEvent ev; XRectangle *rects, ofrect, frect, origin; - int snap, dx, dy, pt_x, pt_y, hr_x, hr_y, i; - uint num, di; + int snap, dx, dy, pt_x, pt_y, hr_x, hr_y; + uint num; Bool floating; float rx, ry; Frame *f; @@ -361,7 +375,7 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) { } } - XQueryPointer(blz.dpy, c->framewin, &dummy, &dummy, &i, &i, &pt_x, &pt_y, &di); + querypointer(c->framewin, &pt_x, &pt_y); rx = (float)pt_x / frect.width; ry = (float)pt_y / frect.height; @@ -378,7 +392,7 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) { ) != GrabSuccess) return; - XQueryPointer(blz.dpy, blz.root, &dummy, &dummy, &i, &i, &pt_x, &pt_y, &di); + querypointer(blz.root, &pt_x, &pt_y); if(align != CENTER) { hr_x = dx = frect.width / 2; @@ -508,7 +522,7 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) { } break; case Expose: - (handler[Expose])(&ev); + dispatch_event(&ev); break; default: break; @@ -520,7 +534,7 @@ void grab_button(Window w, uint button, ulong mod) { XGrabButton(blz.dpy, button, mod, w, False, ButtonMask, GrabModeSync, GrabModeSync, None, None); - if((mod != AnyModifier) && num_lock_mask) { + if((mod != AnyModifier) && (num_lock_mask != 0)) { XGrabButton(blz.dpy, button, mod | num_lock_mask, w, False, ButtonMask, GrabModeSync, GrabModeAsync, None, None); XGrabButton(blz.dpy, button, mod | num_lock_mask | LockMask, w, False, diff --git a/cmd/wmii9menu.c b/cmd/wmii9menu.c @@ -41,8 +41,6 @@ #include <X11/Xutil.h> #include <util.h> -#define nil ((void*)0) - char version[] = "@(#) wmii9menu version 1.8"; /* lovely X stuff */ diff --git a/cmd/wmiir.c b/cmd/wmiir.c @@ -80,8 +80,8 @@ str_of_time(uint val) { } static void -print_stat(Stat *s, int details) { - if(details) +print_stat(Stat *s, int lflag) { + if(lflag) fprintf(stdout, "%s %s %s %5llu %s %s\n", str_of_mode(s->mode), s->uid, s->gid, s->length, str_of_time(s->mtime), s->name); else {