Pre-merge mess.

This commit is contained in:
Kris Maglione 2008-01-18 15:05:45 -05:00
parent 0d05e4f153
commit f6c2a49d34
44 changed files with 710 additions and 728 deletions

View File

@ -23,5 +23,6 @@ deb:
dpkg-buildpackage -rfakeroot dpkg-buildpackage -rfakeroot
include ${ROOT}/mk/dir.mk include ${ROOT}/mk/dir.mk
include ${ROOT}/mk/common.mk
INSTDIRS = ${PDIRS} INSTDIRS = ${PDIRS}

View File

@ -6,7 +6,6 @@
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include "fns.h" #include "fns.h"

View File

@ -3,7 +3,6 @@
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */
#include "dat.h" #include "dat.h"
#include <stdio.h>
#include <string.h> #include <string.h>
#include "fns.h" #include "fns.h"
@ -56,8 +55,8 @@ create_bar(Bar **bp, char *name) {
utflcpy(b->name, name, sizeof(b->name)); utflcpy(b->name, name, sizeof(b->name));
b->col = def.normcolor; b->col = def.normcolor;
for(; *bp; bp = &(*bp)->next) for(; *bp; bp = &bp[0]->next)
if(strcmp((*bp)->name, name) >= 0) if(strcmp(bp[0]->name, name) >= 0)
break; break;
b->next = *bp; b->next = *bp;
*bp = b; *bp = b;
@ -69,7 +68,7 @@ void
destroy_bar(Bar **bp, Bar *b) { destroy_bar(Bar **bp, Bar *b) {
Bar **p; Bar **p;
for(p = bp; *p; p = &(*p)->next) for(p = bp; *p; p = &p[0]->next)
if(*p == b) break; if(*p == b) break;
*p = b->next; *p = b->next;
@ -113,12 +112,11 @@ draw_bar(WMScreen *s) {
width += Dx(b->r); width += Dx(b->r);
} }
if(width > Dx(s->brect)) { /* Not enough room. Shrink bars until they all fit. */ if(width > Dx(s->brect)) { /* Not enough room. Shrink bars until they all fit. */
for(nb = 0; nb < nelem(s->bar); nb++) for(nb = 0; nb < nelem(s->bar); nb++)
for(b = s->bar[nb]; b; b=b->next) { for(b = s->bar[nb]; b; b=b->next) {
for(pb = &largest; *pb; pb = &(*pb)->smaller) for(pb = &largest; *pb; pb = &pb[0]->smaller)
if(Dx((*pb)->r) < Dx(b->r)) if(Dx(pb[0]->r) < Dx(b->r))
break; break;
b->smaller = *pb; b->smaller = *pb;
*pb = b; *pb = b;
@ -131,13 +129,14 @@ draw_bar(WMScreen *s) {
if(Dx(tb->r) * shrink >= Dx(tb->smaller->r)) if(Dx(tb->r) * shrink >= Dx(tb->smaller->r))
break; break;
} }
SET(shrink);
if(tb) if(tb)
for(b = largest; b != tb->smaller; b = b->smaller) for(b = largest; b != tb->smaller; b = b->smaller)
b->r.max.x *= shrink; b->r.max.x *= shrink;
width += tw * shrink; width += tw * shrink;
} }
SET(tb); tb = nil;
for(nb = 0; nb < nelem(s->bar); nb++) for(nb = 0; nb < nelem(s->bar); nb++)
for(b = s->bar[nb]; b; tb=b, b=b->next) { for(b = s->bar[nb]; b; tb=b, b=b->next) {
if(b == s->bar[BarRight]) if(b == s->bar[BarRight])
@ -198,8 +197,7 @@ static void
bup_event(Window *w, XButtonPressedEvent *e) { bup_event(Window *w, XButtonPressedEvent *e) {
Bar *b; Bar *b;
USED(w); USED(w, e);
USED(e);
for(b=screen->bar[BarLeft]; b; b=b->next) for(b=screen->bar[BarLeft]; b; b=b->next)
if(ptinrect(Pt(e->x, e->y), b->r)) { if(ptinrect(Pt(e->x, e->y), b->r)) {
@ -215,8 +213,7 @@ bup_event(Window *w, XButtonPressedEvent *e) {
static void static void
expose_event(Window *w, XExposeEvent *e) { expose_event(Window *w, XExposeEvent *e) {
USED(w); USED(w, e);
USED(e);
draw_bar(screen); draw_bar(screen);
} }

View File

@ -5,7 +5,6 @@
#include "dat.h" #include "dat.h"
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include "fns.h" #include "fns.h"
@ -76,7 +75,7 @@ create_client(XWindow w, XWindowAttributes *wa) {
grab_button(c->framewin->w, AnyButton, AnyModifier); grab_button(c->framewin->w, AnyButton, AnyModifier);
for(t=&client ;; t=&(*t)->next) for(t=&client ;; t=&t[0]->next)
if(!*t) { if(!*t) {
c->next = *t; c->next = *t;
*t = c; *t = c;
@ -125,8 +124,7 @@ manage_client(Client *c) {
static int /* Temporary Xlib error handler */ static int /* Temporary Xlib error handler */
ignoreerrors(Display *d, XErrorEvent *e) { ignoreerrors(Display *d, XErrorEvent *e) {
USED(d); USED(d, e);
USED(e);
return 0; return 0;
} }
@ -142,7 +140,7 @@ destroy_client(Client *c) {
unmapwin(c->framewin); unmapwin(c->framewin);
for(tc=&client; *tc; tc=&(*tc)->next) for(tc=&client; *tc; tc=&tc[0]->next)
if(*tc == c) { if(*tc == c) {
*tc = c->next; *tc = c->next;
break; break;
@ -330,32 +328,27 @@ focus_client(Client *c) {
Dprint("focus_client(%p[%C]) => %s\n", c, c, clientname(c)); Dprint("focus_client(%p[%C]) => %s\n", c, c, clientname(c));
if (screen->focus == c) if((c == nil || !c->noinput) && screen->focus != c) {
return;
if(c == nil || !c->noinput) {
Dprint("\t%s => %s\n", clientname(screen->focus), clientname(c)); Dprint("\t%s => %s\n", clientname(screen->focus), clientname(c));
if(c) if(c)
setfocus(&c->w, RevertToPointerRoot); setfocus(&c->w, RevertToParent);
else else
setfocus(screen->barwin, RevertToPointerRoot); setfocus(screen->barwin, RevertToParent);
write_event("ClientFocus %C\n", c); write_event("ClientFocus %C\n", c);
XSync(display, False); XSync(display, False);
flushevents(FocusChangeMask, True); flushevents(FocusChangeMask, True);
} else if(c && c->noinput) {
setfocus(nil, RevertToPointerRoot);
} }
} }
void void
resize_client(Client *c, Rectangle *r) { resize_client(Client *c, Rectangle r) {
Frame *f; Frame *f;
f = c->sel; f = c->sel;
resize_frame(f, *r); resize_frame(f, r);
if(f->area->view != screen->sel) { if(f->area->view != screen->sel) {
unmap_client(c, IconicState); unmap_client(c, IconicState);
@ -455,10 +448,6 @@ fullscreen(Client *c, int fullscreen) {
if((f = c->sel)) { if((f = c->sel)) {
if(fullscreen) { if(fullscreen) {
/* we lose information here if the client was just moved to
* the floating area, but it's worth it */
c->revert = f->area;
if(f->area->floating) if(f->area->floating)
f->revert = f->r; f->revert = f->r;
else { else {
@ -466,13 +455,8 @@ fullscreen(Client *c, int fullscreen) {
send_to_area(f->view->area, f); send_to_area(f->view->area, f);
} }
focus_client(c); focus_client(c);
}else { }else
resize_frame(f, f->revert); resize_frame(f, f->revert);
if (c->revert) {
send_to_area(c->revert, f);
c->revert = nil;
}
}
if(f->view == screen->sel) if(f->view == screen->sel)
focus_view(screen, f->view); focus_view(screen, f->view);
} }
@ -589,7 +573,7 @@ updatemwm(Client *c) {
if(c->sel) { if(c->sel) {
r = client2frame(c->sel, r); r = client2frame(c->sel, r);
resize_client(c, &r); resize_client(c, r);
draw_frame(c->sel); draw_frame(c->sel);
} }
} }
@ -672,7 +656,7 @@ configreq_event(Window *w, XConfigureRequestEvent *e) {
fullscreen(c, True); fullscreen(c, True);
if(c->sel->area->floating) if(c->sel->area->floating)
resize_client(c, &r); resize_client(c, r);
else { else {
c->sel->revert = r; c->sel->revert = r;
configure_client(c); configure_client(c);
@ -681,8 +665,7 @@ configreq_event(Window *w, XConfigureRequestEvent *e) {
static void static void
destroy_event(Window *w, XDestroyWindowEvent *e) { destroy_event(Window *w, XDestroyWindowEvent *e) {
USED(w); USED(w, e);
USED(e);
Dprint("client.c:destroy_event(%W)\n", w); Dprint("client.c:destroy_event(%W)\n", w);
destroy_client(w->aux); destroy_client(w->aux);
@ -823,7 +806,7 @@ update_client_views(Client *c, char **tags) {
SET(cmp); SET(cmp);
while(*fp) { while(*fp) {
if(*tags) { if(*tags) {
cmp = strcmp((*fp)->view->name, *tags); cmp = strcmp(fp[0]->view->name, *tags);
if(cmp >= 0) if(cmp >= 0)
break; break;
} }
@ -844,7 +827,7 @@ update_client_views(Client *c, char **tags) {
f->cnext = *fp; f->cnext = *fp;
*fp = f; *fp = f;
} }
if(*fp) fp=&(*fp)->cnext; if(fp[0]) fp=&fp[0]->cnext;
tags++; tags++;
} }
} }
@ -857,8 +840,12 @@ bsstrcmp(const void *a, const void *b) {
} }
static int static int
strpcmp(const void *a, const void *b) { strpcmp(const void *ap, const void *bp) {
return strcmp(*(char **)a, *(char **)b); char **a, **b;
a = (char**)ap; /* gcc wants this case. *sigh* */
b = (char**)bp;
return strcmp(*a, *b);
} }
static char *badtags[] = { static char *badtags[] = {

View File

@ -5,7 +5,6 @@
#include "dat.h" #include "dat.h"
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include "fns.h" #include "fns.h"
@ -359,14 +358,14 @@ arrange_column(Area *a, Bool dirty) {
resize: resize:
if(a->view == screen->sel) { if(a->view == screen->sel) {
restack_view(a->view); restack_view(a->view);
resize_client(a->sel->client, &a->sel->r); resize_client(a->sel->client, a->sel->r);
for(f=a->frame; f; f=f->anext) for(f=a->frame; f; f=f->anext)
if(!f->collapsed && f != a->sel) if(!f->collapsed && f != a->sel)
resize_client(f->client, &f->r); resize_client(f->client, f->r);
for(f=a->frame; f; f=f->anext) for(f=a->frame; f; f=f->anext)
if(f->collapsed && f != a->sel) if(f->collapsed && f != a->sel)
resize_client(f->client, &f->r); resize_client(f->client, f->r);
} }
} }
@ -425,17 +424,15 @@ resize_colframe(Frame *f, Rectangle *r) {
Area *a, *al, *ar; Area *a, *al, *ar;
View *v; View *v;
uint minw; uint minw;
int dx, dw; int dx, dw, maxx;
a = f->area; a = f->area;
v = a->view; v = a->view;
maxx = r->max.x;
minw = Dx(screen->r) / NCOL; minw = Dx(screen->r) / NCOL;
if(a->prev && !a->prev->floating) al = a->prev;
al = a->prev;
else
al = nil;
ar = a->next; ar = a->next;
if(al) if(al)
@ -443,26 +440,28 @@ resize_colframe(Frame *f, Rectangle *r) {
else else
r->min.x = max(r->min.x, 0); r->min.x = max(r->min.x, 0);
if(ar) if(ar) {
r->max.x = min(r->max.x, ar->r.max.x - minw); if(maxx >= ar->r.max.x - minw)
maxx = ar->r.max.x - minw;
}
else else
r->max.x = min(r->max.x, screen->r.max.x); if(maxx > screen->r.max.x)
maxx = screen->r.max.x;
dx = a->r.min.x - r->min.x; dx = a->r.min.x - r->min.x;
dw = r->max.x - a->r.max.x; dw = maxx - a->r.max.x;
if(al) { if(al) {
al->r.max.x -= dx; al->r.max.x -= dx;
arrange_column(al, False); arrange_column(al, False);
} }
if(ar) { if(ar) {
ar->r.min.x += dw; ar->r.max.x -= dw;
arrange_column(ar, False); arrange_column(ar, False);
} }
resize_colframeh(f, r); resize_colframeh(f, r);
a->r.min.x = r->min.x; a->r.max.x = maxx;
a->r.max.x = r->max.x;
arrange_view(a->view); arrange_view(a->view);
focus_view(screen, v); focus_view(screen, v);

View File

@ -131,26 +131,24 @@ struct Client {
Area *revert; Area *revert;
Frame *frame; Frame *frame;
Frame *sel; Frame *sel;
Window w;
Window *framewin;
XWindow trans;
Cursor cursor;
Rectangle r;
char name[256]; char name[256];
char tags[256]; char tags[256];
char props[512]; char props[512];
uint border; uint border;
int proto; int proto;
Bool floating; char floating;
Bool fixedsize; char fixedsize;
Bool fullscreen; char fullscreen;
Bool urgent; char urgent;
Bool borderless; char borderless;
Bool titleless; char titleless;
Bool noinput; char noinput;
int unmapped; int unmapped;
Window w;
XWindow trans;
Window *framewin;
Cursor cursor;
Rectangle r;
XSizeHints size;
GC gc;
}; };
struct Divide { struct Divide {
@ -193,19 +191,23 @@ struct Ruleset {
uint size; uint size;
}; };
#ifndef EXTERN
# define EXTERN extern
#endif
/* global variables */ /* global variables */
struct { EXTERN struct {
CTuple focuscolor; CTuple focuscolor;
CTuple normcolor; CTuple normcolor;
Font *font; Font *font;
uint border;
uint snap;
char *keys; char *keys;
uint keyssz;
Ruleset tagrules; Ruleset tagrules;
Ruleset colrules; Ruleset colrules;
char grabmod[5]; char grabmod[5];
ulong mod; ulong mod;
uint border;
uint snap;
uint keyssz;
int colmode; int colmode;
} def; } def;
@ -213,7 +215,7 @@ enum {
BarLeft, BarRight BarLeft, BarRight
}; };
struct WMScreen { EXTERN struct WMScreen {
Bar *bar[2]; Bar *bar[2];
View *sel; View *sel;
Client *focus; Client *focus;
@ -225,39 +227,41 @@ struct WMScreen {
Rectangle brect; Rectangle brect;
} *screens, *screen; } *screens, *screen;
Client *client; EXTERN Client* client;
View *view; EXTERN View* view;
Key *key; EXTERN Key* key;
Divide *divs; EXTERN Divide* divs;
Client c_magic; EXTERN Client c_magic;
Client c_root; EXTERN Client c_root;
Handlers framehandler; EXTERN Handlers framehandler;
char buffer[8092]; EXTERN char buffer[8092];
/* IXP */ /* IXP */
IxpServer srv; EXTERN IxpServer srv;
Ixp9Srv p9srv; EXTERN Ixp9Srv p9srv;
/* X11 */ /* X11 */
uint num_screens; EXTERN uint num_screens;
uint valid_mask; EXTERN uint valid_mask;
uint num_lock_mask; EXTERN uint num_lock_mask;
Bool sel_screen; EXTERN Bool sel_screen;
Image xor; EXTERN Cursor cursor[CurLast];
Cursor cursor[CurLast]; typedef void (*XHandler)(XEvent*);
void (*handler[LASTEvent]) (XEvent *); EXTERN XHandler handler[LASTEvent];
/* Misc */ /* Misc */
Image *broken; EXTERN Image* broken;
Bool starting; EXTERN Bool starting;
Bool verbose; EXTERN Bool verbose;
char *user; EXTERN char* user;
char *execstr; EXTERN char* execstr;
#define BLOCK(x) do { x; }while(0)
#define Debug if(verbose) #define Debug if(verbose)
#define Dprint(...) do{ Debug fprint(2, __VA_ARGS__); }while(0) #define Dprint(...) BLOCK( Debug fprint(2, __VA_ARGS__) )

View File

@ -2,7 +2,6 @@
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */
#include "dat.h" #include "dat.h"
#include <stdio.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include "fns.h" #include "fns.h"
#include "printevent.h" #include "printevent.h"
@ -135,7 +134,7 @@ focusin(XEvent *e) {
if(ev->detail == NotifyDetailNone) { if(ev->detail == NotifyDetailNone) {
print_focus(&c_magic, "<magic[none]>"); print_focus(&c_magic, "<magic[none]>");
screen->focus = &c_magic; screen->focus = &c_magic;
setfocus(screen->barwin, RevertToPointerRoot); setfocus(screen->barwin, RevertToParent);
return; return;
} }

View File

@ -13,234 +13,232 @@
#endif #endif
/* area.c */ /* area.c */
char *area_name(Area *a); uint area_idx(Area*);
uint area_idx(Area *a); char* area_name(Area*);
Area *create_area(View*, Area *pos, uint w); Client* area_selclient(Area*);
void destroy_area(Area*); void attach_to_area(Area*, Frame*);
Area *area_of_id(View*, ushort id); Area* create_area(View*, Area *pos, uint w);
void focus_area(Area*); void destroy_area(Area*);
void send_to_area(Area*, Frame*); void detach_from_area(Frame*);
void attach_to_area(Area*, Frame*); void focus_area(Area*);
void detach_from_area(Frame*); void send_to_area(Area*, Frame*);
Client *area_selclient(Area*);
/* bar.c */ /* bar.c */
void initbar(WMScreen *s); Bar* bar_of_name(Bar*, const char*);
Bar *create_bar(Bar **b_link, char *name); Bar* create_bar(Bar**, char*);
void destroy_bar(Bar **b_link, Bar*); void destroy_bar(Bar**, Bar*);
void draw_bar(WMScreen *s); void draw_bar(WMScreen*);
void resize_bar(WMScreen *s); void initbar(WMScreen*);
Bar *bar_of_name(Bar *b_link, const char *name); void resize_bar(WMScreen*);
/* client.c */ /* client.c */
Client *create_client(XWindow, XWindowAttributes*); int Cfmt(Fmt *f);
void destroy_client(Client*); void apply_rules(Client*);
void configure_client(Client*); void apply_tags(Client*, const char*);
void update_class(Client *c); char* clientname(Client*);
void prop_client(Client *c, Atom); void configure_client(Client*);
void kill_client(Client*); Client* create_client(XWindow, XWindowAttributes*);
void gravitate_client(Client*, Bool invert); void destroy_client(Client*);
void map_client(Client*); void focus(Client*, Bool restack);
void unmap_client(Client*, int state); void focus_client(Client*);
int map_frame(Client*); void focus_frame(Frame*, Bool restack);
int unmap_frame(Client*); void fullscreen(Client*, Bool);
Rectangle gravclient(Client*, Rectangle); void kill_client(Client*);
void fullscreen(Client*, Bool); void manage_client(Client*);
void set_urgent(Client *, Bool urgent, Bool write); void map_client(Client*);
void set_cursor(Client*, Cursor); int map_frame(Client*);
void focus_frame(Frame*, Bool restack); void move_client(Client*, char*);
void reparent_client(Client*, Window*, Point); void prop_client(Client*, Atom);
void manage_client(Client*); void reparent_client(Client*, Window*, Point);
void focus(Client*, Bool restack); void resize_client(Client*, Rectangle);
void focus_client(Client*); Client* selclient(void);
void resize_client(Client*, Rectangle*); void set_cursor(Client*, Cursor);
void apply_sizehints(Client*, Rectangle*, Bool floating, Bool frame, Align sticky); void set_urgent(Client *, Bool urgent, Bool write);
void move_client(Client*, char *arg); void size_client(Client*, char*);
void size_client(Client*, char *arg); void unmap_client(Client*, int state);
Client *selclient(void); int unmap_frame(Client*);
Client *win2client(XWindow); void update_class(Client*);
int Cfmt(Fmt *f); Client* win2client(XWindow);
char *clientname(Client*); Rectangle gravclient(Client*, Rectangle);
void apply_rules(Client*);
void apply_tags(Client*, const char*);
/* column.c */ /* column.c */
void update_divs(void); void arrange_column(Area*, Bool dirty);
void draw_div(Divide*); char* colmode2str(int);
void setdiv(Divide*, int x); void draw_div(Divide*);
void arrange_column(Area*, Bool dirty); Area* new_column(View*, Area *, uint);
void resize_column(Area*, int w); void resize_colframe(Frame*, Rectangle*);
void resize_colframe(Frame*, Rectangle*); void resize_column(Area*, int);
int str2colmode(const char *str); void setdiv(Divide*, int x);
char *colmode2str(int i); int str2colmode(const char*);
Area *new_column(View*, Area *pos, uint w); void update_divs(void);
/* event.c */ /* event.c */
void dispatch_event(XEvent*); void check_x_event(IxpConn*);
void check_x_event(IxpConn*); void dispatch_event(XEvent*);
uint flushevents(long even_mask, Bool dispatch); uint flushevents(long, Bool dispatch);
void print_focus(Client *c, char *to); void print_focus(Client*, char*);
/* frame.c */ /* frame.c */
uint frame_idx(Frame *f); Frame* create_frame(Client*, View*);
Frame *create_frame(Client*, View*); void draw_frame(Frame*);
void remove_frame(Frame*); void draw_frames(void);
void insert_frame(Frame *pos, Frame*); int frame_delta_h(void);
void resize_frame(Frame*, Rectangle); uint frame_idx(Frame*);
Bool frame_to_top(Frame *f); Bool frame_to_top(Frame*);
void set_frame_cursor(Frame*, Point); int ingrabbox(Frame*, int x, int y);
void swap_frames(Frame*, Frame*); void insert_frame(Frame *pos, Frame*);
int frame_delta_h(void); void remove_frame(Frame*);
Rectangle frame_hints(Frame*, Rectangle, Align); void resize_frame(Frame*, Rectangle);
Rectangle frame2client(Frame*, Rectangle); void set_frame_cursor(Frame*, Point);
Rectangle client2frame(Frame*, Rectangle); void swap_frames(Frame*, Frame*);
int ingrabbox(Frame*, int x, int y); void update_frame_widget_colors(Frame*);
void draw_frame(Frame*);
void draw_frames(void);
void update_frame_widget_colors(Frame*);
Rectangle constrain(Rectangle); Rectangle constrain(Rectangle);
Rectangle client2frame(Frame*, Rectangle);
Rectangle frame2client(Frame*, Rectangle);
Rectangle frame_hints(Frame*, Rectangle, Align);
/* fs.c */ /* fs.c */
void fs_attach(Ixp9Req*); void fs_attach(Ixp9Req*);
void fs_clunk(Ixp9Req*); void fs_clunk(Ixp9Req*);
void fs_create(Ixp9Req*); void fs_create(Ixp9Req*);
void fs_flush(Ixp9Req*); void fs_flush(Ixp9Req*);
void fs_freefid(Fid*); void fs_freefid(Fid*);
void fs_open(Ixp9Req*); void fs_open(Ixp9Req*);
void fs_read(Ixp9Req*); void fs_read(Ixp9Req*);
void fs_remove(Ixp9Req*); void fs_remove(Ixp9Req*);
void fs_stat(Ixp9Req*); void fs_stat(Ixp9Req*);
void fs_walk(Ixp9Req*); void fs_walk(Ixp9Req*);
void fs_write(Ixp9Req*); void fs_write(Ixp9Req*);
void write_event(char*, ...); void write_event(char*, ...);
/* geom.c */ /* geom.c */
Bool ptinrect(Point, Rectangle); Cursor cursor_of_quad(Align);
Align quadrant(Rectangle, Point); Align get_sticky(Rectangle src, Rectangle dst);
Cursor cursor_of_quad(Align); Bool ptinrect(Point, Rectangle);
Align get_sticky(Rectangle src, Rectangle dst); Align quadrant(Rectangle, Point);
/* key.c */ /* key.c */
void kpress(XWindow, ulong mod, KeyCode); void init_lock_keys(void);
void update_keys(void); void kpress(XWindow, ulong mod, KeyCode);
void init_lock_keys(void); ulong str2modmask(char*);
ulong str2modmask(char*); void update_keys(void);
/* map.c */ /* map.c */
MapEnt* mapget(Map*, ulong, int create); MapEnt* hashget(Map*, char*, int create);
MapEnt* hashget(Map*, char*, int create); void* hashrm(Map*, char*);
void* maprm(Map*, ulong); MapEnt* mapget(Map*, ulong, int create);
void* hashrm(Map*, char*); void* maprm(Map*, ulong);
/* message.c */ /* message.c */
char *getword(IxpMsg*); int getlong(char*, long*);
int getulong(char*, ulong*); int getulong(char*, ulong*);
int getlong(char*, long*); char* getword(IxpMsg*);
Area *strarea(View*, char*); char* message_client(Client*, IxpMsg*);
char *message_view(View*, IxpMsg*); char* message_root(void*, IxpMsg*);
char *parse_colors(IxpMsg*, CTuple*); char* message_view(View*, IxpMsg*);
char *message_root(void*, IxpMsg*); char* parse_colors(IxpMsg*, CTuple*);
char *read_root_ctl(void); char* read_root_ctl(void);
char *message_client(Client*, IxpMsg*); char* select_area(Area*, IxpMsg*);
char *select_area(Area*, IxpMsg*); char* send_client(View*, IxpMsg*, Bool swap);
char *send_client(View*, IxpMsg*, Bool swap); Area* strarea(View*, char*);
/* mouse.c */ /* mouse.c */
void mouse_resizecol(Divide*); void do_mouse_resize(Client*, Bool opaque, Align);
void do_mouse_resize(Client*, Bool opaque, Align); void grab_button(XWindow, uint button, ulong mod);
void grab_mouse(XWindow, ulong mod, ulong button); void grab_mouse(XWindow, ulong mod, ulong button);
void ungrab_mouse(XWindow, ulong mod, uint button); void mouse_resizecol(Divide*);
Align snap_rect(Rectangle *rects, int num, Rectangle *current, Align *mask, int snapw); Align snap_rect(Rectangle *rects, int num, Rectangle *current, Align *mask, int snapw);
void grab_button(XWindow, uint button, ulong mod); void ungrab_mouse(XWindow, ulong mod, uint button);
/* rule.c */ /* rule.c */
void update_rules(Rule**, const char*); void trim(char *str, const char *chars);
void trim(char *str, const char *chars); void update_rules(Rule**, const char*);
/* view.c */ /* view.c */
void arrange_view(View*); View *get_view(const char*);
void scale_view(View*, int w); void arrange_view(View*);
View *get_view(const char*); void attach_to_view(View*, Frame*);
View *create_view(const char*); View* create_view(const char*);
void focus_view(WMScreen*, View*); void destroy_view(View*);
void update_client_views(Client*, char**); void focus_view(WMScreen*, View*);
Rectangle *rects_of_view(View*, uint *num, Frame *ignore); char* message_view(View *v, IxpMsg *m);
View *view_of_id(ushort); uint newcolw(View*, int i);
Frame *view_clientframe(View *v, Client *c); void restack_view(View*);
void select_view(const char*); void scale_view(View*, int w);
void attach_to_view(View*, Frame*); void select_view(const char*);
Client *view_selclient(View*); void update_client_views(Client*, char**);
char *message_view(View *v, IxpMsg *m); void update_views(void);
void restack_view(View*); Frame* view_clientframe(View *v, Client *c);
uchar *view_index(View*); uchar* view_ctl(View *v);
uchar *view_ctl(View *v); uchar* view_index(View*);
void destroy_view(View*); View* view_of_id(ushort);
void update_views(void); Client* view_selclient(View*);
uint newcolw(View*, int i); Rectangle* rects_of_view(View*, uint *num, Frame *ignore);
/* wm.c */ /* wm.c */
int win_proto(Window); int win_proto(Window);
/* x11.c */ /* x11.c */
XRectangle XRect(Rectangle); Window *createwindow(Window *parent, Rectangle, int depth, uint class, WinAttr*, int valuemask);
int eqrect(Rectangle, Rectangle); char *gettextproperty(Window*, char*);
int eqpt(Point, Point); Point addpt(Point, Point);
Point addpt(Point, Point); Image* allocimage(int w, int h, int depth);
Point subpt(Point, Point); void border(Image *dst, Rectangle, int w, ulong col);
Point mulpt(Point p, Point q); void changeprop_char(Window *w, char *prop, char *type, char data[], int len);
Point divpt(Point, Point); void changeprop_long(Window *w, char *prop, char *type, long data[], int len);
Rectangle insetrect(Rectangle, int); void changeprop_short(Window *w, char *prop, char *type, short data[], int len);
Rectangle rectaddpt(Rectangle, Point); void changeproperty(Window*, char *prop, char *type, int width, uchar *data, int n);
Rectangle rectsubpt(Rectangle, Point); void copyimage(Image *dst, Rectangle, Image *src, Point p);
void initdisplay(void); void destroywindow(Window*);
Image * allocimage(int w, int h, int depth); Point divpt(Point, Point);
void freeimage(Image *); void drawline(Image *dst, Point p1, Point p2, int cap, int w, ulong col);
Window *createwindow(Window *parent, Rectangle, int depth, uint class, WinAttr*, int valuemask); void drawpoly(Image *dst, Point *pt, int np, int cap, int w, ulong col);
void reparentwindow(Window*, Window*, Point); void drawstring(Image *dst, Font *font, Rectangle, Align align, char *text, ulong col);
void destroywindow(Window*); int eqpt(Point, Point);
void setwinattr(Window*, WinAttr*, int valmask); int eqrect(Rectangle, Rectangle);
void reshapewin(Window*, Rectangle); void fill(Image *dst, Rectangle, ulong col);
void movewin(Window*, Point); void fillpoly(Image *dst, Point *pt, int np, ulong col);
int mapwin(Window*); Window* findwin(XWindow);
int unmapwin(Window*); void freefont(Font*);
void lowerwin(Window*); void freeimage(Image *);
void raisewin(Window*); void freestringlist(char**);
Handlers* sethandler(Window*, Handlers*); ulong getproperty(Window *w, char *prop, char *type, Atom *actual, ulong offset, uchar **ret, ulong length);
Window* findwin(XWindow); int gettextlistproperty(Window *w, char *name, char **ret[]);
uint winprotocols(Window*); int grabpointer(Window*, Window *confine, Cursor, int mask);
void setshapemask(Window *dst, Image *src, Point); void initdisplay(void);
void border(Image *dst, Rectangle, int w, ulong col); uint labelh(Font*);
void fill(Image *dst, Rectangle, ulong col); Bool loadcolor(CTuple*, char*);
void drawpoly(Image *dst, Point *pt, int np, int cap, int w, ulong col); Font* loadfont(char*);
void fillpoly(Image *dst, Point *pt, int np, ulong col); void lowerwin(Window*);
void drawline(Image *dst, Point p1, Point p2, int cap, int w, ulong col); int mapwin(Window*);
void drawstring(Image *dst, Font *font, Rectangle, Align align, char *text, ulong col); void movewin(Window*, Point);
void copyimage(Image *dst, Rectangle, Image *src, Point p); Point mulpt(Point p, Point q);
Bool namedcolor(char *name, ulong*); Bool namedcolor(char *name, ulong*);
Bool loadcolor(CTuple*, char*); Point querypointer(Window*);
Font * loadfont(char*); void raisewin(Window*);
void freefont(Font*); void reparentwindow(Window*, Window*, Point);
uint textwidth_l(Font*, char*, uint len); void reshapewin(Window*, Rectangle);
uint textwidth(Font*, char*); void setfocus(Window*, int mode);
uint labelh(Font*); void sethints(Window*);
Atom xatom(char*); void setshapemask(Window *dst, Image *src, Point);
void freestringlist(char**); void setwinattr(Window*, WinAttr*, int valmask);
ulong getproperty(Window *w, char *prop, char *type, Atom *actual, ulong offset, uchar **ret, ulong length); Point subpt(Point, Point);
char *gettextproperty(Window*, char*); uint textwidth(Font*, char*);
int gettextlistproperty(Window *w, char *name, char **ret[]); uint textwidth_l(Font*, char*, uint len);
void changeproperty(Window*, char *prop, char *type, int width, uchar *data, int n); Point translate(Window*, Window*, Point);
void changeprop_char(Window *w, char *prop, char *type, char data[], int len); void ungrabpointer(void);
void changeprop_short(Window *w, char *prop, char *type, short data[], int len); int unmapwin(Window*);
void changeprop_long(Window *w, char *prop, char *type, long data[], int len); void warppointer(Point);
void setfocus(Window*, int mode); uint winprotocols(Window*);
Point querypointer(Window*); Atom xatom(char*);
void warppointer(Point); Handlers* sethandler(Window*, Handlers*);
Point translate(Window*, Window*, Point); XRectangle XRect(Rectangle);
int grabpointer(Window*, Window *confine, Cursor, int mask); Rectangle gravitate(Rectangle dst, Rectangle src, Point grav);
void ungrabpointer(void); Rectangle insetrect(Rectangle, int);
Rectangle gravitate(Rectangle dst, Rectangle src, Point grav); Rectangle rectaddpt(Rectangle, Point);
Rectangle sizehint(WinHints*, Rectangle); Rectangle rectsubpt(Rectangle, Point);
void sethints(Window*); Rectangle sizehint(WinHints*, Rectangle);
char* toutf8n(char*, size_t); /* utf.c */
char* toutf8(char*); char* toutf8(char*);
char* toutf8n(char*, size_t);

View File

@ -3,7 +3,6 @@
*/ */
#include "dat.h" #include "dat.h"
#include <math.h> #include <math.h>
#include <stdio.h>
#include "fns.h" #include "fns.h"
uint uint
@ -337,13 +336,13 @@ swap_frames(Frame *fa, Frame *fb) {
if(fa == fb) return; if(fa == fb) return;
for(fp = &fa->client->frame; *fp; fp = &(*fp)->cnext) for(fp = &fa->client->frame; *fp; fp = &fp[0]->cnext)
if(*fp == fa) break; if(*fp == fa) break;
*fp = (*fp)->cnext; fp[0] = fp[0]->cnext;
for(fp = &fb->client->frame; *fp; fp = &(*fp)->cnext) for(fp = &fb->client->frame; *fp; fp = &fp[0]->cnext)
if(*fp == fb) break; if(*fp == fb) break;
*fp = (*fp)->cnext; fp[0] = fp[0]->cnext;
c = fa->client; c = fa->client;
fa->client = fb->client; fa->client = fb->client;

View File

@ -5,7 +5,6 @@
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
@ -185,8 +184,9 @@ write_buf(Ixp9Req *r, char *buf, uint len) {
/* This should be moved to libixp */ /* This should be moved to libixp */
static void static void
write_to_buf(Ixp9Req *r, void *buf, uint *len, uint max) { write_to_buf(Ixp9Req *r, char **buf, uint *len, uint max) {
uint offset, count; uint offset, count;
char *p;
offset = (r->fid->omode&OAPPEND) ? *len : r->ifcall.offset; offset = (r->fid->omode&OAPPEND) ? *len : r->ifcall.offset;
if(offset > *len || r->ifcall.count == 0) { if(offset > *len || r->ifcall.count == 0) {
@ -199,15 +199,14 @@ write_to_buf(Ixp9Req *r, void *buf, uint *len, uint max) {
count = max - offset; count = max - offset;
*len = offset + count; *len = offset + count;
if(max == 0)
*buf = erealloc((void*)*buf, *len + 1);
if(max == 0) { p = *buf;
*(void **)buf = erealloc(*(void **)buf, *len + 1);
buf = *(void **)buf;
}
memcpy((uchar*)buf + offset, r->ifcall.data, count); memcpy(p+offset, r->ifcall.data, count);
r->ofcall.count = count; r->ofcall.count = count;
((char *)buf)[offset+count] = '\0'; p[offset+count] = '\0';
} }
/* This should be moved to libixp */ /* This should be moved to libixp */
@ -583,7 +582,7 @@ fs_stat(Ixp9Req *r) {
m = ixp_message(buf, size, MsgPack); m = ixp_message(buf, size, MsgPack);
ixp_pstat(&m, &s); ixp_pstat(&m, &s);
r->ofcall.stat = m.data; r->ofcall.stat = (uchar*)m.data;
respond(r, nil); respond(r, nil);
} }
@ -701,6 +700,7 @@ void
fs_write(Ixp9Req *r) { fs_write(Ixp9Req *r) {
FileId *f; FileId *f;
char *errstr; char *errstr;
char *p;
uint i; uint i;
if(r->ifcall.count == 0) { if(r->ifcall.count == 0) {
@ -740,7 +740,9 @@ fs_write(Ixp9Req *r) {
return; return;
case FsFBar: case FsFBar:
i = strlen(f->p.bar->buf); i = strlen(f->p.bar->buf);
write_to_buf(r, f->p.bar->buf, &i, 279); /* Why the explicit cast? Ask gcc. */
p = f->p.bar->buf;
write_to_buf(r, &p, &i, 279);
r->ofcall.count = i - r->ifcall.offset; r->ofcall.count = i - r->ifcall.offset;
respond(r, nil); respond(r, nil);
return; return;
@ -761,9 +763,9 @@ fs_write(Ixp9Req *r) {
return; return;
case FsFEvent: case FsFEvent:
if(r->ifcall.data[r->ifcall.count-1] == '\n') if(r->ifcall.data[r->ifcall.count-1] == '\n')
write_event("%.*s", r->ifcall.count, r->ifcall.data); write_event("%.*s", (int)r->ifcall.count, r->ifcall.data);
else else
write_event("%.*s\n", r->ifcall.count, r->ifcall.data); write_event("%.*s\n", (int)r->ifcall.count, r->ifcall.data);
r->ofcall.count = r->ifcall.count; r->ofcall.count = r->ifcall.count;
respond(r, nil); respond(r, nil);
return; return;
@ -907,10 +909,10 @@ fs_clunk(Ixp9Req *r) {
draw_bar(screen); draw_bar(screen);
break; break;
case FsFEvent: case FsFEvent:
for(fl=&peventfid; *fl; fl=&(*fl)->next) for(fl=&peventfid; *fl; fl=&fl[0]->next)
if((*fl)->fid == r->fid) { if(fl[0]->fid == r->fid) {
ft = *fl; ft = fl[0];
*fl = (*fl)->next; fl[0] = fl[0]->next;
f = ft->fid->aux; f = ft->fid->aux;
free(f->p.buf); free(f->p.buf);
free(ft); free(ft);
@ -926,9 +928,9 @@ fs_flush(Ixp9Req *r) {
Ixp9Req **i, **j; Ixp9Req **i, **j;
for(i=&peventread; i != &oeventread; i=&oeventread) for(i=&peventread; i != &oeventread; i=&oeventread)
for(j=i; *j; j=(Ixp9Req**)&(*j)->aux) for(j=i; *j; j=(Ixp9Req**)&j[0]->aux)
if(*j == r->oldreq) { if(*j == r->oldreq) {
*j = (*j)->aux; j[0] = j[0]->aux;
respond(r->oldreq, Einterrupted); respond(r->oldreq, Einterrupted);
goto done; goto done;
} }

View File

@ -2,7 +2,6 @@
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */
#include "dat.h" #include "dat.h"
#include <stdio.h>
#include "fns.h" #include "fns.h"
Bool Bool

View File

@ -2,14 +2,15 @@
* Copyright ©2006-2007 Kris Maglione <fbsdaemon@gmail.com> * Copyright ©2006-2007 Kris Maglione <fbsdaemon@gmail.com>
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */
#define EXTERN
#include "dat.h" #include "dat.h"
#include <X11/Xproto.h> #include <X11/Xproto.h>
#include <X11/cursorfont.h> #include <X11/cursorfont.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <locale.h> #include <locale.h>
#include <pwd.h> #include <pwd.h>
#include <signal.h> #include <signal.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -17,12 +18,14 @@
#include <unistd.h> #include <unistd.h>
#include "fns.h" #include "fns.h"
enum { false, true };
static const char static const char
version[] = "wmii-"VERSION", ©2007 Kris Maglione\n"; version[] = "wmii-"VERSION", ©2007 Kris Maglione\n";
static int (*xlib_errorhandler) (Display*, XErrorEvent*); static int (*xlib_errorhandler) (Display*, XErrorEvent*);
static char *address, *ns_path; static char *address, *ns_path;
static Bool check_other_wm; static int check_other_wm;
static struct sigaction sa; static struct sigaction sa;
static struct passwd *passwd; static struct passwd *passwd;
static int sleeperfd, sock, exitsignal; static int sleeperfd, sock, exitsignal;
@ -88,20 +91,21 @@ ns_display(void) {
static void static void
rmkdir(char *path, int mode) { rmkdir(char *path, int mode) {
char *p, *q; char *p;
int ret; int ret;
char c; char c;
q = path + strlen(ns_path); for(p = path+1; ; p++) {
for(p = &path[1]; p <= q; p++) {
c = *p; c = *p;
if((c == '/') || (c == '\0')) { if((c == '/') || (c == '\0')) {
*p = '\0'; *p = '\0';
ret = mkdir(path, mode); ret = mkdir(path, mode);
if((ret == -1) && (errno != EEXIST)) if((ret == -1) && (errno != EEXIST))
fatal("Can't create ns_path '%s': %r", path); fatal("Can't create path '%s': %r", path);
*p = c; *p = c;
} }
if(c == '\0')
break;
} }
} }
@ -121,7 +125,7 @@ init_ns(void) {
else else
ns_path = ns_display(); ns_path = ns_display();
if((ns_path[0] != '/') || (strlen(ns_path) == 0)) if(ns_path[0] != '/' || ns_path[0] == '\0')
fatal("Bad ns_path"); fatal("Bad ns_path");
rmkdir(ns_path, 0700); rmkdir(ns_path, 0700);
@ -138,10 +142,8 @@ static void
init_environment(void) { init_environment(void) {
init_ns(); init_ns();
if(address == nil) { if(address == nil)
address = emalloc(strlen(ns_path) + strlen("unix!/wmii") + 1); address = smprint("unix!%s/wmii", ns_path);
sprint(address, "unix!%s/wmii", ns_path);
}
setenv("WMII_NS_DIR", ns_path, True); setenv("WMII_NS_DIR", ns_path, True);
setenv("WMII_ADDRESS", address, True); setenv("WMII_ADDRESS", address, True);
@ -195,23 +197,6 @@ init_screen(WMScreen *screen) {
XWindow w; XWindow w;
int ret; int ret;
unsigned mask; unsigned mask;
XGCValues gcv;
gcv.subwindow_mode = IncludeInferiors;
gcv.function = GXxor;
gcv.foreground = def.normcolor.bg;
gcv.plane_mask = AllPlanes;
gcv.graphics_exposures = False;
xor.type = WImage;
xor.image = scr.root.w;
xor.gc = XCreateGC(display, scr.root.w,
GCForeground
| GCGraphicsExposures
| GCFunction
| GCSubwindowMode
| GCPlaneMask,
&gcv);
screen->r = scr.rect; screen->r = scr.rect;
def.snap = Dy(scr.rect) / 63; def.snap = Dy(scr.rect) / 63;
@ -250,9 +235,9 @@ struct {
*/ */
static int static int
errorhandler(Display *dpy, XErrorEvent *error) { errorhandler(Display *dpy, XErrorEvent *error) {
static Bool dead; static int dead;
int i; int i;
USED(dpy); USED(dpy);
if(check_other_wm) if(check_other_wm)
@ -266,7 +251,7 @@ errorhandler(Display *dpy, XErrorEvent *error) {
fprint(2, "%s: fatal error: Xrequest code=%d, Xerror code=%d\n", fprint(2, "%s: fatal error: Xrequest code=%d, Xerror code=%d\n",
argv0, error->request_code, error->error_code); argv0, error->request_code, error->error_code);
/* Try to cleanup, but only try once, in case we're called again */ /* Try to cleanup, but only try once, in case we're called recursively. */
if(!dead++) if(!dead++)
cleanup(); cleanup();
return xlib_errorhandler(display, error); /* calls exit() */ return xlib_errorhandler(display, error); /* calls exit() */
@ -288,47 +273,58 @@ cleanup_handler(int signal) {
} }
} }
static void
closeexec(int fd) {
fcntl(fd, F_SETFL, FD_CLOEXEC);
}
static int
doublefork(void) {
pid_t pid;
int status;
switch(pid=fork()) {
case -1:
fatal("Can't fork(): %r");
case 0:
switch(pid=fork()) {
case -1:
fatal("Can't fork(): %r");
case 0:
return 0;
default:
exit(0);
}
default:
waitpid(pid, &status, 0);
return pid;
}
return -1; /* not reached */
}
static void static void
init_traps(void) { init_traps(void) {
char buf[1]; char buf[1];
pid_t pid; int fd[2];
int fd[2], status;
if(pipe(fd) != 0) if(pipe(fd) != 0)
fatal("Can't pipe(): %r"); fatal("Can't pipe(): %r");
/* Double fork hack */ if(doublefork() == 0) {
switch(pid = fork()) { close(fd[1]);
case -1: close(ConnectionNumber(display));
fatal("Can't fork(): %r"); setsid();
break; /* not reached */
case 0:
switch(fork()) {
case -1:
fatal("Can't fork(): %r");
break; /* not reached */
case 0:
close(fd[1]);
close(ConnectionNumber(display));
setsid();
display = XOpenDisplay(0); display = XOpenDisplay(0);
if(!display) if(!display)
fatal("Can't open display"); fatal("Can't open display");
/* Wait for parent to exit */ /* Wait for parent to exit */
read(fd[0], buf, 1); read(fd[0], buf, 1);
XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime); XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime);
XCloseDisplay(display); XCloseDisplay(display);
exit(0); exit(0);
default:
exit(0);
break;
}
default:
waitpid(pid, &status, 0);
break;
} }
close(fd[0]); close(fd[0]);
@ -340,50 +336,28 @@ init_traps(void) {
sigaction(SIGTERM, &sa, nil); sigaction(SIGTERM, &sa, nil);
sigaction(SIGQUIT, &sa, nil); sigaction(SIGQUIT, &sa, nil);
sigaction(SIGHUP, &sa, nil); sigaction(SIGHUP, &sa, nil);
sigaction(SIGUSR1, &sa, nil);
sigaction(SIGUSR2, &sa, nil);
} }
static void static void
spawn_command(const char *cmd) { spawn_command(const char *cmd) {
char *shell, *p; char *shell, *p;
pid_t pid;
int status;
/* Double fork hack */ if(doublefork() == 0) {
switch(pid = fork()) { if(setsid() == -1)
case -1: fatal("Can't setsid: %r");
fatal("Can't fork: %r");
break; /* Not reached */
case 0:
switch(fork()) {
case -1:
fatal("Can't fork: %r");
break; /* Not reached */
case 0:
if(setsid() == -1)
fatal("Can't setsid: %r");
close(sock);
close(ConnectionNumber(display));
shell = passwd->pw_shell; shell = passwd->pw_shell;
if(shell[0] != '/') if(shell[0] != '/')
fatal("Shell is not an absolute path: %s", shell); fatal("Shell is not an absolute path: %s", shell);
/* Run through the user's shell as a login shell */ /* Run through the user's shell as a login shell */
p = malloc((strlen(shell) + 2)); p = smprint("-%s", strrchr(shell, '/') + 1);
sprint(p, "-%s", strrchr(shell, '/') + 1);
execl(shell, p, "-c", cmd, nil); execl(shell, p, "-c", cmd, nil);
fatal("Can't exec '%s': %r", cmd); fatal("Can't exec '%s': %r", cmd);
break; /* Not reached */ /* Not reached */
default:
exit(0);
break; /* Not reached */
}
default:
waitpid(pid, &status, 0);
/* if(status != 0)
exit(1); */
break;
} }
} }
@ -418,7 +392,7 @@ main(int argc, char *argv[]) {
print("%s", version); print("%s", version);
exit(0); exit(0);
case 'V': case 'V':
verbose = True; verbose = true;
break; break;
case 'a': case 'a':
address = EARGF(usage()); address = EARGF(usage());
@ -438,16 +412,17 @@ main(int argc, char *argv[]) {
starting = True; starting = True;
initdisplay(); initdisplay();
closeexec(ConnectionNumber(display));
xlib_errorhandler = XSetErrorHandler(errorhandler); xlib_errorhandler = XSetErrorHandler(errorhandler);
check_other_wm = True; check_other_wm = true;
XSelectInput(display, scr.root.w, XSelectInput(display, scr.root.w,
SubstructureRedirectMask SubstructureRedirectMask
| EnterWindowMask); | EnterWindowMask);
XSync(display, False); XSync(display, False);
check_other_wm = False; check_other_wm = false;
passwd = getpwuid(getuid()); passwd = getpwuid(getuid());
user = estrdup(passwd->pw_name); user = estrdup(passwd->pw_name);
@ -457,6 +432,7 @@ main(int argc, char *argv[]) {
sock = ixp_announce(address); sock = ixp_announce(address);
if(sock < 0) if(sock < 0)
fatal("Can't create socket '%s': %r", address); fatal("Can't create socket '%s': %r", address);
closeexec(sock);
if(wmiirc) if(wmiirc)
spawn_command(wmiirc); spawn_command(wmiirc);
@ -506,13 +482,12 @@ main(int argc, char *argv[]) {
setfocus(screen->barwin, RevertToParent); setfocus(screen->barwin, RevertToParent);
scan_wins(); scan_wins();
starting = False; starting = false;
select_view("nil"); select_view("nil");
update_views(); update_views();
write_event("FocusTag %s\n", screen->sel->name); write_event("FocusTag %s\n", screen->sel->name);
check_x_event(nil);
i = ixp_serverloop(&srv); i = ixp_serverloop(&srv);
if(i) if(i)
fprint(2, "%s: error: %r\n", argv0); fprint(2, "%s: error: %r\n", argv0);

View File

@ -4,7 +4,6 @@
#include "dat.h" #include "dat.h"
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "fns.h" #include "fns.h"
@ -119,7 +118,7 @@ eatrunes(IxpMsg *m, int (*p)(Rune), int val) {
int n; int n;
while(m->pos < m->end) { while(m->pos < m->end) {
n = chartorune(&r, (char*)m->pos); n = chartorune(&r, m->pos);
if(p(r) != val) if(p(r) != val)
break; break;
m->pos += n; m->pos += n;
@ -135,14 +134,14 @@ getword(IxpMsg *m) {
int n; int n;
eatrunes(m, isspacerune, 1); eatrunes(m, isspacerune, 1);
ret = (char*)m->pos; ret = m->pos;
eatrunes(m, isspacerune, 0); eatrunes(m, isspacerune, 0);
n = chartorune(&r, (char*)m->pos); n = chartorune(&r, m->pos);
*m->pos = '\0'; *m->pos = '\0';
m->pos += n; m->pos += n;
eatrunes(m, isspacerune, 1); eatrunes(m, isspacerune, 1);
if(ret == (char*)m->end) if(ret == m->end)
return nil; return nil;
return ret; return ret;
} }
@ -165,7 +164,7 @@ getbase(char **s) {
*s += 3; *s += 3;
return 10*(p[0]-'0') + (p[1]-'0'); return 10*(p[0]-'0') + (p[1]-'0');
} }
if(!strbcmp(p, "0")) { if(p[0] == '0') {
*s += 1; *s += 1;
return 8; return 8;
} }
@ -220,10 +219,10 @@ strarea(View *v, char *s) {
if(!getlong(s, &i) || i == 0) if(!getlong(s, &i) || i == 0)
return nil; return nil;
if(i > 0) if(i > 0) {
for(a = v->area; a; a = a->next) { for(a = v->area; a; a = a->next)
if(i-- == 0) break; if(i-- == 0) break;
} }
else { else {
for(a = v->area; a->next; a = a->next) for(a = v->area; a->next; a = a->next)
; ;
@ -252,11 +251,13 @@ message_view(View *v, IxpMsg *m) {
return select_area(v->sel, m); return select_area(v->sel, m);
case LCOLMODE: case LCOLMODE:
s = getword(m); s = getword(m);
if((a = strarea(v, s)) == nil || a->floating) a = strarea(v, s);
if(a == nil || a->floating)
return Ebadvalue; return Ebadvalue;
s = getword(m); s = getword(m);
if((i = str2colmode(s)) == -1) i = str2colmode(s);
if(i == -1)
return Ebadvalue; return Ebadvalue;
a->mode = i; a->mode = i;
@ -281,12 +282,12 @@ parse_colors(IxpMsg *m, CTuple *col) {
int i, j; int i, j;
/* '#%6x #%6x #%6x' */ /* '#%6x #%6x #%6x' */
p = (char*)m->pos; p = m->pos;
for(i = 0; i < 3 && p < (char*)m->end; i++) { for(i = 0; i < 3 && p < m->end; i++) {
if(*p++ != '#') if(*p++ != '#')
return Ebad; return Ebad;
for(j = 0; j < 6 && p < (char*)m->end; j++) for(j = 0; j < 6; j++)
if(!isxdigit(*p++)) if(p >= m->end || !isxdigit(*p++))
return Ebad; return Ebad;
chartorune(&r, p); chartorune(&r, p);
@ -294,16 +295,16 @@ parse_colors(IxpMsg *m, CTuple *col) {
if(r != ' ') if(r != ' ')
return Ebad; return Ebad;
p++; p++;
}else if(!isspacerune(r) && *p != '\0') }else if(*p != '\0' && !isspacerune(r))
return Ebad; return Ebad;
} }
c = *p; c = *p;
*p = '\0'; *p = '\0';
loadcolor(col, (char*)m->pos); loadcolor(col, m->pos);
*p = c; *p = c;
m->pos = (uchar*)p; m->pos = p;
eatrunes(m, isspacerune, 1); eatrunes(m, isspacerune, 1);
return nil; return nil;
} }
@ -323,11 +324,11 @@ message_root(void *p, IxpMsg *m) {
srv.running = 0; srv.running = 0;
break; break;
case LEXEC: case LEXEC:
execstr = smprint("exec %s", (char*)m->pos); execstr = smprint("exec %s", m->pos);
srv.running = 0; srv.running = 0;
break; break;
case LVIEW: case LVIEW:
select_view((char*)m->pos); select_view(m->pos);
break; break;
case LSELCOLORS: case LSELCOLORS:
fprint(2, "%s: warning: selcolors have been removed\n", argv0); fprint(2, "%s: warning: selcolors have been removed\n", argv0);
@ -341,7 +342,7 @@ message_root(void *p, IxpMsg *m) {
focus_view(screen, screen->sel); focus_view(screen, screen->sel);
break; break;
case LFONT: case LFONT:
fn = loadfont((char*)m->pos); fn = loadfont(m->pos);
if(fn) { if(fn) {
freefont(def.font); freefont(def.font);
def.font = fn; def.font = fn;

View File

@ -4,7 +4,6 @@
#include "dat.h" #include "dat.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include "fns.h" #include "fns.h"
@ -289,14 +288,9 @@ horiz:
resize_frame(f->aprev, f->aprev->r); resize_frame(f->aprev, f->aprev->r);
} }
if (f->aprev || f->anext) { remove_frame(f);
remove_frame(f); f->area = fw->ra;
f->area = fw->ra; insert_frame(fw->fp, f);
insert_frame(fw->fp, f);
} else if (f->area != fw->ra) {
detach_from_area(f);
attach_to_area(fw->ra, f);
}
if(f->aprev) { if(f->aprev) {
f->aprev->r.max.y = fw->fr.min.y; f->aprev->r.max.y = fw->fr.min.y;
@ -750,6 +744,8 @@ do_mouse_resize(Client *c, Bool opaque, Align align) {
d.y = ev.xmotion.y_root; d.y = ev.xmotion.y_root;
if(align == CENTER && !opaque) { if(align == CENTER && !opaque) {
SET(hrx);
SET(hry);
d.x = (d.x * hrx) - pt.x; d.x = (d.x * hrx) - pt.x;
d.y = (d.y * hry) - pt.y; d.y = (d.y * hry) - pt.y;
}else }else
@ -766,10 +762,10 @@ do_mouse_resize(Client *c, Bool opaque, Align align) {
frect = constrain(frect); frect = constrain(frect);
//reshapewin(c->framewin, frect); //reshapewin(c->framewin, frect);
resize_client(c, &frect); resize_client(c, frect);
break; break;
case ButtonRelease: case ButtonRelease:
resize_client(c, &frect); resize_client(c, frect);
if(!opaque) { if(!opaque) {
pt = translate(c->framewin, &scr.root, pt = translate(c->framewin, &scr.root,

View File

@ -41,7 +41,6 @@
#include "dat.h" #include "dat.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <bio.h> #include <bio.h>
@ -96,13 +95,13 @@ unmask(Pair * list, uint val)
static char * static char *
strhex(int key) { strhex(int key) {
sprintf(buffer, "0x%x", key); sprint(buffer, "0x%x", key);
return buffer; return buffer;
} }
static char * static char *
strdec(int key) { strdec(int key) {
sprintf(buffer, "%d", key); sprint(buffer, "%d", key);
return buffer; return buffer;
} }
@ -656,14 +655,13 @@ VerbFocus(XEvent *e) {
static void static void
VerbKeymap(XEvent *e) { VerbKeymap(XEvent *e) {
XKeymapEvent *ev = &e->xkeymap; XKeymapEvent *ev = &e->xkeymap;
int i;
int i; fprint(2, "window=0x%x%s", (int)ev->window, sep);
fprint(2, "key_vector=");
fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
fprintf(stderr, "key_vector=");
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
fprintf(stderr, "%02x", ev->key_vector[i]); fprint(2, "%02x", ev->key_vector[i]);
fprintf(stderr, "\n"); fprint(2, "\n");
} }
static void static void
@ -935,7 +933,6 @@ VerbVisibility(XEvent *e) {
/******************************************************************************/ /******************************************************************************/
typedef struct Handler Handler; typedef struct Handler Handler;
struct Handler { struct Handler {
int key; int key;
void (*fn)(XEvent*); void (*fn)(XEvent*);
@ -945,9 +942,9 @@ void
printevent(XEvent *e) { printevent(XEvent *e) {
XAnyEvent *ev = &e->xany; XAnyEvent *ev = &e->xany;
fprintf(stderr, "%3ld %-20s ", ev->serial, eventtype(e->xany.type)); fprint(2, "%3ld %-20s ", ev->serial, eventtype(e->xany.type));
if(ev->send_event) if(ev->send_event)
fprintf(stderr, "(sendevent) "); fprint(2, "(sendevent) ");
/* /*
fprintf(stderr, "type=%s%s", eventtype(e->xany.type), sep); fprintf(stderr, "type=%s%s", eventtype(e->xany.type), sep);
fprintf(stderr, "serial=%lu%s", ev->serial, sep); fprintf(stderr, "serial=%lu%s", ev->serial, sep);

View File

@ -20,14 +20,15 @@ enum {
void void
trim(char *str, const char *chars) { trim(char *str, const char *chars) {
const char *cp; const char *cp;
char *sp, *sn; char *p, *q;
char c;
for(cp = chars; *cp; cp++) { for(cp = chars; (c = *cp); cp++) {
for(sp = sn = str; *sn; sn++) { q = str;
if(*sn != *cp) for(p = q; *p; p++)
*(sp++) = *sn; if(*p != c)
} *q++ = *p;
*sp = 0; *q = '\0';
} }
} }

View File

@ -4,7 +4,6 @@
*/ */
#include "dat.h" #include "dat.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include "fns.h" #include "fns.h"
@ -134,7 +133,7 @@ focus_view(WMScreen *s, View *v) {
for(c=client; c; c=c->next) for(c=client; c; c=c->next)
if((f = c->sel)) { if((f = c->sel)) {
if(f->view == v) if(f->view == v)
resize_client(c, &f->r); resize_client(c, f->r);
else { else {
unmap_frame(c); unmap_frame(c);
unmap_client(c, IconicState); unmap_client(c, IconicState);
@ -188,15 +187,15 @@ restack_view(View *v) {
Frame *f; Frame *f;
Client *c; Client *c;
Area *a; Area *a;
uint n, i; uint n, i, fscrn;
if(v != screen->sel) if(v != screen->sel)
return; return;
i = 0; i = 1;
for(c = client; c; c = c->next) for(c = client; c; c = c->next)
i++; i++;
if(i == 0) if(i == 1)
return; return;
for(a = v->area; a; a = a->next) for(a = v->area; a; a = a->next)
@ -208,16 +207,21 @@ restack_view(View *v) {
} }
n = 0; n = 0;
fscrn = 0;
wins[n++] = screen->barwin->w; wins[n++] = screen->barwin->w;
for(f = v->area->frame; f; f = f->anext) for(f=v->area->frame; f; f=f->anext)
if(f->client->fullscreen) { if(f->client->fullscreen) {
n--; n--;
fscrn++;
break; break;
} }
for(f=v->area->stack; f; f=f->snext) for(f=v->area->stack; f; f=f->snext)
wins[n++] = f->client->framewin->w; wins[n++] = f->client->framewin->w;
if(fscrn)
wins[n++] = screen->barwin->w;
for(d = divs; d && d->w->mapped; d = d->next) for(d = divs; d && d->w->mapped; d = d->next)
wins[n++] = d->w->w; wins[n++] = d->w->w;
@ -228,10 +232,8 @@ restack_view(View *v) {
if(f != a->sel) if(f != a->sel)
wins[n++] = f->client->framewin->w; wins[n++] = f->client->framewin->w;
} }
if(n) { if(n)
XRaiseWindow(display, wins[0]);
XRestackWindows(display, wins, n); XRestackWindows(display, wins, n);
}
} }
void void
@ -269,10 +271,10 @@ scale_view(View *v, int w) {
if(numcol * minwidth > w) if(numcol * minwidth > w)
return; return;
dx = numcol * minwidth;
xoff = 0; xoff = 0;
for(a=v->area->next, numcol--; a; a=a->next, numcol--) { for(a=v->area->next, numcol--; a; a=a->next, numcol--) {
a->r.min.x = xoff; a->r.min.x = xoff;
dx = numcol * minwidth;
if(Dx(a->r) < minwidth) if(Dx(a->r) < minwidth)
a->r.max.x = xoff + minwidth; a->r.max.x = xoff + minwidth;
@ -328,14 +330,13 @@ rects_of_view(View *v, uint *num, Frame *ignore) {
return result; return result;
} }
/* XXX: This will need cleanup */
uchar * uchar *
view_index(View *v) { view_index(View *v) {
Rectangle *r; Rectangle *r;
Frame *f; Frame *f;
Area *a; Area *a;
char *buf, *end; char *buf, *end;
uint i; int i;
buf = buffer; buf = buffer;
end = buffer+sizeof(buffer)-1; end = buffer+sizeof(buffer)-1;
@ -396,20 +397,20 @@ view_ctl(View *v) {
void void
update_views(void) { update_views(void) {
View *n, *v, *old; View *n, *v, *old;
Bool found; int found;
old = screen->sel; old = screen->sel;
for(v=view; v; v=v->next) for(v=view; v; v=v->next)
update_frame_selectors(v); update_frame_selectors(v);
found = False; found = 0;
for(v=view; v; v=n) { for(v=view; v; v=n) {
n=v->next; n=v->next;
if(v != old) { if(v != old) {
if(is_empty(v)) if(is_empty(v))
destroy_view(v); destroy_view(v);
else else
found = True; found++;
} }
} }

View File

@ -1,11 +1,11 @@
/* Copyright ©2007 Kris Maglione <fbsdaemon@gmail.com> /* Copyright ©2007 Kris Maglione <fbsdaemon@gmail.com>
* See LICENSE file for license details. * See LICENSE file for license details.
*/ */
#define _X11_VISIBLE
#include "dat.h" #include "dat.h"
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <bio.h> #include <bio.h>
@ -122,8 +122,7 @@ Wfmt(Fmt *f) {
/* Init */ /* Init */
void void
initdisplay(void) { initdisplay(void) {
if(!(display = XOpenDisplay(nil))) display = XOpenDisplay(nil);
fatal("couldn't open display");
scr.screen = DefaultScreen(display); scr.screen = DefaultScreen(display);
scr.colormap = DefaultColormap(display, scr.screen); scr.colormap = DefaultColormap(display, scr.screen);
scr.visual = DefaultVisual(display, scr.screen); scr.visual = DefaultVisual(display, scr.screen);
@ -627,6 +626,27 @@ getproperty(Window *w, char *prop, char *type, Atom *actual, ulong offset, uchar
return n; return n;
} }
char**
strlistdup(char *list[], int n) {
char **p, *q;
int i, m;
for(i=0, m=0; i < n; i++)
m += strlen(list[i])+1;
p = malloc((n+1)*sizeof(char*) + m);
q = (char*)&p[n+1];
for(i=0; i < n; i++) {
p[i] = q;
m = strlen(list[i])+1;
memcpy(q, list[i], m);
q += m;
}
p[n] = nil;
return p;
}
int int
gettextlistproperty(Window *w, char *name, char **ret[]) { gettextlistproperty(Window *w, char *name, char **ret[]) {
XTextProperty prop; XTextProperty prop;
@ -662,11 +682,7 @@ gettextproperty(Window *w, char *name) {
void void
setfocus(Window *w, int mode) { setfocus(Window *w, int mode) {
if(w) { XSetInputFocus(display, w->w, mode, CurrentTime);
XSetInputFocus(display, w->w, mode, CurrentTime);
} else { /* "relinquish" focus */
XSetInputFocus(display, PointerRoot, mode, CurrentTime);
}
} }
/* Mouse */ /* Mouse */

View File

@ -3,8 +3,10 @@
#define Screen XScreen #define Screen XScreen
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/Xatom.h> #ifdef _X11_VISIBLE
#include <X11/extensions/shape.h> # include <X11/Xatom.h>
# include <X11/extensions/shape.h>
#endif
#undef Window #undef Window
#undef Font #undef Font
#undef Screen #undef Screen

View File

@ -1,7 +1,7 @@
#!/bin/sh -f #!/bin/sh -f
RC="" RC=""
IFS=: IFS=:
for i in "$PLAN9" `echo "P9PATHS"`; do for i in "$PLAN9" `echo P9PATHS`; do
if [ -d "$i" -a -x "$i/bin/rc" ]; then if [ -d "$i" -a -x "$i/bin/rc" ]; then
export PLAN9="$i" export PLAN9="$i"
RC="$i/bin/rc" RC="$i/bin/rc"
@ -9,10 +9,14 @@ for i in "$PLAN9" `echo "P9PATHS"`; do
fi fi
done done
if [ ! -n "$RC" ]; then if [ -n "$RC" ]; then
exit 1 exit 1
fi fi
if [ ! -x "$PLAN9/bin/read" ]; then
echo 1>&2 $0: Found rc, but not read'(1)'. You probably have an out-of-date 9base installed.
fi
if [ -n "$1" ]; then if [ -n "$1" ]; then
exec "$RC" "$@" exec "$RC" "$@"
else else

View File

@ -17,9 +17,9 @@ static IxpClient *client;
static void static void
usage(void) { usage(void) {
fprint(1, fprint(1,
"usage: %1$s [-a <address>] {create | read | ls [-ld] | remove | rm | write} <file>\n" "usage: %s [-a <address>] {create | read | ls [-ld] | remove | rm | write} <file>\n"
" %1$s [-a <address>] xwrite <file> <data>\n" " %s [-a <address>] xwrite <file> <data>\n"
" %1$s -v\n", argv0); " %s -v\n", argv0, argv0, argv0);
exit(1); exit(1);
} }
@ -185,6 +185,7 @@ xcreate(int argc, char *argv[]) {
static int static int
xremove(int argc, char *argv[]) { xremove(int argc, char *argv[]) {
char *file; char *file;
int n;
ARGBEGIN{ ARGBEGIN{
default: default:
@ -192,8 +193,12 @@ xremove(int argc, char *argv[]) {
}ARGEND; }ARGEND;
file = EARGF(usage()); file = EARGF(usage());
if(ixp_remove(client, file) == 0) do {
fatal("Can't remove file '%s': %r\n", file); if(ixp_remove(client, file) == 0) {
fprint(2, "%s: Can't remove file '%s': %r\n", argv0, file);
n++;
}
}while((file = ARGF()));
return 0; return 0;
} }
@ -208,18 +213,22 @@ xread(int argc, char *argv[]) {
usage(); usage();
}ARGEND; }ARGEND;
if(argc == 0)
usage();
file = EARGF(usage()); file = EARGF(usage());
fid = ixp_open(client, file, P9_OREAD); do {
if(fid == nil) fid = ixp_open(client, file, P9_OREAD);
fatal("Can't open file '%s': %r\n", file); if(fid == nil)
fatal("Can't open file '%s': %r\n", file);
buf = emalloc(fid->iounit); buf = emalloc(fid->iounit);
while((count = ixp_read(fid, buf, fid->iounit)) > 0) while((count = ixp_read(fid, buf, fid->iounit)) > 0)
write(1, buf, count); write(1, buf, count);
ixp_close(fid); ixp_close(fid);
if(count == -1) if(count == -1)
fatal("cannot read file/directory '%s': %r\n", file); fprint(2, "%s: cannot read file/directory '%s': %r\n", argv0, file);
}while((file = ARGF()));
return 0; return 0;
} }
@ -299,6 +308,7 @@ struct exectab {
{"write", xwrite}, {"write", xwrite},
{"xwrite", xawrite}, {"xwrite", xawrite},
{"read", xread}, {"read", xread},
{"cat", xread},
{"create", xcreate}, {"create", xcreate},
{"remove", xremove}, {"remove", xremove},
{"rm", xremove}, {"rm", xremove},
@ -308,7 +318,7 @@ struct exectab {
int int
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
char *cmd, *address; char *address;
exectab *tab; exectab *tab;
int ret; int ret;
@ -327,8 +337,6 @@ main(int argc, char *argv[]) {
usage(); usage();
}ARGEND; }ARGEND;
cmd = EARGF(usage());
if(!address) if(!address)
fatal("$WMII_ADDRESS not set\n"); fatal("$WMII_ADDRESS not set\n");
@ -337,7 +345,7 @@ main(int argc, char *argv[]) {
fatal("can't mount: %r\n"); fatal("can't mount: %r\n");
for(tab = etab; tab->cmd; tab++) for(tab = etab; tab->cmd; tab++)
if(strcmp(cmd, tab->cmd) == 0) break; if(strcmp(*argv, tab->cmd) == 0) break;
if(tab->cmd == 0) if(tab->cmd == 0)
usage(); usage();

View File

@ -1,7 +1,12 @@
#!/bin/sh -f #!/bin/sh -f
# start wmiirc # start wmiirc
export WMII_CONFPATH="$HOME/.wmii-CONFVERSION:CONFPREFIX/wmii-CONFVERSION" export home="$HOME"
lconf="$home/.wmii-CONFVERSION"
gconf="CONFPREFIX/.wmii-CONFVERSION"
export WMII_CONFPATH="$conf:$gconf"
export POSIXLY_CORRECT=gnu_hippies
if wmii9rc; then if wmii9rc; then
WMIIRC=`PATH="$WMII_CONFPATH:$PATH" which rc.wmii` WMIIRC=`PATH="$WMII_CONFPATH:$PATH" which rc.wmii`
@ -9,5 +14,6 @@ else
WMIIRC=`PATH="$WMII_CONFPATH:$PATH" which wmiirc` WMIIRC=`PATH="$WMII_CONFPATH:$PATH" which wmiirc`
fi fi
mkdir $HOME/.wmii-CONFVERSION 2>/dev/null && CONFPREFIX/wmii-CONFVERSION/welcome & mkdir $conf 2>/dev/null && $gconf/welcome &
exec "$WMIIRC" $@ exec "$WMIIRC" "$@"

View File

@ -9,9 +9,10 @@ iconscale = `{*=$epsbox; hoc -e $iconwidth/'('$3-' '$1')'}
iconheight = `{*=$epsbox; hoc -e '('$4-' '$2')*'$iconscale} iconheight = `{*=$epsbox; hoc -e '('$4-' '$2')*'$iconscale}
icon.png: $eps icon.png: $eps
x = `{hoc -e -'('$epsbox(1)^')'} * = `{hoc -e'-('$epsbox')'}
y = `{hoc -e -'('$epsbox(2)^')'} x = $1
gs -q -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=$target -g^$iconwidth^x^$iconheight - <<! y = $2
gs -q -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=$target -g$iconwidth'x'$iconheight - <<!
$iconscale $iconscale scale $iconscale $iconscale scale
$x $y translate $x $y translate
($eps) run ($eps) run

View File

@ -108,41 +108,41 @@ extern int (*fmtdoquote)(int);
#endif #endif
/* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/fmt/?*.c | grep -v static |grep -v __ */ /* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/fmt/?*.c | grep -v static |grep -v __ */
int dofmt(Fmt *f, const char *fmt); int dofmt(Fmt*, const char *fmt);
int dorfmt(Fmt *f, const Rune *fmt); int dorfmt(Fmt*, const Rune *fmt);
double fmtcharstod(int(*f)(void*), void *vp); double fmtcharstod(int(*f)(void*), void*);
int fmtfdflush(Fmt *f); int fmtfdflush(Fmt*);
int fmtfdinit(Fmt *f, int fd, char *buf, int size); int fmtfdinit(Fmt*, int fd, char *buf, int size);
int fmtinstall(int c, int (*f)(Fmt*)); int fmtinstall(int, int (*f)(Fmt*));
int fmtprint(Fmt *f, const char *fmt, ...); int fmtprint(Fmt*, const char*, ...);
int fmtrune(Fmt *f, int r); int fmtrune(Fmt*, int);
int fmtrunestrcpy(Fmt *f, Rune *s); int fmtrunestrcpy(Fmt*, Rune*);
int fmtstrcpy(Fmt *f, const char *s); int fmtstrcpy(Fmt*, const char*);
char* fmtstrflush(Fmt *f); char* fmtstrflush(Fmt*);
int fmtstrinit(Fmt *f); int fmtstrinit(Fmt*);
double fmtstrtod(const char *as, char **aas); double fmtstrtod(const char*, char**);
int fmtvprint(Fmt *f, const char *fmt, va_list args); int fmtvprint(Fmt*, const char*, va_list);
int fprint(int fd, const char *fmt, ...); int fprint(int, const char*, ...);
int print(const char *fmt, ...); int print(const char*, ...);
void quotefmtinstall(void); void quotefmtinstall(void);
int quoterunestrfmt(Fmt *f); int quoterunestrfmt(Fmt*);
int quotestrfmt(Fmt *f); int quotestrfmt(Fmt*);
Rune* runefmtstrflush(Fmt *f); Rune* runefmtstrflush(Fmt*);
int runefmtstrinit(Fmt *f); int runefmtstrinit(Fmt*);
Rune* runeseprint(Rune *buf, Rune *e, const char *fmt, ...); Rune* runeseprint(Rune*,Rune*, const char*, ...);
Rune* runesmprint(const char *fmt, ...); Rune* runesmprint(const char*, ...);
int runesnprint(Rune *buf, int len, const char *fmt, ...); int runesnprint(Rune*, int, const char*, ...);
int runesprint(Rune *buf, const char *fmt, ...); int runesprint(Rune*, const char*, ...);
Rune* runevseprint(Rune *buf, Rune *e, const char *fmt, va_list args); Rune* runevseprint(Rune*, Rune *, const char*, va_list);
Rune* runevsmprint(const char *fmt, va_list args); Rune* runevsmprint(const char*, va_list);
int runevsnprint(Rune *buf, int len, const char *fmt, va_list args); int runevsnprint(Rune*, int, const char*, va_list);
char* seprint(char *buf, char *e, const char *fmt, ...); char* seprint(char*, char*, const char*, ...);
char* smprint(const char *fmt, ...); char* smprint(const char*, ...);
int snprint(char *buf, int len, const char *fmt, ...); int snprint(char*, int, const char *, ...);
int sprint(char *buf, const char *fmt, ...); int sprint(char*, const char*, ...);
int vfprint(int fd, const char *fmt, va_list args); int vfprint(int, const char*, va_list);
char* vseprint(char *buf, char *e, const char *fmt, va_list args); char* vseprint(char*, char*, const char*, va_list);
char* vsmprint(const char *fmt, va_list args); char* vsmprint(const char*, va_list);
int vsnprint(char *buf, int len, const char *fmt, va_list args); int vsnprint(char*, int, const char*, va_list);
#endif #endif

View File

@ -9,11 +9,12 @@
# ifndef USED # ifndef USED
# define USED(x) if(x);else # define USED(x) if(x);else
# endif # endif
# define uchar _p9uchar
# define ushort _p9ushort
# define uint _p9uint
# define ulong _p9ulong
#endif #endif
#define uchar _p9uchar
#define ushort _p9ushort
#define uint _p9uint
#define ulong _p9ulong
typedef unsigned char uchar; typedef unsigned char uchar;
typedef unsigned short ushort; typedef unsigned short ushort;
typedef unsigned int uint; typedef unsigned int uint;

View File

@ -16,13 +16,11 @@ typedef struct Reprog Reprog;
* Sub expression matches * Sub expression matches
*/ */
struct Resub{ struct Resub{
union union {
{
char *sp; char *sp;
Rune *rsp; Rune *rsp;
}s; }s;
union union {
{
char *ep; char *ep;
Rune *rep; Rune *rep;
}e; }e;

View File

@ -14,34 +14,34 @@ enum
/* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/utf/?*.c | grep -v static |grep -v __ */ /* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/utf/?*.c | grep -v static |grep -v __ */
int chartorune(Rune *rune, const char *str); int chartorune(Rune *rune, const char *str);
int fullrune(const char *str, int n); int fullrune(const char *str, int n);
int isalpharune(Rune c); int isalpharune(Rune);
int islowerrune(Rune c); int islowerrune(Rune);
int isspacerune(Rune c); int isspacerune(Rune);
int istitlerune(Rune c); int istitlerune(Rune);
int isupperrune(Rune c); int isupperrune(Rune);
int runelen(long c); int runelen(Rune);
int runenlen(Rune *r, int nrune); int runenlen(const Rune*, int);
Rune* runestrcat(Rune *s1, Rune *s2); Rune* runestrcat(Rune*, const Rune*);
Rune* runestrchr(Rune *s, Rune c); Rune* runestrchr(const Rune*, Rune);
int runestrcmp(Rune *s1, Rune *s2); int runestrcmp(const Rune*, const Rune*);
Rune* runestrcpy(Rune *s1, Rune *s2); Rune* runestrcpy(Rune*, const Rune*);
Rune* runestrdup(Rune *s) ; Rune* runestrdup(const Rune*) ;
Rune* runestrecpy(Rune *s1, Rune *es1, Rune *s2); Rune* runestrecpy(Rune*, Rune *e, const Rune*);
long runestrlen(Rune *s); long runestrlen(const Rune*);
Rune* runestrncat(Rune *s1, Rune *s2, long n); Rune* runestrncat(Rune*, const Rune*, long);
int runestrncmp(Rune *s1, Rune *s2, long n); int runestrncmp(const Rune*, const Rune*, long);
Rune* runestrncpy(Rune *s1, Rune *s2, long n); Rune* runestrncpy(Rune*, const Rune*, long);
Rune* runestrrchr(Rune *s, Rune c); Rune* runestrrchr(const Rune*, Rune);
Rune* runestrstr(Rune *s1, Rune *s2); Rune* runestrstr(const Rune*, const Rune*);
int runetochar(char *str, Rune *rune); int runetochar(char*, const Rune*);
Rune tolowerrune(Rune c); Rune tolowerrune(Rune);
Rune totitlerune(Rune c); Rune totitlerune(Rune);
Rune toupperrune(Rune c); Rune toupperrune(Rune);
char* utfecpy(char *to, char *e, const char *from); char* utfecpy(char*, char*, const char*);
int utflen(const char *s); int utflen(const char*);
int utfnlen(const char *s, long m); int utfnlen(const char*, long);
char* utfrrune(const char *s, long c); char* utfrrune(const char*, long);
char* utfrune(const char *s, long c); char* utfrune(const char*, long);
char* utfutf(const char *s1, const char *s2); char* utfutf(const char*, const char*);
#endif #endif

View File

@ -8,63 +8,65 @@
#undef ulong #undef ulong
#undef uvlong #undef uvlong
#undef vlong #undef vlong
#ifndef KENC #define uchar _x_uchar
# define uchar _wmiiuchar #define ushort _x_ushort
# define ushort _wmiiushort #define uint _x_uint
# define uint _wmiiuint #define ulong _x_ulong
# define ulong _wmiiulong #define uvlong _x_uvlong
# define vlong _wmiivlong #define vlong _x_vlong
# define uvlong _wmiiuvlong
#endif
typedef unsigned char uchar; typedef unsigned char uchar;
typedef unsigned short ushort; typedef unsigned short ushort;
typedef unsigned int uint; typedef unsigned int uint;
typedef unsigned long ulong; typedef unsigned long ulong;
typedef unsigned long long uvlong; typedef unsigned long long uvlong;
typedef long long vlong;
typedef long long vlong;
#define strlcat wmii_strlcat #define strlcat wmii_strlcat
/* util.c */ /* util.c */
uint tokenize(char *res[], uint reslen, char *str, char delim); void* emalloc(uint);
char *estrdup(const char *str); void* emallocz(uint);
void *erealloc(void *ptr, uint size); void* erealloc(void*, uint);
void *emallocz(uint size); char* estrdup(const char*);
void *emalloc(uint size); void fatal(const char*, ...);
void fatal(const char *fmt, ...); int max(int, int);
int max(int a, int b); int min(int, int);
int min(int a, int b); char* str_nil(char*);
char *str_nil(char *s); uint strlcat(char*, const char*, uint);
int utflcpy(char *to, const char *from, int l); uint tokenize(char **, uint, char*, char);
uint strlcat(char *dst, const char *src, unsigned int siz); int utflcpy(char*, const char*, int);
char *argv0; char *argv0;
void *__p;
int __i;
#undef ARGBEGIN #undef ARGBEGIN
#undef ARGEND #undef ARGEND
#undef ARGF #undef ARGF
#undef EARGF #undef EARGF
#define ARGBEGIN \ #define ARGBEGIN \
int _argi=0, _argtmp=0, _inargv=0; char *_argv=nil; \ int _argtmp=0, _inargv=0; char *_argv=nil; \
if(!argv0) argv0=ARGF(); \ if(!argv0) argv0=*argv; argv++, argc--; \
_inargv=1; USED(_inargv); \ _inargv=1; USED(_inargv); \
while(argc && argv[0][0] == '-') { \ while(argc && argv[0][0] == '-') { \
_argi=1; _argv=*argv++; argc--; \ _argv=&argv[0][1]; argv++; argc--; \
while(_argv[_argi]) switch(_argv[_argi++]) if(_argv[0] == '-' && _argv[1] == '\0') \
#define ARGEND }_inargv=0;USED(_argtmp);USED(_argv);USED(_argi);USED(_inargv) break; \
while(*_argv) switch(*_argv++)
#define ARGEND }_inargv=0;USED(_argtmp, _argv, _inargv)
#define ARGF() ((_inargv && _argv[_argi]) ? \ #define EARGF(f) ((_inargv && *_argv) ? \
(_argtmp=_argi, _argi=strlen(_argv), __i=_argi,_argv+_argtmp) \ (_argtmp=strlen(_argv), _argv+=_argtmp, _argv-_argtmp) \
: ((argc > 0) ? (--argc, ++argv, __i=argc, __p=argv, *(argv-1)) : ((char*)0))) : ((argc > 0) ? \
(--argc, ++argv, _used(argc), *(argv-1)) \
#define EARGF(f) ((_inargv && _argv[_argi]) ? \ : ((f), (char*)0)))
(_argtmp=_argi, _argi=strlen(_argv), __i=_argi, _argv+_argtmp) \ #define ARGF() EARGF(_used(0))
: ((argc > 0) ? (--argc, ++argv, __i=argc, __p=argv, *(argv-1)) : ((f), (char*)0)))
static inline void
_used(long a, ...) {
if(a){}
}
#ifndef KENC #ifndef KENC
# undef USED # undef USED
# undef SET # undef SET
# define USED(x) if(x){}else # define USED(...) _used((long)__VA_ARGS__)
# define SET(x) ((x)=0) # define SET(x) USED(&x)
#endif #endif

View File

@ -97,7 +97,7 @@ bad:
} }
int int
runetochar(char *str, Rune *rune) runetochar(char *str, const Rune *rune)
{ {
long c; long c;
@ -132,17 +132,15 @@ runetochar(char *str, Rune *rune)
} }
int int
runelen(long c) runelen(Rune c)
{ {
Rune rune;
char str[10]; char str[10];
rune = c; return runetochar(str, &c);
return runetochar(str, &rune);
} }
int int
runenlen(Rune *r, int nrune) runenlen(const Rune *r, int nrune)
{ {
int nb, c; int nb, c;

View File

@ -16,7 +16,7 @@
#include <plan9.h> #include <plan9.h>
Rune* Rune*
runestrcat(Rune *s1, Rune *s2) runestrcat(Rune *s1, const Rune *s2)
{ {
runestrcpy(runestrchr(s1, 0), s2); runestrcpy(runestrchr(s1, 0), s2);

View File

@ -17,7 +17,7 @@
#include "utf.h" #include "utf.h"
Rune* Rune*
runestrchr(Rune *s, Rune c) runestrchr(const Rune *s, Rune c)
{ {
Rune c0 = c; Rune c0 = c;
Rune c1; Rune c1;
@ -25,11 +25,11 @@ runestrchr(Rune *s, Rune c)
if(c == 0) { if(c == 0) {
while(*s++) while(*s++)
; ;
return s-1; return (Rune*)s-1;
} }
while(c1 = *s++) while(c1 = *s++)
if(c1 == c0) if(c1 == c0)
return s-1; return (Rune*)s-1;
return 0; return 0;
} }

View File

@ -17,7 +17,7 @@
#include "utf.h" #include "utf.h"
int int
runestrcmp(Rune *s1, Rune *s2) runestrcmp(const Rune *s1, const Rune *s2)
{ {
Rune c1, c2; Rune c1, c2;

View File

@ -17,7 +17,7 @@
#include "utf.h" #include "utf.h"
Rune* Rune*
runestrcpy(Rune *s1, Rune *s2) runestrcpy(Rune *s1, const Rune *s2)
{ {
Rune *os1; Rune *os1;

View File

@ -15,7 +15,7 @@
#include <plan9.h> #include <plan9.h>
Rune* Rune*
runestrdup(Rune *s) runestrdup(const Rune *s)
{ {
Rune *ns; Rune *ns;

View File

@ -17,7 +17,7 @@
#include "utf.h" #include "utf.h"
Rune* Rune*
runestrecpy(Rune *s1, Rune *es1, Rune *s2) runestrecpy(Rune *s1, Rune *es1, const Rune *s2)
{ {
if(s1 >= es1) if(s1 >= es1)
return s1; return s1;

View File

@ -14,7 +14,7 @@
#include <plan9.h> #include <plan9.h>
long long
runestrlen(Rune *s) runestrlen(const Rune *s)
{ {
return runestrchr(s, 0) - s; return runestrchr(s, 0) - s;

View File

@ -17,7 +17,7 @@
#include "utf.h" #include "utf.h"
Rune* Rune*
runestrncat(Rune *s1, Rune *s2, long n) runestrncat(Rune *s1, const Rune *s2, long n)
{ {
Rune *os1; Rune *os1;

View File

@ -17,7 +17,7 @@
#include "utf.h" #include "utf.h"
int int
runestrncmp(Rune *s1, Rune *s2, long n) runestrncmp(const Rune *s1, const Rune *s2, long n)
{ {
Rune c1, c2; Rune c1, c2;

View File

@ -17,7 +17,7 @@
#include "utf.h" #include "utf.h"
Rune* Rune*
runestrncpy(Rune *s1, Rune *s2, long n) runestrncpy(Rune *s1, const Rune *s2, long n)
{ {
int i; int i;
Rune *os1; Rune *os1;

View File

@ -17,14 +17,14 @@
#include "utf.h" #include "utf.h"
Rune* Rune*
runestrrchr(Rune *s, Rune c) runestrrchr(const Rune *s, Rune c)
{ {
Rune *r; const Rune *r;
if(c == 0) if(c == 0)
return runestrchr(s, 0); return runestrchr(s, 0);
r = 0; r = 0;
while(s = runestrchr(s, c)) while(s = runestrchr(s, c))
r = s++; r = s++;
return r; return (Rune*)r;
} }

View File

@ -21,14 +21,15 @@
* 0 if none * 0 if none
*/ */
Rune* Rune*
runestrstr(Rune *s1, Rune *s2) runestrstr(const Rune *s1, const Rune *s2)
{ {
Rune *p, *pa, *pb; const Rune *pa, *pb;
Rune *p;
int c0, c; int c0, c;
c0 = *s2; c0 = *s2;
if(c0 == 0) if(c0 == 0)
return s1; return (Rune*)s1;
s2++; s2++;
for(p=runestrchr(s1, c0); p; p=runestrchr(p+1, c0)) { for(p=runestrchr(s1, c0); p; p=runestrchr(p+1, c0)) {
pa = p; pa = p;

View File

@ -1,17 +1,16 @@
CFLAGS += \ CFLAGS += \
-std=c99 \ -std=c99 \
-pipe \ -pipe \
-pedantic \
-Wall \ -Wall \
-Wno-parentheses \
-Wno-missing-braces \
-Wno-switch \
-Wno-comment \
-Wno-sign-compare \
-Wno-uninitialized \
-Wno-unused-parameter \
-Wimplicit \ -Wimplicit \
-Wreturn-type \
-Wtrigraphs \
-Wstrict-prototypes \
-Wmissing-prototypes \ -Wmissing-prototypes \
-Wno-comment \
-Wno-missing-braces \
-Wno-parentheses \
-Wno-sign-compare \
-Wno-switch \
-Wpointer-arith \ -Wpointer-arith \
-Wreturn-type \
-Wstrict-prototypes \
-Wtrigraphs \

View File

@ -1,6 +1,8 @@
#!/usr/bin/env wmii9rc #!/usr/bin/env wmii9rc
# WMII Configuration # WMII Configuration
ifs='' {nl=`{echo}}
confpath=`{echo $WMII_CONFPATH | sed 'y/:/ /'} confpath=`{echo $WMII_CONFPATH | sed 'y/:/ /'}
oldpath=$path oldpath=$path
path=($PLAN9/bin $path) path=($PLAN9/bin $path)
@ -11,24 +13,6 @@ if(echo $0 | grep -s '(^|/)rc\.wmii\.local$') {
exit badname exit badname
} }
fn config_whatis {
prog = `{@{path=$confpath whatis $1} | grep -v '^fn|=' || echo /dev/null}
shift; echo $prog $*
}
if(! test -x $PLAN9/bin/read) {
echo 'Can''t find the ''read'' command' >[1=2]
xmessage -file - <<'!'
path=$oldpath
exec `{config_whatis wmiirc}
}
rc.wmii can't run:
You have a Plan 9 utilities installed, but are missing the 'read' command.
This likely means that you have an out-of-date 9base installed.
wmiirc will be run instead.
!
# Configurables # Configurables
MODKEY=Mod1 MODKEY=Mod1
UP=k UP=k
@ -37,8 +21,8 @@ LEFT=h
RIGHT=l RIGHT=l
WMII_FONT='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*' WMII_FONT='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*'
WMII_NORMCOLORS=('#888888' '#222222' '#333333') WMII_NORMCOLORS=('#222222' '#5FBF77' '#2A7F3F')
WMII_FOCUSCOLORS=('#ffffff' '#285577' '#4C7899') WMII_FOCUSCOLORS=('#ffffff' '#153F1F' '#2A7F3F')
WMII_BACKGROUND='#333333' WMII_BACKGROUND='#333333'
WMII_TERM=(xterm) WMII_TERM=(xterm)
@ -58,7 +42,6 @@ wmiir write /tagrules <<!
# Status Bar Info # Status Bar Info
fn status { echo -n `{uptime | sed 's/.*://; s/,//g'} '|' `{date} } fn status { echo -n `{uptime | sed 's/.*://; s/,//g'} '|' `{date} }
fn viewtitle { echo $* } fn viewtitle { echo $* }
# Convenience Functions # Convenience Functions
@ -86,6 +69,11 @@ fn actionlist {
} | sort | uniq } | sort | uniq
} }
fn config_whatis {
prog = `{@{path=$confpath whatis $1} | grep -v '^fn|= ' || echo /dev/null}
shift; echo $prog $*
}
fn run_command { @{ fn run_command { @{
rfork ns rfork ns
path=$oldpath path=$oldpath
@ -93,9 +81,16 @@ fn run_command { @{
} }
} }
fn getfuns { env | sed -n 's/^fn#'^$1^'-([^=]+).*/\1/p' } fn getfuns {
fn initkeys { getfuns Key | wmiir write /keys } env | sed -n 's/^fn#'^$1^'-([^=]+).*/\1/p'
fn read_tags { wmiir ls /tag | sed 's,/,,; /^sel$/d' } }
fn initkeys {
getfuns Key | wmiir write /keys
}
fn read_tags {
wmiir ls /tag | sed 's,/,,; /^sel$/d'
}
fn 'fn?' {rc -c 'whatis '$1 >[2]/dev/null | grep -s '^fn ' } fn 'fn?' {rc -c 'whatis '$1 >[2]/dev/null | grep -s '^fn ' }
# Events # Events
@ -231,11 +226,11 @@ key Shift-$MODKEY-^`{seq 0 9} || fn $key {
# WM Configuration # WM Configuration
wmiir write /ctl <<! wmiir write /ctl <<!
grabmod $MODKEY grabmod $MODKEY
border 2 border 2
font $WMII_FONT font $WMII_FONT
focuscolors $WMII_FOCUSCOLORS focuscolors $WMII_FOCUSCOLORS
normcolors $WMII_NORMCOLORS normcolors $WMII_NORMCOLORS
! !
xsetroot -solid $WMII_BACKGROUND xsetroot -solid $WMII_BACKGROUND
@ -252,9 +247,8 @@ Action status
Action rehash Action rehash
# Tag Bar Setup # Tag Bar Setup
ifs='# ifs=$nl{
'{ for(bar in `{comm -23 <{wmiir ls /lbar} <{read_tags}}) wmiir rm `{comm -23 <{wmiir ls /lbar} <{read_tags}}
wmiir remove /lbar/$bar
seltag=`{wmiir read /tag/sel/ctl | sed 1q} seltag=`{wmiir read /tag/sel/ctl | sed 1q}
for(tag in `{read_tags}) { for(tag in `{read_tags}) {
if(~ $tag $seltag) if(~ $tag $seltag)
@ -276,3 +270,4 @@ wmiir read /event |
event = $1; shift event = $1; shift
Event-$event $* Event-$event $*
} >[2]/dev/null </dev/null } >[2]/dev/null </dev/null

View File

@ -9,15 +9,15 @@ LEFT=h
RIGHT=l RIGHT=l
# Colors tuples: "<text> <background> <border>" # Colors tuples: "<text> <background> <border>"
WMII_NORMCOLORS='#888888 #222222 #333333' WMII_NORMCOLORS='#222222 #5FBF77 #2A7F3F'
WMII_FOCUSCOLORS='#ffffff #285577 #4c7899' WMII_FOCUSCOLORS='#ffffff #153F1F #2A7F3F'
WMII_BACKGROUND='#333333' WMII_BACKGROUND='#333333'
WMII_FONT='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*' WMII_FONT='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*'
set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS) set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS)
WMII_MENU="dmenu -b -fn '$WMII_FONT' -nf '$1' -nb '$2' -sf '$4' -sb '$5'" WMII_MENU='dmenu -b -fn "$WMII_FONT" -nf '"$1 -nb $2 -sf $4 -sb $5"
WMII_9MENU="wmii9menu -font '$WMII_FONT' -nf '$1' -nb '$2' -sf '$4' -sb '$5' -br '$6'" WMII_9MENU='wmii9menu -font "$WMII_FONT" -nf '"$1 -nb $2 -sf $4 -sb $5 -br $6"
WMII_TERM="xterm" WMII_TERM="xterm"
# Column Rules # Column Rules
@ -40,7 +40,7 @@ status() {
# Event processing # Event processing
# Processed later by `wmiiloop' and evaled. # Processed later by `wmiiloop' and evaled.
# Duplicate the eval line and replace 'eval' with 'echo' for details. # Uncomment the line before the eval and run for details.
eventstuff() { eventstuff() {
cat <<'!' cat <<'!'
# Events # Events
@ -188,7 +188,7 @@ Action() {
proglist() { proglist() {
paths=$(echo "$@" | sed 'y/:/ /') paths=$(echo "$@" | sed 'y/:/ /')
ls -lL $paths 2>/dev/null \ ls -lL $paths 2>/dev/null \
| awk '$1 ~ /^[^d].*x/ && NF > 2 { print $NF }' \ | awk '$1 ~ /^[^d].*x/ { print $NF }' \
| sort | uniq | sort | uniq
} }
@ -200,18 +200,14 @@ proglist $PATH >$progsfile &
xsetroot -solid "$WMII_BACKGROUND" & xsetroot -solid "$WMII_BACKGROUND" &
# Setup Tag Bar # Setup Tag Bar
seltag="$(wmiir read /tag/sel/ctl 2>/dev/null)" (IFS="$(echo)"; wmiir rm $(wmiir ls /lbar))
wmiir ls /lbar | seltag="$(wmiir read /tag/sel/ctl 2>/dev/null | sed 1q)"
while read bar; do wmiir ls /tag | sed -e 's|/||; /^sel$/d' | while read tag; do
wmiir remove "/lbar/$bar" if [ "$tag" = "$seltag" ]; then
done echo "$WMII_FOCUSCOLORS" "$tag"
wmiir ls /tag | sed -e 's|/||; /^sel$/d' |
while read tag; do
if [ "X$tag" = "X$seltag" ]; then
echo "$WMII_FOCUSCOLORS" "$tag" | wmiir create "/lbar/$tag"
else else
echo "$WMII_NORMCOLORS" "$tag" | wmiir create "/lbar/$tag" echo "$WMII_NORMCOLORS" "$tag"
fi fi | wmiir create "/lbar/$tag"
done done
# More functions # More functions
@ -234,9 +230,9 @@ conf_which() {
# Stop any running instances of wmiirc # Stop any running instances of wmiirc
echo Start wmiirc | wmiir write /event || exit 1 echo Start wmiirc | wmiir write /event || exit 1
wmiir read /event | wmiir read /event | while read event; do
while read event; do
set -- $event set -- $event
event=$1; shift event=$1; shift
Event_$event $@ Event_$event $@
done 2>/dev/null done 2>/dev/null