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

This commit is contained in:
Kris Maglione 2007-04-06 15:29:24 -04:00
parent 6336612d9c
commit 375b59eefd
7 changed files with 74 additions and 78 deletions

View File

@ -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> © 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 Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),

2
README
View File

@ -85,5 +85,5 @@ The following people have contributed especially to wmii in various ways:
References References
---------- ----------
[1] http://suckless.org [1] http://www.suckless.org/
[2] http://www.cs.bell-labs.com/sys/man/5/INDEX.html [2] http://www.cs.bell-labs.com/sys/man/5/INDEX.html

View File

@ -446,6 +446,7 @@ check_x_event(IxpConn *c) {
if(verbose) if(verbose)
printevent(&ev); printevent(&ev);
dispatch_event(&ev); dispatch_event(&ev);
/* Hack to alleviate an apparant Xlib bug */
XPending(blz.dpy); XPending(blz.dpy);
} }
} }

View File

@ -73,9 +73,11 @@ static char
/* Global Vars */ /* Global Vars */
/***************/ /***************/
FileId *free_fileid; FileId *free_fileid;
Ixp9Req *pending_event_reads; /* Pending, outgoing reads on /event */
Ixp9Req *outgoing_event_reads; Ixp9Req *peventread, *oeventread;
FidLink *pending_event_fids; /* Fids for /event with pending reads */
FidLink *peventfid;
Ixp9Srv p9srv = { Ixp9Srv p9srv = {
.open= fs_open, .open= fs_open,
.walk= fs_walk, .walk= fs_walk,
@ -122,9 +124,6 @@ dirtab_tag[]= {{".", QTDIR, FsDTag, 0500|P9_DMDIR },
{"ctl", QTAPPEND, FsFTctl, 0600|P9_DMAPPEND }, {"ctl", QTAPPEND, FsFTctl, 0600|P9_DMAPPEND },
{"index", QTFILE, FsFTindex, 0400 }, {"index", QTFILE, FsFTindex, 0400 },
{nil}}; {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[] = { static Dirtab *dirtab[] = {
[FsRoot] = dirtab_root, [FsRoot] = dirtab_root,
[FsDBars] = dirtab_bars, [FsDBars] = dirtab_bars,
@ -135,11 +134,6 @@ static Dirtab *dirtab[] = {
}; };
/* Utility Functions */ /* 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 * static FileId *
get_file() { get_file() {
FileId *temp; FileId *temp;
@ -167,8 +161,7 @@ free_file(FileId *f) {
free_fileid = f; free_fileid = f;
} }
/* This function's name belies it's true purpose. It increases /* Increase the reference counts of the FileId list */
* the reference counts of the FileId list */
static void static void
clone_files(FileId *f) { clone_files(FileId *f) {
for(; f; f=f->next) for(; f; f=f->next)
@ -311,8 +304,8 @@ respond_event(Ixp9Req *r) {
respond(r, nil); respond(r, nil);
f->content.buf = nil; f->content.buf = nil;
}else{ }else{
r->aux = pending_event_reads; r->aux = peventread;
pending_event_reads = r; peventread = r;
} }
} }
@ -329,17 +322,17 @@ write_event(char *format, ...) {
va_end(ap); va_end(ap);
if(!(len = strlen(buffer))) if(!(len = strlen(buffer)))
return; return;
for(f=pending_event_fids; f; f=f->next) { for(f=peventfid; f; f=f->next) {
fi = f->fid->aux; fi = f->fid->aux;
slen = fi->content.buf ? strlen(fi->content.buf) : 0; slen = fi->content.buf ? strlen(fi->content.buf) : 0;
fi->content.buf = (char *) erealloc(fi->content.buf, slen + len + 1); fi->content.buf = (char *) erealloc(fi->content.buf, slen + len + 1);
(fi->content.buf)[slen] = '\0'; (fi->content.buf)[slen] = '\0';
strcat(fi->content.buf, buffer); strcat(fi->content.buf, buffer);
} }
outgoing_event_reads = pending_event_reads; oeventread = peventread;
pending_event_reads = nil; peventread = nil;
while((req = outgoing_event_reads)) { while((req = oeventread)) {
outgoing_event_reads = outgoing_event_reads->aux; oeventread = oeventread->aux;
respond_event(req); respond_event(req);
} }
} }
@ -361,8 +354,6 @@ dostat(Stat *s, uint len, FileId *f) {
s->muid = user; s->muid = user;
} }
/* lookup_file */
/***************/
/* All lookups and directory organization should be performed through /* All lookups and directory organization should be performed through
* lookup_file, mostly through the dirtabs[] tree. */ * lookup_file, mostly through the dirtabs[] tree. */
static FileId * static FileId *
@ -508,7 +499,6 @@ verify_file(FileId *f) {
} }
/* Service Functions */ /* Service Functions */
/*********************/
void void
fs_attach(Ixp9Req *r) { fs_attach(Ixp9Req *r) {
FileId *f = get_file(); FileId *f = get_file();
@ -826,8 +816,8 @@ fs_open(Ixp9Req *r) {
case FsFEvent: case FsFEvent:
fl = emallocz(sizeof(FidLink)); fl = emallocz(sizeof(FidLink));
fl->fid = r->fid; fl->fid = r->fid;
fl->next = pending_event_fids; fl->next = peventfid;
pending_event_fids = fl; peventfid = fl;
break; break;
} }
if((r->ifcall.mode&3) == P9_OEXEC) { if((r->ifcall.mode&3) == P9_OEXEC) {
@ -855,7 +845,6 @@ fs_create(Ixp9Req *r) {
switch(f->tab.type) { switch(f->tab.type) {
default: default:
/* XXX: This should be taken care of by the library */
respond(r, Enoperm); respond(r, Enoperm);
return; return;
case FsDBars: case FsDBars:
@ -890,7 +879,6 @@ fs_remove(Ixp9Req *r) {
switch(f->tab.type) { switch(f->tab.type) {
default: default:
/* XXX: This should be taken care of by the library */
respond(r, Enoperm); respond(r, Enoperm);
return; return;
case FsFBar: case FsFBar:
@ -937,7 +925,7 @@ fs_clunk(Ixp9Req *r) {
draw_bar(screen); draw_bar(screen);
break; break;
case FsFEvent: case FsFEvent:
for(fl=&pending_event_fids; *fl; fl=&(*fl)->next) for(fl=&peventfid; *fl; fl=&(*fl)->next)
if((*fl)->fid == r->fid) { if((*fl)->fid == r->fid) {
ft = *fl; ft = *fl;
*fl = (*fl)->next; *fl = (*fl)->next;
@ -955,7 +943,7 @@ void
fs_flush(Ixp9Req *r) { fs_flush(Ixp9Req *r) {
Ixp9Req **i, **j; 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) for(j=i; *j; j=(Ixp9Req **)&(*j)->aux)
if(*j == r->oldreq) { if(*j == r->oldreq) {
*j = (*j)->aux; *j = (*j)->aux;

View File

@ -63,9 +63,10 @@ rect_morph_xy(XRectangle *rect, int dx, int dy, BlitzAlign *mask) {
typedef struct { typedef struct {
XRectangle *rects; XRectangle *rects;
int num; int num;
int x1, y1, x2, y2; int x1, y1;
int x2, y2;
int dx, dy;
BlitzAlign mask; BlitzAlign mask;
int *delta;
} SnapArgs; } SnapArgs;
static void static void
@ -78,44 +79,48 @@ snap_line(SnapArgs *a) {
if(!(r_east(&a->rects[i]) < a->x1) || if(!(r_east(&a->rects[i]) < a->x1) ||
(a->rects[i].x > a->x2)) { (a->rects[i].x > a->x2)) {
if(abs(a->rects[i].y - a->y1) <= abs(*a->delta)) if(abs(a->rects[i].y - a->y1) <= abs(a->dy))
*a->delta = a->rects[i].y - a->y1; a->dy = a->rects[i].y - a->y1;
t_xy = r_south(&a->rects[i]); t_xy = r_south(&a->rects[i]);
if(abs(t_xy - a->y1) < abs(*a->delta)) if(abs(t_xy - a->y1) < abs(a->dy))
*a->delta = t_xy - a->y1; a->dy = t_xy - a->y1;
} }
} }
} }
else if (a->mask & (EAST|WEST)) { 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++) { for(i=0; i < a->num; i++) {
if(!(r_south(&a->rects[i]) < a->y1) || if(!(r_south(&a->rects[i]) < a->y1) ||
(a->rects[i].y > a->y2)) { (a->rects[i].y > a->y2)) {
if(abs(a->rects[i].x - a->x1) <= abs(*a->delta)) if(abs(a->rects[i].x - a->x1) <= abs(a->dx))
*a->delta = a->rects[i].x - a->x1; a->dx = a->rects[i].x - a->x1;
t_xy = r_east(&a->rects[i]); t_xy = r_east(&a->rects[i]);
if(abs(t_xy - a->x1) < abs(*a->delta)) if(abs(t_xy - a->x1) < abs(a->dx))
*a->delta = t_xy - a->x1; 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 BlitzAlign
snap_rect(XRectangle *rects, int num, XRectangle *current, BlitzAlign *mask, int snap) { snap_rect(XRectangle *rects, int num, XRectangle *current, BlitzAlign *mask, int snap) {
SnapArgs a = { rects, num, 0, 0, 0, 0, *mask, nil }; SnapArgs a = { 0, };
int dx, dy;
BlitzAlign ret; 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.x1 = current->x;
a.x2 = r_east(current); a.x2 = r_east(current);
a.delta = &dy;
if(*mask & NORTH) { if(*mask & NORTH) {
a.y2 = a.y1 = current->y; a.y2 = a.y1 = current->y;
snap_line(&a); snap_line(&a);
@ -127,7 +132,6 @@ snap_rect(XRectangle *rects, int num, XRectangle *current, BlitzAlign *mask, int
a.y1 = current->y; a.y1 = current->y;
a.y2 = r_south(current); a.y2 = r_south(current);
a.delta = &dx;
if(*mask & EAST) { if(*mask & EAST) {
a.x1 = a.x2 = r_east(current); a.x1 = a.x2 = r_east(current);
snap_line(&a); snap_line(&a);
@ -137,17 +141,20 @@ snap_rect(XRectangle *rects, int num, XRectangle *current, BlitzAlign *mask, int
snap_line(&a); snap_line(&a);
} }
rect_morph_xy(current, ret = CENTER;
abs(dx) <= snap ? dx : 0, if(abs(a.dx) > snap)
abs(dy) <= snap ? dy : 0, a.dx = 0;
mask); else
ret = *mask;
if(abs(dx) <= snap)
ret ^= EAST|WEST; ret ^= EAST|WEST;
if(abs(dy) <= snap)
if(abs(a.dy) > snap)
a.dy = 0;
else
ret ^= NORTH|SOUTH; ret ^= NORTH|SOUTH;
return ret ^ CENTER;
rect_morph_xy(current, a.dx, a.dy, mask);
return ret ^ *mask;
} }
static void static void
@ -273,14 +280,21 @@ do_move:
focus(frame->client, True); 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 static void
do_managed_move(Client *c) { do_managed_move(Client *c) {
XRectangle frect, ofrect; XRectangle frect, ofrect;
Window dummy;
XEvent ev; XEvent ev;
Frame *f; Frame *f;
uint di; int x, y;
int x, y, i;
focus(c, False); focus(c, False);
f = c->sel; f = c->sel;
@ -291,7 +305,7 @@ do_managed_move(Client *c) {
return; return;
XGrabServer(blz.dpy); 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); find_droppoint(f, x, y, &frect, False);
draw_xor_border(&frect); draw_xor_border(&frect);
@ -320,7 +334,7 @@ do_managed_move(Client *c) {
} }
break; break;
case Expose: case Expose:
(handler[Expose])(&ev); dispatch_event(&ev);
break; break;
default: break; default: break;
} }
@ -334,8 +348,8 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
Cursor cur; Cursor cur;
XEvent ev; XEvent ev;
XRectangle *rects, ofrect, frect, origin; XRectangle *rects, ofrect, frect, origin;
int snap, dx, dy, pt_x, pt_y, hr_x, hr_y, i; int snap, dx, dy, pt_x, pt_y, hr_x, hr_y;
uint num, di; uint num;
Bool floating; Bool floating;
float rx, ry; float rx, ry;
Frame *f; 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; rx = (float)pt_x / frect.width;
ry = (float)pt_y / frect.height; ry = (float)pt_y / frect.height;
@ -378,7 +392,7 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
) != GrabSuccess) ) != GrabSuccess)
return; 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) { if(align != CENTER) {
hr_x = dx = frect.width / 2; hr_x = dx = frect.width / 2;
@ -508,7 +522,7 @@ do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
} }
break; break;
case Expose: case Expose:
(handler[Expose])(&ev); dispatch_event(&ev);
break; break;
default: default:
break; break;
@ -520,7 +534,7 @@ void
grab_button(Window w, uint button, ulong mod) { grab_button(Window w, uint button, ulong mod) {
XGrabButton(blz.dpy, button, mod, w, False, ButtonMask, XGrabButton(blz.dpy, button, mod, w, False, ButtonMask,
GrabModeSync, GrabModeSync, None, None); 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, XGrabButton(blz.dpy, button, mod | num_lock_mask, w, False, ButtonMask,
GrabModeSync, GrabModeAsync, None, None); GrabModeSync, GrabModeAsync, None, None);
XGrabButton(blz.dpy, button, mod | num_lock_mask | LockMask, w, False, XGrabButton(blz.dpy, button, mod | num_lock_mask | LockMask, w, False,

View File

@ -41,8 +41,6 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <util.h> #include <util.h>
#define nil ((void*)0)
char version[] = "@(#) wmii9menu version 1.8"; char version[] = "@(#) wmii9menu version 1.8";
/* lovely X stuff */ /* lovely X stuff */

View File

@ -80,8 +80,8 @@ str_of_time(uint val) {
} }
static void static void
print_stat(Stat *s, int details) { print_stat(Stat *s, int lflag) {
if(details) if(lflag)
fprintf(stdout, "%s %s %s %5llu %s %s\n", str_of_mode(s->mode), 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); s->uid, s->gid, s->length, str_of_time(s->mtime), s->name);
else { else {