mirror of https://github.com/0intro/wmii
Pre-merge mess.
This commit is contained in:
parent
0d05e4f153
commit
f6c2a49d34
1
Makefile
1
Makefile
|
@ -23,5 +23,6 @@ deb:
|
|||
dpkg-buildpackage -rfakeroot
|
||||
|
||||
include ${ROOT}/mk/dir.mk
|
||||
include ${ROOT}/mk/common.mk
|
||||
INSTDIRS = ${PDIRS}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "fns.h"
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dat.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "fns.h"
|
||||
|
||||
|
@ -56,8 +55,8 @@ create_bar(Bar **bp, char *name) {
|
|||
utflcpy(b->name, name, sizeof(b->name));
|
||||
b->col = def.normcolor;
|
||||
|
||||
for(; *bp; bp = &(*bp)->next)
|
||||
if(strcmp((*bp)->name, name) >= 0)
|
||||
for(; *bp; bp = &bp[0]->next)
|
||||
if(strcmp(bp[0]->name, name) >= 0)
|
||||
break;
|
||||
b->next = *bp;
|
||||
*bp = b;
|
||||
|
@ -69,7 +68,7 @@ void
|
|||
destroy_bar(Bar **bp, Bar *b) {
|
||||
Bar **p;
|
||||
|
||||
for(p = bp; *p; p = &(*p)->next)
|
||||
for(p = bp; *p; p = &p[0]->next)
|
||||
if(*p == b) break;
|
||||
*p = b->next;
|
||||
|
||||
|
@ -113,12 +112,11 @@ draw_bar(WMScreen *s) {
|
|||
width += Dx(b->r);
|
||||
}
|
||||
|
||||
|
||||
if(width > Dx(s->brect)) { /* Not enough room. Shrink bars until they all fit. */
|
||||
for(nb = 0; nb < nelem(s->bar); nb++)
|
||||
for(b = s->bar[nb]; b; b=b->next) {
|
||||
for(pb = &largest; *pb; pb = &(*pb)->smaller)
|
||||
if(Dx((*pb)->r) < Dx(b->r))
|
||||
for(pb = &largest; *pb; pb = &pb[0]->smaller)
|
||||
if(Dx(pb[0]->r) < Dx(b->r))
|
||||
break;
|
||||
b->smaller = *pb;
|
||||
*pb = b;
|
||||
|
@ -131,13 +129,14 @@ draw_bar(WMScreen *s) {
|
|||
if(Dx(tb->r) * shrink >= Dx(tb->smaller->r))
|
||||
break;
|
||||
}
|
||||
SET(shrink);
|
||||
if(tb)
|
||||
for(b = largest; b != tb->smaller; b = b->smaller)
|
||||
b->r.max.x *= shrink;
|
||||
width += tw * shrink;
|
||||
}
|
||||
|
||||
SET(tb);
|
||||
tb = nil;
|
||||
for(nb = 0; nb < nelem(s->bar); nb++)
|
||||
for(b = s->bar[nb]; b; tb=b, b=b->next) {
|
||||
if(b == s->bar[BarRight])
|
||||
|
@ -198,8 +197,7 @@ static void
|
|||
bup_event(Window *w, XButtonPressedEvent *e) {
|
||||
Bar *b;
|
||||
|
||||
USED(w);
|
||||
USED(e);
|
||||
USED(w, e);
|
||||
|
||||
for(b=screen->bar[BarLeft]; b; b=b->next)
|
||||
if(ptinrect(Pt(e->x, e->y), b->r)) {
|
||||
|
@ -215,8 +213,7 @@ bup_event(Window *w, XButtonPressedEvent *e) {
|
|||
|
||||
static void
|
||||
expose_event(Window *w, XExposeEvent *e) {
|
||||
USED(w);
|
||||
USED(e);
|
||||
USED(w, e);
|
||||
draw_bar(screen);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "dat.h"
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include "fns.h"
|
||||
|
@ -76,7 +75,7 @@ create_client(XWindow w, XWindowAttributes *wa) {
|
|||
|
||||
grab_button(c->framewin->w, AnyButton, AnyModifier);
|
||||
|
||||
for(t=&client ;; t=&(*t)->next)
|
||||
for(t=&client ;; t=&t[0]->next)
|
||||
if(!*t) {
|
||||
c->next = *t;
|
||||
*t = c;
|
||||
|
@ -125,8 +124,7 @@ manage_client(Client *c) {
|
|||
|
||||
static int /* Temporary Xlib error handler */
|
||||
ignoreerrors(Display *d, XErrorEvent *e) {
|
||||
USED(d);
|
||||
USED(e);
|
||||
USED(d, e);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -142,7 +140,7 @@ destroy_client(Client *c) {
|
|||
|
||||
unmapwin(c->framewin);
|
||||
|
||||
for(tc=&client; *tc; tc=&(*tc)->next)
|
||||
for(tc=&client; *tc; tc=&tc[0]->next)
|
||||
if(*tc == c) {
|
||||
*tc = c->next;
|
||||
break;
|
||||
|
@ -330,32 +328,27 @@ focus_client(Client *c) {
|
|||
|
||||
Dprint("focus_client(%p[%C]) => %s\n", c, c, clientname(c));
|
||||
|
||||
if (screen->focus == c)
|
||||
return;
|
||||
|
||||
if(c == nil || !c->noinput) {
|
||||
if((c == nil || !c->noinput) && screen->focus != c) {
|
||||
Dprint("\t%s => %s\n", clientname(screen->focus), clientname(c));
|
||||
|
||||
if(c)
|
||||
setfocus(&c->w, RevertToPointerRoot);
|
||||
setfocus(&c->w, RevertToParent);
|
||||
else
|
||||
setfocus(screen->barwin, RevertToPointerRoot);
|
||||
setfocus(screen->barwin, RevertToParent);
|
||||
|
||||
write_event("ClientFocus %C\n", c);
|
||||
|
||||
XSync(display, False);
|
||||
flushevents(FocusChangeMask, True);
|
||||
} else if(c && c->noinput) {
|
||||
setfocus(nil, RevertToPointerRoot);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
resize_client(Client *c, Rectangle *r) {
|
||||
resize_client(Client *c, Rectangle r) {
|
||||
Frame *f;
|
||||
|
||||
f = c->sel;
|
||||
resize_frame(f, *r);
|
||||
resize_frame(f, r);
|
||||
|
||||
if(f->area->view != screen->sel) {
|
||||
unmap_client(c, IconicState);
|
||||
|
@ -455,10 +448,6 @@ fullscreen(Client *c, int fullscreen) {
|
|||
|
||||
if((f = c->sel)) {
|
||||
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)
|
||||
f->revert = f->r;
|
||||
else {
|
||||
|
@ -466,13 +455,8 @@ fullscreen(Client *c, int fullscreen) {
|
|||
send_to_area(f->view->area, f);
|
||||
}
|
||||
focus_client(c);
|
||||
}else {
|
||||
}else
|
||||
resize_frame(f, f->revert);
|
||||
if (c->revert) {
|
||||
send_to_area(c->revert, f);
|
||||
c->revert = nil;
|
||||
}
|
||||
}
|
||||
if(f->view == screen->sel)
|
||||
focus_view(screen, f->view);
|
||||
}
|
||||
|
@ -589,7 +573,7 @@ updatemwm(Client *c) {
|
|||
|
||||
if(c->sel) {
|
||||
r = client2frame(c->sel, r);
|
||||
resize_client(c, &r);
|
||||
resize_client(c, r);
|
||||
draw_frame(c->sel);
|
||||
}
|
||||
}
|
||||
|
@ -672,7 +656,7 @@ configreq_event(Window *w, XConfigureRequestEvent *e) {
|
|||
fullscreen(c, True);
|
||||
|
||||
if(c->sel->area->floating)
|
||||
resize_client(c, &r);
|
||||
resize_client(c, r);
|
||||
else {
|
||||
c->sel->revert = r;
|
||||
configure_client(c);
|
||||
|
@ -681,8 +665,7 @@ configreq_event(Window *w, XConfigureRequestEvent *e) {
|
|||
|
||||
static void
|
||||
destroy_event(Window *w, XDestroyWindowEvent *e) {
|
||||
USED(w);
|
||||
USED(e);
|
||||
USED(w, e);
|
||||
|
||||
Dprint("client.c:destroy_event(%W)\n", w);
|
||||
destroy_client(w->aux);
|
||||
|
@ -823,7 +806,7 @@ update_client_views(Client *c, char **tags) {
|
|||
SET(cmp);
|
||||
while(*fp) {
|
||||
if(*tags) {
|
||||
cmp = strcmp((*fp)->view->name, *tags);
|
||||
cmp = strcmp(fp[0]->view->name, *tags);
|
||||
if(cmp >= 0)
|
||||
break;
|
||||
}
|
||||
|
@ -844,7 +827,7 @@ update_client_views(Client *c, char **tags) {
|
|||
f->cnext = *fp;
|
||||
*fp = f;
|
||||
}
|
||||
if(*fp) fp=&(*fp)->cnext;
|
||||
if(fp[0]) fp=&fp[0]->cnext;
|
||||
tags++;
|
||||
}
|
||||
}
|
||||
|
@ -857,8 +840,12 @@ bsstrcmp(const void *a, const void *b) {
|
|||
}
|
||||
|
||||
static int
|
||||
strpcmp(const void *a, const void *b) {
|
||||
return strcmp(*(char **)a, *(char **)b);
|
||||
strpcmp(const void *ap, const void *bp) {
|
||||
char **a, **b;
|
||||
|
||||
a = (char**)ap; /* gcc wants this case. *sigh* */
|
||||
b = (char**)bp;
|
||||
return strcmp(*a, *b);
|
||||
}
|
||||
|
||||
static char *badtags[] = {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "dat.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include "fns.h"
|
||||
|
@ -359,14 +358,14 @@ arrange_column(Area *a, Bool dirty) {
|
|||
resize:
|
||||
if(a->view == screen->sel) {
|
||||
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)
|
||||
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)
|
||||
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;
|
||||
View *v;
|
||||
uint minw;
|
||||
int dx, dw;
|
||||
int dx, dw, maxx;
|
||||
|
||||
a = f->area;
|
||||
v = a->view;
|
||||
maxx = r->max.x;
|
||||
|
||||
minw = Dx(screen->r) / NCOL;
|
||||
|
||||
if(a->prev && !a->prev->floating)
|
||||
al = a->prev;
|
||||
else
|
||||
al = nil;
|
||||
al = a->prev;
|
||||
ar = a->next;
|
||||
|
||||
if(al)
|
||||
|
@ -443,26 +440,28 @@ resize_colframe(Frame *f, Rectangle *r) {
|
|||
else
|
||||
r->min.x = max(r->min.x, 0);
|
||||
|
||||
if(ar)
|
||||
r->max.x = min(r->max.x, ar->r.max.x - minw);
|
||||
if(ar) {
|
||||
if(maxx >= ar->r.max.x - minw)
|
||||
maxx = ar->r.max.x - minw;
|
||||
}
|
||||
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;
|
||||
dw = r->max.x - a->r.max.x;
|
||||
dw = maxx - a->r.max.x;
|
||||
if(al) {
|
||||
al->r.max.x -= dx;
|
||||
arrange_column(al, False);
|
||||
}
|
||||
if(ar) {
|
||||
ar->r.min.x += dw;
|
||||
ar->r.max.x -= dw;
|
||||
arrange_column(ar, False);
|
||||
}
|
||||
|
||||
resize_colframeh(f, r);
|
||||
|
||||
a->r.min.x = r->min.x;
|
||||
a->r.max.x = r->max.x;
|
||||
a->r.max.x = maxx;
|
||||
arrange_view(a->view);
|
||||
|
||||
focus_view(screen, v);
|
||||
|
|
|
@ -131,26 +131,24 @@ struct Client {
|
|||
Area *revert;
|
||||
Frame *frame;
|
||||
Frame *sel;
|
||||
Window w;
|
||||
Window *framewin;
|
||||
XWindow trans;
|
||||
Cursor cursor;
|
||||
Rectangle r;
|
||||
char name[256];
|
||||
char tags[256];
|
||||
char props[512];
|
||||
uint border;
|
||||
int proto;
|
||||
Bool floating;
|
||||
Bool fixedsize;
|
||||
Bool fullscreen;
|
||||
Bool urgent;
|
||||
Bool borderless;
|
||||
Bool titleless;
|
||||
Bool noinput;
|
||||
char floating;
|
||||
char fixedsize;
|
||||
char fullscreen;
|
||||
char urgent;
|
||||
char borderless;
|
||||
char titleless;
|
||||
char noinput;
|
||||
int unmapped;
|
||||
Window w;
|
||||
XWindow trans;
|
||||
Window *framewin;
|
||||
Cursor cursor;
|
||||
Rectangle r;
|
||||
XSizeHints size;
|
||||
GC gc;
|
||||
};
|
||||
|
||||
struct Divide {
|
||||
|
@ -193,19 +191,23 @@ struct Ruleset {
|
|||
uint size;
|
||||
};
|
||||
|
||||
#ifndef EXTERN
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* global variables */
|
||||
struct {
|
||||
EXTERN struct {
|
||||
CTuple focuscolor;
|
||||
CTuple normcolor;
|
||||
Font *font;
|
||||
uint border;
|
||||
uint snap;
|
||||
char *keys;
|
||||
uint keyssz;
|
||||
Ruleset tagrules;
|
||||
Ruleset colrules;
|
||||
char grabmod[5];
|
||||
ulong mod;
|
||||
uint border;
|
||||
uint snap;
|
||||
uint keyssz;
|
||||
int colmode;
|
||||
} def;
|
||||
|
||||
|
@ -213,7 +215,7 @@ enum {
|
|||
BarLeft, BarRight
|
||||
};
|
||||
|
||||
struct WMScreen {
|
||||
EXTERN struct WMScreen {
|
||||
Bar *bar[2];
|
||||
View *sel;
|
||||
Client *focus;
|
||||
|
@ -225,39 +227,41 @@ struct WMScreen {
|
|||
Rectangle brect;
|
||||
} *screens, *screen;
|
||||
|
||||
Client *client;
|
||||
View *view;
|
||||
Key *key;
|
||||
Divide *divs;
|
||||
Client c_magic;
|
||||
Client c_root;
|
||||
EXTERN Client* client;
|
||||
EXTERN View* view;
|
||||
EXTERN Key* key;
|
||||
EXTERN Divide* divs;
|
||||
EXTERN Client c_magic;
|
||||
EXTERN Client c_root;
|
||||
|
||||
Handlers framehandler;
|
||||
EXTERN Handlers framehandler;
|
||||
|
||||
char buffer[8092];
|
||||
EXTERN char buffer[8092];
|
||||
|
||||
/* IXP */
|
||||
IxpServer srv;
|
||||
Ixp9Srv p9srv;
|
||||
EXTERN IxpServer srv;
|
||||
EXTERN Ixp9Srv p9srv;
|
||||
|
||||
/* X11 */
|
||||
uint num_screens;
|
||||
uint valid_mask;
|
||||
uint num_lock_mask;
|
||||
Bool sel_screen;
|
||||
EXTERN uint num_screens;
|
||||
EXTERN uint valid_mask;
|
||||
EXTERN uint num_lock_mask;
|
||||
EXTERN Bool sel_screen;
|
||||
|
||||
Image xor;
|
||||
EXTERN Cursor cursor[CurLast];
|
||||
|
||||
Cursor cursor[CurLast];
|
||||
void (*handler[LASTEvent]) (XEvent *);
|
||||
typedef void (*XHandler)(XEvent*);
|
||||
EXTERN XHandler handler[LASTEvent];
|
||||
|
||||
/* Misc */
|
||||
Image *broken;
|
||||
Bool starting;
|
||||
Bool verbose;
|
||||
char *user;
|
||||
char *execstr;
|
||||
EXTERN Image* broken;
|
||||
EXTERN Bool starting;
|
||||
EXTERN Bool verbose;
|
||||
EXTERN char* user;
|
||||
EXTERN char* execstr;
|
||||
|
||||
#define BLOCK(x) do { x; }while(0)
|
||||
|
||||
#define Debug if(verbose)
|
||||
#define Dprint(...) do{ Debug fprint(2, __VA_ARGS__); }while(0)
|
||||
#define Dprint(...) BLOCK( Debug fprint(2, __VA_ARGS__) )
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dat.h"
|
||||
#include <stdio.h>
|
||||
#include <X11/keysym.h>
|
||||
#include "fns.h"
|
||||
#include "printevent.h"
|
||||
|
@ -135,7 +134,7 @@ focusin(XEvent *e) {
|
|||
if(ev->detail == NotifyDetailNone) {
|
||||
print_focus(&c_magic, "<magic[none]>");
|
||||
screen->focus = &c_magic;
|
||||
setfocus(screen->barwin, RevertToPointerRoot);
|
||||
setfocus(screen->barwin, RevertToParent);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
394
cmd/wmii/fns.h
394
cmd/wmii/fns.h
|
@ -13,234 +13,232 @@
|
|||
#endif
|
||||
|
||||
/* area.c */
|
||||
char *area_name(Area *a);
|
||||
uint area_idx(Area *a);
|
||||
Area *create_area(View*, Area *pos, uint w);
|
||||
void destroy_area(Area*);
|
||||
Area *area_of_id(View*, ushort id);
|
||||
void focus_area(Area*);
|
||||
void send_to_area(Area*, Frame*);
|
||||
void attach_to_area(Area*, Frame*);
|
||||
void detach_from_area(Frame*);
|
||||
Client *area_selclient(Area*);
|
||||
uint area_idx(Area*);
|
||||
char* area_name(Area*);
|
||||
Client* area_selclient(Area*);
|
||||
void attach_to_area(Area*, Frame*);
|
||||
Area* create_area(View*, Area *pos, uint w);
|
||||
void destroy_area(Area*);
|
||||
void detach_from_area(Frame*);
|
||||
void focus_area(Area*);
|
||||
void send_to_area(Area*, Frame*);
|
||||
|
||||
/* bar.c */
|
||||
void initbar(WMScreen *s);
|
||||
Bar *create_bar(Bar **b_link, char *name);
|
||||
void destroy_bar(Bar **b_link, Bar*);
|
||||
void draw_bar(WMScreen *s);
|
||||
void resize_bar(WMScreen *s);
|
||||
Bar *bar_of_name(Bar *b_link, const char *name);
|
||||
Bar* bar_of_name(Bar*, const char*);
|
||||
Bar* create_bar(Bar**, char*);
|
||||
void destroy_bar(Bar**, Bar*);
|
||||
void draw_bar(WMScreen*);
|
||||
void initbar(WMScreen*);
|
||||
void resize_bar(WMScreen*);
|
||||
|
||||
/* client.c */
|
||||
Client *create_client(XWindow, XWindowAttributes*);
|
||||
void destroy_client(Client*);
|
||||
void configure_client(Client*);
|
||||
void update_class(Client *c);
|
||||
void prop_client(Client *c, Atom);
|
||||
void kill_client(Client*);
|
||||
void gravitate_client(Client*, Bool invert);
|
||||
void map_client(Client*);
|
||||
void unmap_client(Client*, int state);
|
||||
int map_frame(Client*);
|
||||
int unmap_frame(Client*);
|
||||
Rectangle gravclient(Client*, Rectangle);
|
||||
void fullscreen(Client*, Bool);
|
||||
void set_urgent(Client *, Bool urgent, Bool write);
|
||||
void set_cursor(Client*, Cursor);
|
||||
void focus_frame(Frame*, Bool restack);
|
||||
void reparent_client(Client*, Window*, Point);
|
||||
void manage_client(Client*);
|
||||
void focus(Client*, Bool restack);
|
||||
void focus_client(Client*);
|
||||
void resize_client(Client*, Rectangle*);
|
||||
void apply_sizehints(Client*, Rectangle*, Bool floating, Bool frame, Align sticky);
|
||||
void move_client(Client*, char *arg);
|
||||
void size_client(Client*, char *arg);
|
||||
Client *selclient(void);
|
||||
Client *win2client(XWindow);
|
||||
int Cfmt(Fmt *f);
|
||||
char *clientname(Client*);
|
||||
void apply_rules(Client*);
|
||||
void apply_tags(Client*, const char*);
|
||||
int Cfmt(Fmt *f);
|
||||
void apply_rules(Client*);
|
||||
void apply_tags(Client*, const char*);
|
||||
char* clientname(Client*);
|
||||
void configure_client(Client*);
|
||||
Client* create_client(XWindow, XWindowAttributes*);
|
||||
void destroy_client(Client*);
|
||||
void focus(Client*, Bool restack);
|
||||
void focus_client(Client*);
|
||||
void focus_frame(Frame*, Bool restack);
|
||||
void fullscreen(Client*, Bool);
|
||||
void kill_client(Client*);
|
||||
void manage_client(Client*);
|
||||
void map_client(Client*);
|
||||
int map_frame(Client*);
|
||||
void move_client(Client*, char*);
|
||||
void prop_client(Client*, Atom);
|
||||
void reparent_client(Client*, Window*, Point);
|
||||
void resize_client(Client*, Rectangle);
|
||||
Client* selclient(void);
|
||||
void set_cursor(Client*, Cursor);
|
||||
void set_urgent(Client *, Bool urgent, Bool write);
|
||||
void size_client(Client*, char*);
|
||||
void unmap_client(Client*, int state);
|
||||
int unmap_frame(Client*);
|
||||
void update_class(Client*);
|
||||
Client* win2client(XWindow);
|
||||
Rectangle gravclient(Client*, Rectangle);
|
||||
|
||||
/* column.c */
|
||||
void update_divs(void);
|
||||
void draw_div(Divide*);
|
||||
void setdiv(Divide*, int x);
|
||||
void arrange_column(Area*, Bool dirty);
|
||||
void resize_column(Area*, int w);
|
||||
void resize_colframe(Frame*, Rectangle*);
|
||||
int str2colmode(const char *str);
|
||||
char *colmode2str(int i);
|
||||
Area *new_column(View*, Area *pos, uint w);
|
||||
void arrange_column(Area*, Bool dirty);
|
||||
char* colmode2str(int);
|
||||
void draw_div(Divide*);
|
||||
Area* new_column(View*, Area *, uint);
|
||||
void resize_colframe(Frame*, Rectangle*);
|
||||
void resize_column(Area*, int);
|
||||
void setdiv(Divide*, int x);
|
||||
int str2colmode(const char*);
|
||||
void update_divs(void);
|
||||
|
||||
/* event.c */
|
||||
void dispatch_event(XEvent*);
|
||||
void check_x_event(IxpConn*);
|
||||
uint flushevents(long even_mask, Bool dispatch);
|
||||
void print_focus(Client *c, char *to);
|
||||
void check_x_event(IxpConn*);
|
||||
void dispatch_event(XEvent*);
|
||||
uint flushevents(long, Bool dispatch);
|
||||
void print_focus(Client*, char*);
|
||||
|
||||
/* frame.c */
|
||||
uint frame_idx(Frame *f);
|
||||
Frame *create_frame(Client*, View*);
|
||||
void remove_frame(Frame*);
|
||||
void insert_frame(Frame *pos, Frame*);
|
||||
void resize_frame(Frame*, Rectangle);
|
||||
Bool frame_to_top(Frame *f);
|
||||
void set_frame_cursor(Frame*, Point);
|
||||
void swap_frames(Frame*, Frame*);
|
||||
int frame_delta_h(void);
|
||||
Rectangle frame_hints(Frame*, Rectangle, Align);
|
||||
Rectangle frame2client(Frame*, Rectangle);
|
||||
Rectangle client2frame(Frame*, Rectangle);
|
||||
int ingrabbox(Frame*, int x, int y);
|
||||
void draw_frame(Frame*);
|
||||
void draw_frames(void);
|
||||
void update_frame_widget_colors(Frame*);
|
||||
Frame* create_frame(Client*, View*);
|
||||
void draw_frame(Frame*);
|
||||
void draw_frames(void);
|
||||
int frame_delta_h(void);
|
||||
uint frame_idx(Frame*);
|
||||
Bool frame_to_top(Frame*);
|
||||
int ingrabbox(Frame*, int x, int y);
|
||||
void insert_frame(Frame *pos, Frame*);
|
||||
void remove_frame(Frame*);
|
||||
void resize_frame(Frame*, Rectangle);
|
||||
void set_frame_cursor(Frame*, Point);
|
||||
void swap_frames(Frame*, Frame*);
|
||||
void update_frame_widget_colors(Frame*);
|
||||
Rectangle constrain(Rectangle);
|
||||
Rectangle client2frame(Frame*, Rectangle);
|
||||
Rectangle frame2client(Frame*, Rectangle);
|
||||
Rectangle frame_hints(Frame*, Rectangle, Align);
|
||||
|
||||
/* fs.c */
|
||||
void fs_attach(Ixp9Req*);
|
||||
void fs_clunk(Ixp9Req*);
|
||||
void fs_create(Ixp9Req*);
|
||||
void fs_flush(Ixp9Req*);
|
||||
void fs_freefid(Fid*);
|
||||
void fs_open(Ixp9Req*);
|
||||
void fs_read(Ixp9Req*);
|
||||
void fs_remove(Ixp9Req*);
|
||||
void fs_stat(Ixp9Req*);
|
||||
void fs_walk(Ixp9Req*);
|
||||
void fs_write(Ixp9Req*);
|
||||
void write_event(char*, ...);
|
||||
void fs_attach(Ixp9Req*);
|
||||
void fs_clunk(Ixp9Req*);
|
||||
void fs_create(Ixp9Req*);
|
||||
void fs_flush(Ixp9Req*);
|
||||
void fs_freefid(Fid*);
|
||||
void fs_open(Ixp9Req*);
|
||||
void fs_read(Ixp9Req*);
|
||||
void fs_remove(Ixp9Req*);
|
||||
void fs_stat(Ixp9Req*);
|
||||
void fs_walk(Ixp9Req*);
|
||||
void fs_write(Ixp9Req*);
|
||||
void write_event(char*, ...);
|
||||
|
||||
/* geom.c */
|
||||
Bool ptinrect(Point, Rectangle);
|
||||
Align quadrant(Rectangle, Point);
|
||||
Cursor cursor_of_quad(Align);
|
||||
Align get_sticky(Rectangle src, Rectangle dst);
|
||||
Cursor cursor_of_quad(Align);
|
||||
Align get_sticky(Rectangle src, Rectangle dst);
|
||||
Bool ptinrect(Point, Rectangle);
|
||||
Align quadrant(Rectangle, Point);
|
||||
|
||||
/* key.c */
|
||||
void kpress(XWindow, ulong mod, KeyCode);
|
||||
void update_keys(void);
|
||||
void init_lock_keys(void);
|
||||
ulong str2modmask(char*);
|
||||
void init_lock_keys(void);
|
||||
void kpress(XWindow, ulong mod, KeyCode);
|
||||
ulong str2modmask(char*);
|
||||
void update_keys(void);
|
||||
|
||||
/* map.c */
|
||||
MapEnt* mapget(Map*, ulong, int create);
|
||||
MapEnt* hashget(Map*, char*, int create);
|
||||
void* maprm(Map*, ulong);
|
||||
void* hashrm(Map*, char*);
|
||||
MapEnt* hashget(Map*, char*, int create);
|
||||
void* hashrm(Map*, char*);
|
||||
MapEnt* mapget(Map*, ulong, int create);
|
||||
void* maprm(Map*, ulong);
|
||||
|
||||
/* message.c */
|
||||
char *getword(IxpMsg*);
|
||||
int getulong(char*, ulong*);
|
||||
int getlong(char*, long*);
|
||||
Area *strarea(View*, char*);
|
||||
char *message_view(View*, IxpMsg*);
|
||||
char *parse_colors(IxpMsg*, CTuple*);
|
||||
char *message_root(void*, IxpMsg*);
|
||||
char *read_root_ctl(void);
|
||||
char *message_client(Client*, IxpMsg*);
|
||||
char *select_area(Area*, IxpMsg*);
|
||||
char *send_client(View*, IxpMsg*, Bool swap);
|
||||
int getlong(char*, long*);
|
||||
int getulong(char*, ulong*);
|
||||
char* getword(IxpMsg*);
|
||||
char* message_client(Client*, IxpMsg*);
|
||||
char* message_root(void*, IxpMsg*);
|
||||
char* message_view(View*, IxpMsg*);
|
||||
char* parse_colors(IxpMsg*, CTuple*);
|
||||
char* read_root_ctl(void);
|
||||
char* select_area(Area*, IxpMsg*);
|
||||
char* send_client(View*, IxpMsg*, Bool swap);
|
||||
Area* strarea(View*, char*);
|
||||
|
||||
/* mouse.c */
|
||||
void mouse_resizecol(Divide*);
|
||||
void do_mouse_resize(Client*, Bool opaque, Align);
|
||||
void grab_mouse(XWindow, ulong mod, ulong button);
|
||||
void ungrab_mouse(XWindow, ulong mod, uint button);
|
||||
Align snap_rect(Rectangle *rects, int num, Rectangle *current, Align *mask, int snapw);
|
||||
void grab_button(XWindow, uint button, ulong mod);
|
||||
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 mouse_resizecol(Divide*);
|
||||
Align snap_rect(Rectangle *rects, int num, Rectangle *current, Align *mask, int snapw);
|
||||
void ungrab_mouse(XWindow, ulong mod, uint button);
|
||||
|
||||
/* 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 */
|
||||
void arrange_view(View*);
|
||||
void scale_view(View*, int w);
|
||||
View *get_view(const char*);
|
||||
View *create_view(const char*);
|
||||
void focus_view(WMScreen*, View*);
|
||||
void update_client_views(Client*, char**);
|
||||
Rectangle *rects_of_view(View*, uint *num, Frame *ignore);
|
||||
View *view_of_id(ushort);
|
||||
Frame *view_clientframe(View *v, Client *c);
|
||||
void select_view(const char*);
|
||||
void attach_to_view(View*, Frame*);
|
||||
Client *view_selclient(View*);
|
||||
char *message_view(View *v, IxpMsg *m);
|
||||
void restack_view(View*);
|
||||
uchar *view_index(View*);
|
||||
uchar *view_ctl(View *v);
|
||||
void destroy_view(View*);
|
||||
void update_views(void);
|
||||
uint newcolw(View*, int i);
|
||||
View *get_view(const char*);
|
||||
void arrange_view(View*);
|
||||
void attach_to_view(View*, Frame*);
|
||||
View* create_view(const char*);
|
||||
void destroy_view(View*);
|
||||
void focus_view(WMScreen*, View*);
|
||||
char* message_view(View *v, IxpMsg *m);
|
||||
uint newcolw(View*, int i);
|
||||
void restack_view(View*);
|
||||
void scale_view(View*, int w);
|
||||
void select_view(const char*);
|
||||
void update_client_views(Client*, char**);
|
||||
void update_views(void);
|
||||
Frame* view_clientframe(View *v, Client *c);
|
||||
uchar* view_ctl(View *v);
|
||||
uchar* view_index(View*);
|
||||
View* view_of_id(ushort);
|
||||
Client* view_selclient(View*);
|
||||
Rectangle* rects_of_view(View*, uint *num, Frame *ignore);
|
||||
|
||||
/* wm.c */
|
||||
int win_proto(Window);
|
||||
int win_proto(Window);
|
||||
|
||||
/* x11.c */
|
||||
XRectangle XRect(Rectangle);
|
||||
int eqrect(Rectangle, Rectangle);
|
||||
int eqpt(Point, Point);
|
||||
Point addpt(Point, Point);
|
||||
Point subpt(Point, Point);
|
||||
Point mulpt(Point p, Point q);
|
||||
Point divpt(Point, Point);
|
||||
Rectangle insetrect(Rectangle, int);
|
||||
Rectangle rectaddpt(Rectangle, Point);
|
||||
Rectangle rectsubpt(Rectangle, Point);
|
||||
void initdisplay(void);
|
||||
Image * allocimage(int w, int h, int depth);
|
||||
void freeimage(Image *);
|
||||
Window *createwindow(Window *parent, Rectangle, int depth, uint class, WinAttr*, int valuemask);
|
||||
void reparentwindow(Window*, Window*, Point);
|
||||
void destroywindow(Window*);
|
||||
void setwinattr(Window*, WinAttr*, int valmask);
|
||||
void reshapewin(Window*, Rectangle);
|
||||
void movewin(Window*, Point);
|
||||
int mapwin(Window*);
|
||||
int unmapwin(Window*);
|
||||
void lowerwin(Window*);
|
||||
void raisewin(Window*);
|
||||
Handlers* sethandler(Window*, Handlers*);
|
||||
Window* findwin(XWindow);
|
||||
uint winprotocols(Window*);
|
||||
void setshapemask(Window *dst, Image *src, Point);
|
||||
void border(Image *dst, Rectangle, int w, ulong col);
|
||||
void fill(Image *dst, Rectangle, ulong col);
|
||||
void drawpoly(Image *dst, Point *pt, int np, int cap, int w, ulong col);
|
||||
void fillpoly(Image *dst, Point *pt, int np, ulong col);
|
||||
void drawline(Image *dst, Point p1, Point p2, int cap, int w, ulong col);
|
||||
void drawstring(Image *dst, Font *font, Rectangle, Align align, char *text, ulong col);
|
||||
void copyimage(Image *dst, Rectangle, Image *src, Point p);
|
||||
Bool namedcolor(char *name, ulong*);
|
||||
Bool loadcolor(CTuple*, char*);
|
||||
Font * loadfont(char*);
|
||||
void freefont(Font*);
|
||||
uint textwidth_l(Font*, char*, uint len);
|
||||
uint textwidth(Font*, char*);
|
||||
uint labelh(Font*);
|
||||
Atom xatom(char*);
|
||||
void freestringlist(char**);
|
||||
ulong getproperty(Window *w, char *prop, char *type, Atom *actual, ulong offset, uchar **ret, ulong length);
|
||||
char *gettextproperty(Window*, char*);
|
||||
int gettextlistproperty(Window *w, char *name, char **ret[]);
|
||||
void changeproperty(Window*, char *prop, char *type, int width, uchar *data, int n);
|
||||
void changeprop_char(Window *w, char *prop, char *type, char data[], int len);
|
||||
void changeprop_short(Window *w, char *prop, char *type, short data[], int len);
|
||||
void changeprop_long(Window *w, char *prop, char *type, long data[], int len);
|
||||
void setfocus(Window*, int mode);
|
||||
Point querypointer(Window*);
|
||||
void warppointer(Point);
|
||||
Point translate(Window*, Window*, Point);
|
||||
int grabpointer(Window*, Window *confine, Cursor, int mask);
|
||||
void ungrabpointer(void);
|
||||
Rectangle gravitate(Rectangle dst, Rectangle src, Point grav);
|
||||
Rectangle sizehint(WinHints*, Rectangle);
|
||||
void sethints(Window*);
|
||||
Window *createwindow(Window *parent, Rectangle, int depth, uint class, WinAttr*, int valuemask);
|
||||
char *gettextproperty(Window*, char*);
|
||||
Point addpt(Point, Point);
|
||||
Image* allocimage(int w, int h, int depth);
|
||||
void border(Image *dst, Rectangle, int w, ulong col);
|
||||
void changeprop_char(Window *w, char *prop, char *type, char data[], int len);
|
||||
void changeprop_long(Window *w, char *prop, char *type, long data[], int len);
|
||||
void changeprop_short(Window *w, char *prop, char *type, short data[], int len);
|
||||
void changeproperty(Window*, char *prop, char *type, int width, uchar *data, int n);
|
||||
void copyimage(Image *dst, Rectangle, Image *src, Point p);
|
||||
void destroywindow(Window*);
|
||||
Point divpt(Point, Point);
|
||||
void drawline(Image *dst, Point p1, Point p2, int cap, int w, ulong col);
|
||||
void drawpoly(Image *dst, Point *pt, int np, int cap, int w, ulong col);
|
||||
void drawstring(Image *dst, Font *font, Rectangle, Align align, char *text, ulong col);
|
||||
int eqpt(Point, Point);
|
||||
int eqrect(Rectangle, Rectangle);
|
||||
void fill(Image *dst, Rectangle, ulong col);
|
||||
void fillpoly(Image *dst, Point *pt, int np, ulong col);
|
||||
Window* findwin(XWindow);
|
||||
void freefont(Font*);
|
||||
void freeimage(Image *);
|
||||
void freestringlist(char**);
|
||||
ulong getproperty(Window *w, char *prop, char *type, Atom *actual, ulong offset, uchar **ret, ulong length);
|
||||
int gettextlistproperty(Window *w, char *name, char **ret[]);
|
||||
int grabpointer(Window*, Window *confine, Cursor, int mask);
|
||||
void initdisplay(void);
|
||||
uint labelh(Font*);
|
||||
Bool loadcolor(CTuple*, char*);
|
||||
Font* loadfont(char*);
|
||||
void lowerwin(Window*);
|
||||
int mapwin(Window*);
|
||||
void movewin(Window*, Point);
|
||||
Point mulpt(Point p, Point q);
|
||||
Bool namedcolor(char *name, ulong*);
|
||||
Point querypointer(Window*);
|
||||
void raisewin(Window*);
|
||||
void reparentwindow(Window*, Window*, Point);
|
||||
void reshapewin(Window*, Rectangle);
|
||||
void setfocus(Window*, int mode);
|
||||
void sethints(Window*);
|
||||
void setshapemask(Window *dst, Image *src, Point);
|
||||
void setwinattr(Window*, WinAttr*, int valmask);
|
||||
Point subpt(Point, Point);
|
||||
uint textwidth(Font*, char*);
|
||||
uint textwidth_l(Font*, char*, uint len);
|
||||
Point translate(Window*, Window*, Point);
|
||||
void ungrabpointer(void);
|
||||
int unmapwin(Window*);
|
||||
void warppointer(Point);
|
||||
uint winprotocols(Window*);
|
||||
Atom xatom(char*);
|
||||
Handlers* sethandler(Window*, Handlers*);
|
||||
XRectangle XRect(Rectangle);
|
||||
Rectangle gravitate(Rectangle dst, Rectangle src, Point grav);
|
||||
Rectangle insetrect(Rectangle, int);
|
||||
Rectangle rectaddpt(Rectangle, Point);
|
||||
Rectangle rectsubpt(Rectangle, Point);
|
||||
Rectangle sizehint(WinHints*, Rectangle);
|
||||
|
||||
char* toutf8n(char*, size_t);
|
||||
/* utf.c */
|
||||
char* toutf8(char*);
|
||||
char* toutf8n(char*, size_t);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
*/
|
||||
#include "dat.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "fns.h"
|
||||
|
||||
uint
|
||||
|
@ -337,13 +336,13 @@ swap_frames(Frame *fa, Frame *fb) {
|
|||
|
||||
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;
|
||||
*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;
|
||||
*fp = (*fp)->cnext;
|
||||
fp[0] = fp[0]->cnext;
|
||||
|
||||
c = fa->client;
|
||||
fa->client = fb->client;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
@ -185,8 +184,9 @@ write_buf(Ixp9Req *r, char *buf, uint len) {
|
|||
|
||||
/* This should be moved to libixp */
|
||||
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;
|
||||
char *p;
|
||||
|
||||
offset = (r->fid->omode&OAPPEND) ? *len : r->ifcall.offset;
|
||||
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;
|
||||
|
||||
*len = offset + count;
|
||||
if(max == 0)
|
||||
*buf = erealloc((void*)*buf, *len + 1);
|
||||
|
||||
if(max == 0) {
|
||||
*(void **)buf = erealloc(*(void **)buf, *len + 1);
|
||||
buf = *(void **)buf;
|
||||
}
|
||||
p = *buf;
|
||||
|
||||
memcpy((uchar*)buf + offset, r->ifcall.data, count);
|
||||
memcpy(p+offset, r->ifcall.data, count);
|
||||
r->ofcall.count = count;
|
||||
((char *)buf)[offset+count] = '\0';
|
||||
p[offset+count] = '\0';
|
||||
}
|
||||
|
||||
/* This should be moved to libixp */
|
||||
|
@ -583,7 +582,7 @@ fs_stat(Ixp9Req *r) {
|
|||
m = ixp_message(buf, size, MsgPack);
|
||||
ixp_pstat(&m, &s);
|
||||
|
||||
r->ofcall.stat = m.data;
|
||||
r->ofcall.stat = (uchar*)m.data;
|
||||
respond(r, nil);
|
||||
}
|
||||
|
||||
|
@ -701,6 +700,7 @@ void
|
|||
fs_write(Ixp9Req *r) {
|
||||
FileId *f;
|
||||
char *errstr;
|
||||
char *p;
|
||||
uint i;
|
||||
|
||||
if(r->ifcall.count == 0) {
|
||||
|
@ -740,7 +740,9 @@ fs_write(Ixp9Req *r) {
|
|||
return;
|
||||
case FsFBar:
|
||||
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;
|
||||
respond(r, nil);
|
||||
return;
|
||||
|
@ -761,9 +763,9 @@ fs_write(Ixp9Req *r) {
|
|||
return;
|
||||
case FsFEvent:
|
||||
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
|
||||
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;
|
||||
respond(r, nil);
|
||||
return;
|
||||
|
@ -907,10 +909,10 @@ fs_clunk(Ixp9Req *r) {
|
|||
draw_bar(screen);
|
||||
break;
|
||||
case FsFEvent:
|
||||
for(fl=&peventfid; *fl; fl=&(*fl)->next)
|
||||
if((*fl)->fid == r->fid) {
|
||||
ft = *fl;
|
||||
*fl = (*fl)->next;
|
||||
for(fl=&peventfid; *fl; fl=&fl[0]->next)
|
||||
if(fl[0]->fid == r->fid) {
|
||||
ft = fl[0];
|
||||
fl[0] = fl[0]->next;
|
||||
f = ft->fid->aux;
|
||||
free(f->p.buf);
|
||||
free(ft);
|
||||
|
@ -926,9 +928,9 @@ fs_flush(Ixp9Req *r) {
|
|||
Ixp9Req **i, **j;
|
||||
|
||||
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) {
|
||||
*j = (*j)->aux;
|
||||
j[0] = j[0]->aux;
|
||||
respond(r->oldreq, Einterrupted);
|
||||
goto done;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* See LICENSE file for license details.
|
||||
*/
|
||||
#include "dat.h"
|
||||
#include <stdio.h>
|
||||
#include "fns.h"
|
||||
|
||||
Bool
|
||||
|
|
179
cmd/wmii/main.c
179
cmd/wmii/main.c
|
@ -2,14 +2,15 @@
|
|||
* Copyright ©2006-2007 Kris Maglione <fbsdaemon@gmail.com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#define EXTERN
|
||||
#include "dat.h"
|
||||
#include <X11/Xproto.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <locale.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -17,12 +18,14 @@
|
|||
#include <unistd.h>
|
||||
#include "fns.h"
|
||||
|
||||
enum { false, true };
|
||||
|
||||
static const char
|
||||
version[] = "wmii-"VERSION", ©2007 Kris Maglione\n";
|
||||
|
||||
static int (*xlib_errorhandler) (Display*, XErrorEvent*);
|
||||
static char *address, *ns_path;
|
||||
static Bool check_other_wm;
|
||||
static int check_other_wm;
|
||||
static struct sigaction sa;
|
||||
static struct passwd *passwd;
|
||||
static int sleeperfd, sock, exitsignal;
|
||||
|
@ -88,20 +91,21 @@ ns_display(void) {
|
|||
|
||||
static void
|
||||
rmkdir(char *path, int mode) {
|
||||
char *p, *q;
|
||||
char *p;
|
||||
int ret;
|
||||
char c;
|
||||
|
||||
q = path + strlen(ns_path);
|
||||
for(p = &path[1]; p <= q; p++) {
|
||||
for(p = path+1; ; p++) {
|
||||
c = *p;
|
||||
if((c == '/') || (c == '\0')) {
|
||||
*p = '\0';
|
||||
ret = mkdir(path, mode);
|
||||
if((ret == -1) && (errno != EEXIST))
|
||||
fatal("Can't create ns_path '%s': %r", path);
|
||||
fatal("Can't create path '%s': %r", path);
|
||||
*p = c;
|
||||
}
|
||||
if(c == '\0')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +125,7 @@ init_ns(void) {
|
|||
else
|
||||
ns_path = ns_display();
|
||||
|
||||
if((ns_path[0] != '/') || (strlen(ns_path) == 0))
|
||||
if(ns_path[0] != '/' || ns_path[0] == '\0')
|
||||
fatal("Bad ns_path");
|
||||
|
||||
rmkdir(ns_path, 0700);
|
||||
|
@ -138,10 +142,8 @@ static void
|
|||
init_environment(void) {
|
||||
init_ns();
|
||||
|
||||
if(address == nil) {
|
||||
address = emalloc(strlen(ns_path) + strlen("unix!/wmii") + 1);
|
||||
sprint(address, "unix!%s/wmii", ns_path);
|
||||
}
|
||||
if(address == nil)
|
||||
address = smprint("unix!%s/wmii", ns_path);
|
||||
|
||||
setenv("WMII_NS_DIR", ns_path, True);
|
||||
setenv("WMII_ADDRESS", address, True);
|
||||
|
@ -195,23 +197,6 @@ init_screen(WMScreen *screen) {
|
|||
XWindow w;
|
||||
int ret;
|
||||
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;
|
||||
def.snap = Dy(scr.rect) / 63;
|
||||
|
@ -250,9 +235,9 @@ struct {
|
|||
*/
|
||||
static int
|
||||
errorhandler(Display *dpy, XErrorEvent *error) {
|
||||
static Bool dead;
|
||||
static int dead;
|
||||
int i;
|
||||
|
||||
|
||||
USED(dpy);
|
||||
|
||||
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",
|
||||
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++)
|
||||
cleanup();
|
||||
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
|
||||
init_traps(void) {
|
||||
char buf[1];
|
||||
pid_t pid;
|
||||
int fd[2], status;
|
||||
int fd[2];
|
||||
|
||||
if(pipe(fd) != 0)
|
||||
fatal("Can't pipe(): %r");
|
||||
|
||||
/* Double fork hack */
|
||||
switch(pid = fork()) {
|
||||
case -1:
|
||||
fatal("Can't fork(): %r");
|
||||
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();
|
||||
if(doublefork() == 0) {
|
||||
close(fd[1]);
|
||||
close(ConnectionNumber(display));
|
||||
setsid();
|
||||
|
||||
display = XOpenDisplay(0);
|
||||
if(!display)
|
||||
fatal("Can't open display");
|
||||
display = XOpenDisplay(0);
|
||||
if(!display)
|
||||
fatal("Can't open display");
|
||||
|
||||
/* Wait for parent to exit */
|
||||
read(fd[0], buf, 1);
|
||||
/* Wait for parent to exit */
|
||||
read(fd[0], buf, 1);
|
||||
|
||||
XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XCloseDisplay(display);
|
||||
exit(0);
|
||||
default:
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
waitpid(pid, &status, 0);
|
||||
break;
|
||||
XSetInputFocus(display, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XCloseDisplay(display);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
close(fd[0]);
|
||||
|
@ -340,50 +336,28 @@ init_traps(void) {
|
|||
sigaction(SIGTERM, &sa, nil);
|
||||
sigaction(SIGQUIT, &sa, nil);
|
||||
sigaction(SIGHUP, &sa, nil);
|
||||
sigaction(SIGUSR1, &sa, nil);
|
||||
sigaction(SIGUSR2, &sa, nil);
|
||||
}
|
||||
|
||||
static void
|
||||
spawn_command(const char *cmd) {
|
||||
char *shell, *p;
|
||||
pid_t pid;
|
||||
int status;
|
||||
|
||||
/* Double fork hack */
|
||||
switch(pid = fork()) {
|
||||
case -1:
|
||||
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));
|
||||
if(doublefork() == 0) {
|
||||
if(setsid() == -1)
|
||||
fatal("Can't setsid: %r");
|
||||
|
||||
shell = passwd->pw_shell;
|
||||
if(shell[0] != '/')
|
||||
fatal("Shell is not an absolute path: %s", shell);
|
||||
shell = passwd->pw_shell;
|
||||
if(shell[0] != '/')
|
||||
fatal("Shell is not an absolute path: %s", shell);
|
||||
|
||||
/* Run through the user's shell as a login shell */
|
||||
p = malloc((strlen(shell) + 2));
|
||||
sprint(p, "-%s", strrchr(shell, '/') + 1);
|
||||
/* Run through the user's shell as a login shell */
|
||||
p = smprint("-%s", strrchr(shell, '/') + 1);
|
||||
|
||||
execl(shell, p, "-c", cmd, nil);
|
||||
fatal("Can't exec '%s': %r", cmd);
|
||||
break; /* Not reached */
|
||||
default:
|
||||
exit(0);
|
||||
break; /* Not reached */
|
||||
}
|
||||
default:
|
||||
waitpid(pid, &status, 0);
|
||||
/* if(status != 0)
|
||||
exit(1); */
|
||||
break;
|
||||
execl(shell, p, "-c", cmd, nil);
|
||||
fatal("Can't exec '%s': %r", cmd);
|
||||
/* Not reached */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,7 +392,7 @@ main(int argc, char *argv[]) {
|
|||
print("%s", version);
|
||||
exit(0);
|
||||
case 'V':
|
||||
verbose = True;
|
||||
verbose = true;
|
||||
break;
|
||||
case 'a':
|
||||
address = EARGF(usage());
|
||||
|
@ -438,16 +412,17 @@ main(int argc, char *argv[]) {
|
|||
starting = True;
|
||||
|
||||
initdisplay();
|
||||
closeexec(ConnectionNumber(display));
|
||||
|
||||
xlib_errorhandler = XSetErrorHandler(errorhandler);
|
||||
|
||||
check_other_wm = True;
|
||||
check_other_wm = true;
|
||||
XSelectInput(display, scr.root.w,
|
||||
SubstructureRedirectMask
|
||||
| EnterWindowMask);
|
||||
XSync(display, False);
|
||||
|
||||
check_other_wm = False;
|
||||
check_other_wm = false;
|
||||
|
||||
passwd = getpwuid(getuid());
|
||||
user = estrdup(passwd->pw_name);
|
||||
|
@ -457,6 +432,7 @@ main(int argc, char *argv[]) {
|
|||
sock = ixp_announce(address);
|
||||
if(sock < 0)
|
||||
fatal("Can't create socket '%s': %r", address);
|
||||
closeexec(sock);
|
||||
|
||||
if(wmiirc)
|
||||
spawn_command(wmiirc);
|
||||
|
@ -506,13 +482,12 @@ main(int argc, char *argv[]) {
|
|||
setfocus(screen->barwin, RevertToParent);
|
||||
|
||||
scan_wins();
|
||||
starting = False;
|
||||
starting = false;
|
||||
|
||||
select_view("nil");
|
||||
update_views();
|
||||
write_event("FocusTag %s\n", screen->sel->name);
|
||||
|
||||
check_x_event(nil);
|
||||
i = ixp_serverloop(&srv);
|
||||
if(i)
|
||||
fprint(2, "%s: error: %r\n", argv0);
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "dat.h"
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "fns.h"
|
||||
|
@ -119,7 +118,7 @@ eatrunes(IxpMsg *m, int (*p)(Rune), int val) {
|
|||
int n;
|
||||
|
||||
while(m->pos < m->end) {
|
||||
n = chartorune(&r, (char*)m->pos);
|
||||
n = chartorune(&r, m->pos);
|
||||
if(p(r) != val)
|
||||
break;
|
||||
m->pos += n;
|
||||
|
@ -135,14 +134,14 @@ getword(IxpMsg *m) {
|
|||
int n;
|
||||
|
||||
eatrunes(m, isspacerune, 1);
|
||||
ret = (char*)m->pos;
|
||||
ret = m->pos;
|
||||
eatrunes(m, isspacerune, 0);
|
||||
n = chartorune(&r, (char*)m->pos);
|
||||
n = chartorune(&r, m->pos);
|
||||
*m->pos = '\0';
|
||||
m->pos += n;
|
||||
eatrunes(m, isspacerune, 1);
|
||||
|
||||
if(ret == (char*)m->end)
|
||||
if(ret == m->end)
|
||||
return nil;
|
||||
return ret;
|
||||
}
|
||||
|
@ -165,7 +164,7 @@ getbase(char **s) {
|
|||
*s += 3;
|
||||
return 10*(p[0]-'0') + (p[1]-'0');
|
||||
}
|
||||
if(!strbcmp(p, "0")) {
|
||||
if(p[0] == '0') {
|
||||
*s += 1;
|
||||
return 8;
|
||||
}
|
||||
|
@ -220,10 +219,10 @@ strarea(View *v, char *s) {
|
|||
if(!getlong(s, &i) || i == 0)
|
||||
return nil;
|
||||
|
||||
if(i > 0)
|
||||
for(a = v->area; a; a = a->next) {
|
||||
if(i > 0) {
|
||||
for(a = v->area; a; a = a->next)
|
||||
if(i-- == 0) break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
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);
|
||||
case LCOLMODE:
|
||||
s = getword(m);
|
||||
if((a = strarea(v, s)) == nil || a->floating)
|
||||
a = strarea(v, s);
|
||||
if(a == nil || a->floating)
|
||||
return Ebadvalue;
|
||||
|
||||
s = getword(m);
|
||||
if((i = str2colmode(s)) == -1)
|
||||
i = str2colmode(s);
|
||||
if(i == -1)
|
||||
return Ebadvalue;
|
||||
|
||||
a->mode = i;
|
||||
|
@ -281,12 +282,12 @@ parse_colors(IxpMsg *m, CTuple *col) {
|
|||
int i, j;
|
||||
|
||||
/* '#%6x #%6x #%6x' */
|
||||
p = (char*)m->pos;
|
||||
for(i = 0; i < 3 && p < (char*)m->end; i++) {
|
||||
p = m->pos;
|
||||
for(i = 0; i < 3 && p < m->end; i++) {
|
||||
if(*p++ != '#')
|
||||
return Ebad;
|
||||
for(j = 0; j < 6 && p < (char*)m->end; j++)
|
||||
if(!isxdigit(*p++))
|
||||
for(j = 0; j < 6; j++)
|
||||
if(p >= m->end || !isxdigit(*p++))
|
||||
return Ebad;
|
||||
|
||||
chartorune(&r, p);
|
||||
|
@ -294,16 +295,16 @@ parse_colors(IxpMsg *m, CTuple *col) {
|
|||
if(r != ' ')
|
||||
return Ebad;
|
||||
p++;
|
||||
}else if(!isspacerune(r) && *p != '\0')
|
||||
}else if(*p != '\0' && !isspacerune(r))
|
||||
return Ebad;
|
||||
}
|
||||
|
||||
c = *p;
|
||||
*p = '\0';
|
||||
loadcolor(col, (char*)m->pos);
|
||||
loadcolor(col, m->pos);
|
||||
*p = c;
|
||||
|
||||
m->pos = (uchar*)p;
|
||||
m->pos = p;
|
||||
eatrunes(m, isspacerune, 1);
|
||||
return nil;
|
||||
}
|
||||
|
@ -323,11 +324,11 @@ message_root(void *p, IxpMsg *m) {
|
|||
srv.running = 0;
|
||||
break;
|
||||
case LEXEC:
|
||||
execstr = smprint("exec %s", (char*)m->pos);
|
||||
execstr = smprint("exec %s", m->pos);
|
||||
srv.running = 0;
|
||||
break;
|
||||
case LVIEW:
|
||||
select_view((char*)m->pos);
|
||||
select_view(m->pos);
|
||||
break;
|
||||
case LSELCOLORS:
|
||||
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);
|
||||
break;
|
||||
case LFONT:
|
||||
fn = loadfont((char*)m->pos);
|
||||
fn = loadfont(m->pos);
|
||||
if(fn) {
|
||||
freefont(def.font);
|
||||
def.font = fn;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "dat.h"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "fns.h"
|
||||
|
||||
|
@ -289,14 +288,9 @@ horiz:
|
|||
resize_frame(f->aprev, f->aprev->r);
|
||||
}
|
||||
|
||||
if (f->aprev || f->anext) {
|
||||
remove_frame(f);
|
||||
f->area = fw->ra;
|
||||
insert_frame(fw->fp, f);
|
||||
} else if (f->area != fw->ra) {
|
||||
detach_from_area(f);
|
||||
attach_to_area(fw->ra, f);
|
||||
}
|
||||
remove_frame(f);
|
||||
f->area = fw->ra;
|
||||
insert_frame(fw->fp, f);
|
||||
|
||||
if(f->aprev) {
|
||||
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;
|
||||
|
||||
if(align == CENTER && !opaque) {
|
||||
SET(hrx);
|
||||
SET(hry);
|
||||
d.x = (d.x * hrx) - pt.x;
|
||||
d.y = (d.y * hry) - pt.y;
|
||||
}else
|
||||
|
@ -766,10 +762,10 @@ do_mouse_resize(Client *c, Bool opaque, Align align) {
|
|||
frect = constrain(frect);
|
||||
|
||||
//reshapewin(c->framewin, frect);
|
||||
resize_client(c, &frect);
|
||||
resize_client(c, frect);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
resize_client(c, &frect);
|
||||
resize_client(c, frect);
|
||||
|
||||
if(!opaque) {
|
||||
pt = translate(c->framewin, &scr.root,
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
|
||||
#include "dat.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <bio.h>
|
||||
|
@ -96,13 +95,13 @@ unmask(Pair * list, uint val)
|
|||
|
||||
static char *
|
||||
strhex(int key) {
|
||||
sprintf(buffer, "0x%x", key);
|
||||
sprint(buffer, "0x%x", key);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static char *
|
||||
strdec(int key) {
|
||||
sprintf(buffer, "%d", key);
|
||||
sprint(buffer, "%d", key);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -656,14 +655,13 @@ VerbFocus(XEvent *e) {
|
|||
static void
|
||||
VerbKeymap(XEvent *e) {
|
||||
XKeymapEvent *ev = &e->xkeymap;
|
||||
int i;
|
||||
|
||||
int i;
|
||||
|
||||
fprintf(stderr, "window=0x%x%s", (int)ev->window, sep);
|
||||
fprintf(stderr, "key_vector=");
|
||||
fprint(2, "window=0x%x%s", (int)ev->window, sep);
|
||||
fprint(2, "key_vector=");
|
||||
for (i = 0; i < 32; i++)
|
||||
fprintf(stderr, "%02x", ev->key_vector[i]);
|
||||
fprintf(stderr, "\n");
|
||||
fprint(2, "%02x", ev->key_vector[i]);
|
||||
fprint(2, "\n");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -935,7 +933,6 @@ VerbVisibility(XEvent *e) {
|
|||
/******************************************************************************/
|
||||
|
||||
typedef struct Handler Handler;
|
||||
|
||||
struct Handler {
|
||||
int key;
|
||||
void (*fn)(XEvent*);
|
||||
|
@ -945,9 +942,9 @@ void
|
|||
printevent(XEvent *e) {
|
||||
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)
|
||||
fprintf(stderr, "(sendevent) ");
|
||||
fprint(2, "(sendevent) ");
|
||||
/*
|
||||
fprintf(stderr, "type=%s%s", eventtype(e->xany.type), sep);
|
||||
fprintf(stderr, "serial=%lu%s", ev->serial, sep);
|
||||
|
|
|
@ -20,14 +20,15 @@ enum {
|
|||
void
|
||||
trim(char *str, const char *chars) {
|
||||
const char *cp;
|
||||
char *sp, *sn;
|
||||
char *p, *q;
|
||||
char c;
|
||||
|
||||
for(cp = chars; *cp; cp++) {
|
||||
for(sp = sn = str; *sn; sn++) {
|
||||
if(*sn != *cp)
|
||||
*(sp++) = *sn;
|
||||
}
|
||||
*sp = 0;
|
||||
for(cp = chars; (c = *cp); cp++) {
|
||||
q = str;
|
||||
for(p = q; *p; p++)
|
||||
if(*p != c)
|
||||
*q++ = *p;
|
||||
*q = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
*/
|
||||
#include "dat.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "fns.h"
|
||||
|
||||
|
@ -134,7 +133,7 @@ focus_view(WMScreen *s, View *v) {
|
|||
for(c=client; c; c=c->next)
|
||||
if((f = c->sel)) {
|
||||
if(f->view == v)
|
||||
resize_client(c, &f->r);
|
||||
resize_client(c, f->r);
|
||||
else {
|
||||
unmap_frame(c);
|
||||
unmap_client(c, IconicState);
|
||||
|
@ -188,15 +187,15 @@ restack_view(View *v) {
|
|||
Frame *f;
|
||||
Client *c;
|
||||
Area *a;
|
||||
uint n, i;
|
||||
uint n, i, fscrn;
|
||||
|
||||
if(v != screen->sel)
|
||||
return;
|
||||
|
||||
i = 0;
|
||||
i = 1;
|
||||
for(c = client; c; c = c->next)
|
||||
i++;
|
||||
if(i == 0)
|
||||
if(i == 1)
|
||||
return;
|
||||
|
||||
for(a = v->area; a; a = a->next)
|
||||
|
@ -208,16 +207,21 @@ restack_view(View *v) {
|
|||
}
|
||||
|
||||
n = 0;
|
||||
fscrn = 0;
|
||||
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) {
|
||||
n--;
|
||||
fscrn++;
|
||||
break;
|
||||
}
|
||||
|
||||
for(f=v->area->stack; f; f=f->snext)
|
||||
wins[n++] = f->client->framewin->w;
|
||||
|
||||
if(fscrn)
|
||||
wins[n++] = screen->barwin->w;
|
||||
|
||||
for(d = divs; d && d->w->mapped; d = d->next)
|
||||
wins[n++] = d->w->w;
|
||||
|
||||
|
@ -228,10 +232,8 @@ restack_view(View *v) {
|
|||
if(f != a->sel)
|
||||
wins[n++] = f->client->framewin->w;
|
||||
}
|
||||
if(n) {
|
||||
XRaiseWindow(display, wins[0]);
|
||||
if(n)
|
||||
XRestackWindows(display, wins, n);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -269,10 +271,10 @@ scale_view(View *v, int w) {
|
|||
if(numcol * minwidth > w)
|
||||
return;
|
||||
|
||||
dx = numcol * minwidth;
|
||||
xoff = 0;
|
||||
for(a=v->area->next, numcol--; a; a=a->next, numcol--) {
|
||||
a->r.min.x = xoff;
|
||||
dx = numcol * minwidth;
|
||||
|
||||
if(Dx(a->r) < minwidth)
|
||||
a->r.max.x = xoff + minwidth;
|
||||
|
@ -328,14 +330,13 @@ rects_of_view(View *v, uint *num, Frame *ignore) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/* XXX: This will need cleanup */
|
||||
uchar *
|
||||
view_index(View *v) {
|
||||
Rectangle *r;
|
||||
Frame *f;
|
||||
Area *a;
|
||||
char *buf, *end;
|
||||
uint i;
|
||||
int i;
|
||||
|
||||
buf = buffer;
|
||||
end = buffer+sizeof(buffer)-1;
|
||||
|
@ -396,20 +397,20 @@ view_ctl(View *v) {
|
|||
void
|
||||
update_views(void) {
|
||||
View *n, *v, *old;
|
||||
Bool found;
|
||||
int found;
|
||||
|
||||
old = screen->sel;
|
||||
for(v=view; v; v=v->next)
|
||||
update_frame_selectors(v);
|
||||
|
||||
found = False;
|
||||
found = 0;
|
||||
for(v=view; v; v=n) {
|
||||
n=v->next;
|
||||
if(v != old) {
|
||||
if(is_empty(v))
|
||||
destroy_view(v);
|
||||
else
|
||||
found = True;
|
||||
found++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* Copyright ©2007 Kris Maglione <fbsdaemon@gmail.com>
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
#define _X11_VISIBLE
|
||||
#include "dat.h"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <bio.h>
|
||||
|
@ -122,8 +122,7 @@ Wfmt(Fmt *f) {
|
|||
/* Init */
|
||||
void
|
||||
initdisplay(void) {
|
||||
if(!(display = XOpenDisplay(nil)))
|
||||
fatal("couldn't open display");
|
||||
display = XOpenDisplay(nil);
|
||||
scr.screen = DefaultScreen(display);
|
||||
scr.colormap = DefaultColormap(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;
|
||||
}
|
||||
|
||||
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
|
||||
gettextlistproperty(Window *w, char *name, char **ret[]) {
|
||||
XTextProperty prop;
|
||||
|
@ -662,11 +682,7 @@ gettextproperty(Window *w, char *name) {
|
|||
|
||||
void
|
||||
setfocus(Window *w, int mode) {
|
||||
if(w) {
|
||||
XSetInputFocus(display, w->w, mode, CurrentTime);
|
||||
} else { /* "relinquish" focus */
|
||||
XSetInputFocus(display, PointerRoot, mode, CurrentTime);
|
||||
}
|
||||
XSetInputFocus(display, w->w, mode, CurrentTime);
|
||||
}
|
||||
|
||||
/* Mouse */
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
#define Screen XScreen
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/extensions/shape.h>
|
||||
#ifdef _X11_VISIBLE
|
||||
# include <X11/Xatom.h>
|
||||
# include <X11/extensions/shape.h>
|
||||
#endif
|
||||
#undef Window
|
||||
#undef Font
|
||||
#undef Screen
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh -f
|
||||
RC=""
|
||||
IFS=:
|
||||
for i in "$PLAN9" `echo "P9PATHS"`; do
|
||||
for i in "$PLAN9" `echo P9PATHS`; do
|
||||
if [ -d "$i" -a -x "$i/bin/rc" ]; then
|
||||
export PLAN9="$i"
|
||||
RC="$i/bin/rc"
|
||||
|
@ -9,10 +9,14 @@ for i in "$PLAN9" `echo "P9PATHS"`; do
|
|||
fi
|
||||
done
|
||||
|
||||
if [ ! -n "$RC" ]; then
|
||||
if [ -n "$RC" ]; then
|
||||
exit 1
|
||||
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
|
||||
exec "$RC" "$@"
|
||||
else
|
||||
|
|
44
cmd/wmiir.c
44
cmd/wmiir.c
|
@ -17,9 +17,9 @@ static IxpClient *client;
|
|||
static void
|
||||
usage(void) {
|
||||
fprint(1,
|
||||
"usage: %1$s [-a <address>] {create | read | ls [-ld] | remove | rm | write} <file>\n"
|
||||
" %1$s [-a <address>] xwrite <file> <data>\n"
|
||||
" %1$s -v\n", argv0);
|
||||
"usage: %s [-a <address>] {create | read | ls [-ld] | remove | rm | write} <file>\n"
|
||||
" %s [-a <address>] xwrite <file> <data>\n"
|
||||
" %s -v\n", argv0, argv0, argv0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -185,6 +185,7 @@ xcreate(int argc, char *argv[]) {
|
|||
static int
|
||||
xremove(int argc, char *argv[]) {
|
||||
char *file;
|
||||
int n;
|
||||
|
||||
ARGBEGIN{
|
||||
default:
|
||||
|
@ -192,8 +193,12 @@ xremove(int argc, char *argv[]) {
|
|||
}ARGEND;
|
||||
|
||||
file = EARGF(usage());
|
||||
if(ixp_remove(client, file) == 0)
|
||||
fatal("Can't remove file '%s': %r\n", file);
|
||||
do {
|
||||
if(ixp_remove(client, file) == 0) {
|
||||
fprint(2, "%s: Can't remove file '%s': %r\n", argv0, file);
|
||||
n++;
|
||||
}
|
||||
}while((file = ARGF()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -208,18 +213,22 @@ xread(int argc, char *argv[]) {
|
|||
usage();
|
||||
}ARGEND;
|
||||
|
||||
if(argc == 0)
|
||||
usage();
|
||||
file = EARGF(usage());
|
||||
fid = ixp_open(client, file, P9_OREAD);
|
||||
if(fid == nil)
|
||||
fatal("Can't open file '%s': %r\n", file);
|
||||
do {
|
||||
fid = ixp_open(client, file, P9_OREAD);
|
||||
if(fid == nil)
|
||||
fatal("Can't open file '%s': %r\n", file);
|
||||
|
||||
buf = emalloc(fid->iounit);
|
||||
while((count = ixp_read(fid, buf, fid->iounit)) > 0)
|
||||
write(1, buf, count);
|
||||
ixp_close(fid);
|
||||
buf = emalloc(fid->iounit);
|
||||
while((count = ixp_read(fid, buf, fid->iounit)) > 0)
|
||||
write(1, buf, count);
|
||||
ixp_close(fid);
|
||||
|
||||
if(count == -1)
|
||||
fatal("cannot read file/directory '%s': %r\n", file);
|
||||
if(count == -1)
|
||||
fprint(2, "%s: cannot read file/directory '%s': %r\n", argv0, file);
|
||||
}while((file = ARGF()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -299,6 +308,7 @@ struct exectab {
|
|||
{"write", xwrite},
|
||||
{"xwrite", xawrite},
|
||||
{"read", xread},
|
||||
{"cat", xread},
|
||||
{"create", xcreate},
|
||||
{"remove", xremove},
|
||||
{"rm", xremove},
|
||||
|
@ -308,7 +318,7 @@ struct exectab {
|
|||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
char *cmd, *address;
|
||||
char *address;
|
||||
exectab *tab;
|
||||
int ret;
|
||||
|
||||
|
@ -327,8 +337,6 @@ main(int argc, char *argv[]) {
|
|||
usage();
|
||||
}ARGEND;
|
||||
|
||||
cmd = EARGF(usage());
|
||||
|
||||
if(!address)
|
||||
fatal("$WMII_ADDRESS not set\n");
|
||||
|
||||
|
@ -337,7 +345,7 @@ main(int argc, char *argv[]) {
|
|||
fatal("can't mount: %r\n");
|
||||
|
||||
for(tab = etab; tab->cmd; tab++)
|
||||
if(strcmp(cmd, tab->cmd) == 0) break;
|
||||
if(strcmp(*argv, tab->cmd) == 0) break;
|
||||
if(tab->cmd == 0)
|
||||
usage();
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#!/bin/sh -f
|
||||
# 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
|
||||
WMIIRC=`PATH="$WMII_CONFPATH:$PATH" which rc.wmii`
|
||||
|
@ -9,5 +14,6 @@ else
|
|||
WMIIRC=`PATH="$WMII_CONFPATH:$PATH" which wmiirc`
|
||||
fi
|
||||
|
||||
mkdir $HOME/.wmii-CONFVERSION 2>/dev/null && CONFPREFIX/wmii-CONFVERSION/welcome &
|
||||
exec "$WMIIRC" $@
|
||||
mkdir $conf 2>/dev/null && $gconf/welcome &
|
||||
exec "$WMIIRC" "$@"
|
||||
|
||||
|
|
|
@ -9,9 +9,10 @@ iconscale = `{*=$epsbox; hoc -e $iconwidth/'('$3-' '$1')'}
|
|||
iconheight = `{*=$epsbox; hoc -e '('$4-' '$2')*'$iconscale}
|
||||
|
||||
icon.png: $eps
|
||||
x = `{hoc -e -'('$epsbox(1)^')'}
|
||||
y = `{hoc -e -'('$epsbox(2)^')'}
|
||||
gs -q -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=$target -g^$iconwidth^x^$iconheight - <<!
|
||||
* = `{hoc -e'-('$epsbox')'}
|
||||
x = $1
|
||||
y = $2
|
||||
gs -q -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=$target -g$iconwidth'x'$iconheight - <<!
|
||||
$iconscale $iconscale scale
|
||||
$x $y translate
|
||||
($eps) run
|
||||
|
|
|
@ -108,41 +108,41 @@ extern int (*fmtdoquote)(int);
|
|||
#endif
|
||||
|
||||
/* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/fmt/?*.c | grep -v static |grep -v __ */
|
||||
int dofmt(Fmt *f, const char *fmt);
|
||||
int dorfmt(Fmt *f, const Rune *fmt);
|
||||
double fmtcharstod(int(*f)(void*), void *vp);
|
||||
int fmtfdflush(Fmt *f);
|
||||
int fmtfdinit(Fmt *f, int fd, char *buf, int size);
|
||||
int fmtinstall(int c, int (*f)(Fmt*));
|
||||
int fmtprint(Fmt *f, const char *fmt, ...);
|
||||
int fmtrune(Fmt *f, int r);
|
||||
int fmtrunestrcpy(Fmt *f, Rune *s);
|
||||
int fmtstrcpy(Fmt *f, const char *s);
|
||||
char* fmtstrflush(Fmt *f);
|
||||
int fmtstrinit(Fmt *f);
|
||||
double fmtstrtod(const char *as, char **aas);
|
||||
int fmtvprint(Fmt *f, const char *fmt, va_list args);
|
||||
int fprint(int fd, const char *fmt, ...);
|
||||
int print(const char *fmt, ...);
|
||||
int dofmt(Fmt*, const char *fmt);
|
||||
int dorfmt(Fmt*, const Rune *fmt);
|
||||
double fmtcharstod(int(*f)(void*), void*);
|
||||
int fmtfdflush(Fmt*);
|
||||
int fmtfdinit(Fmt*, int fd, char *buf, int size);
|
||||
int fmtinstall(int, int (*f)(Fmt*));
|
||||
int fmtprint(Fmt*, const char*, ...);
|
||||
int fmtrune(Fmt*, int);
|
||||
int fmtrunestrcpy(Fmt*, Rune*);
|
||||
int fmtstrcpy(Fmt*, const char*);
|
||||
char* fmtstrflush(Fmt*);
|
||||
int fmtstrinit(Fmt*);
|
||||
double fmtstrtod(const char*, char**);
|
||||
int fmtvprint(Fmt*, const char*, va_list);
|
||||
int fprint(int, const char*, ...);
|
||||
int print(const char*, ...);
|
||||
void quotefmtinstall(void);
|
||||
int quoterunestrfmt(Fmt *f);
|
||||
int quotestrfmt(Fmt *f);
|
||||
Rune* runefmtstrflush(Fmt *f);
|
||||
int runefmtstrinit(Fmt *f);
|
||||
Rune* runeseprint(Rune *buf, Rune *e, const char *fmt, ...);
|
||||
Rune* runesmprint(const char *fmt, ...);
|
||||
int runesnprint(Rune *buf, int len, const char *fmt, ...);
|
||||
int runesprint(Rune *buf, const char *fmt, ...);
|
||||
Rune* runevseprint(Rune *buf, Rune *e, const char *fmt, va_list args);
|
||||
Rune* runevsmprint(const char *fmt, va_list args);
|
||||
int runevsnprint(Rune *buf, int len, const char *fmt, va_list args);
|
||||
char* seprint(char *buf, char *e, const char *fmt, ...);
|
||||
char* smprint(const char *fmt, ...);
|
||||
int snprint(char *buf, int len, const char *fmt, ...);
|
||||
int sprint(char *buf, const char *fmt, ...);
|
||||
int vfprint(int fd, const char *fmt, va_list args);
|
||||
char* vseprint(char *buf, char *e, const char *fmt, va_list args);
|
||||
char* vsmprint(const char *fmt, va_list args);
|
||||
int vsnprint(char *buf, int len, const char *fmt, va_list args);
|
||||
int quoterunestrfmt(Fmt*);
|
||||
int quotestrfmt(Fmt*);
|
||||
Rune* runefmtstrflush(Fmt*);
|
||||
int runefmtstrinit(Fmt*);
|
||||
Rune* runeseprint(Rune*,Rune*, const char*, ...);
|
||||
Rune* runesmprint(const char*, ...);
|
||||
int runesnprint(Rune*, int, const char*, ...);
|
||||
int runesprint(Rune*, const char*, ...);
|
||||
Rune* runevseprint(Rune*, Rune *, const char*, va_list);
|
||||
Rune* runevsmprint(const char*, va_list);
|
||||
int runevsnprint(Rune*, int, const char*, va_list);
|
||||
char* seprint(char*, char*, const char*, ...);
|
||||
char* smprint(const char*, ...);
|
||||
int snprint(char*, int, const char *, ...);
|
||||
int sprint(char*, const char*, ...);
|
||||
int vfprint(int, const char*, va_list);
|
||||
char* vseprint(char*, char*, const char*, va_list);
|
||||
char* vsmprint(const char*, va_list);
|
||||
int vsnprint(char*, int, const char*, va_list);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,11 +9,12 @@
|
|||
# ifndef USED
|
||||
# define USED(x) if(x);else
|
||||
# endif
|
||||
# define uchar _p9uchar
|
||||
# define ushort _p9ushort
|
||||
# define uint _p9uint
|
||||
# define ulong _p9ulong
|
||||
#endif
|
||||
|
||||
#define uchar _p9uchar
|
||||
#define ushort _p9ushort
|
||||
#define uint _p9uint
|
||||
#define ulong _p9ulong
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
|
|
|
@ -16,13 +16,11 @@ typedef struct Reprog Reprog;
|
|||
* Sub expression matches
|
||||
*/
|
||||
struct Resub{
|
||||
union
|
||||
{
|
||||
union {
|
||||
char *sp;
|
||||
Rune *rsp;
|
||||
}s;
|
||||
union
|
||||
{
|
||||
union {
|
||||
char *ep;
|
||||
Rune *rep;
|
||||
}e;
|
||||
|
|
|
@ -14,34 +14,34 @@ enum
|
|||
/* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/utf/?*.c | grep -v static |grep -v __ */
|
||||
int chartorune(Rune *rune, const char *str);
|
||||
int fullrune(const char *str, int n);
|
||||
int isalpharune(Rune c);
|
||||
int islowerrune(Rune c);
|
||||
int isspacerune(Rune c);
|
||||
int istitlerune(Rune c);
|
||||
int isupperrune(Rune c);
|
||||
int runelen(long c);
|
||||
int runenlen(Rune *r, int nrune);
|
||||
Rune* runestrcat(Rune *s1, Rune *s2);
|
||||
Rune* runestrchr(Rune *s, Rune c);
|
||||
int runestrcmp(Rune *s1, Rune *s2);
|
||||
Rune* runestrcpy(Rune *s1, Rune *s2);
|
||||
Rune* runestrdup(Rune *s) ;
|
||||
Rune* runestrecpy(Rune *s1, Rune *es1, Rune *s2);
|
||||
long runestrlen(Rune *s);
|
||||
Rune* runestrncat(Rune *s1, Rune *s2, long n);
|
||||
int runestrncmp(Rune *s1, Rune *s2, long n);
|
||||
Rune* runestrncpy(Rune *s1, Rune *s2, long n);
|
||||
Rune* runestrrchr(Rune *s, Rune c);
|
||||
Rune* runestrstr(Rune *s1, Rune *s2);
|
||||
int runetochar(char *str, Rune *rune);
|
||||
Rune tolowerrune(Rune c);
|
||||
Rune totitlerune(Rune c);
|
||||
Rune toupperrune(Rune c);
|
||||
char* utfecpy(char *to, char *e, const char *from);
|
||||
int utflen(const char *s);
|
||||
int utfnlen(const char *s, long m);
|
||||
char* utfrrune(const char *s, long c);
|
||||
char* utfrune(const char *s, long c);
|
||||
char* utfutf(const char *s1, const char *s2);
|
||||
int isalpharune(Rune);
|
||||
int islowerrune(Rune);
|
||||
int isspacerune(Rune);
|
||||
int istitlerune(Rune);
|
||||
int isupperrune(Rune);
|
||||
int runelen(Rune);
|
||||
int runenlen(const Rune*, int);
|
||||
Rune* runestrcat(Rune*, const Rune*);
|
||||
Rune* runestrchr(const Rune*, Rune);
|
||||
int runestrcmp(const Rune*, const Rune*);
|
||||
Rune* runestrcpy(Rune*, const Rune*);
|
||||
Rune* runestrdup(const Rune*) ;
|
||||
Rune* runestrecpy(Rune*, Rune *e, const Rune*);
|
||||
long runestrlen(const Rune*);
|
||||
Rune* runestrncat(Rune*, const Rune*, long);
|
||||
int runestrncmp(const Rune*, const Rune*, long);
|
||||
Rune* runestrncpy(Rune*, const Rune*, long);
|
||||
Rune* runestrrchr(const Rune*, Rune);
|
||||
Rune* runestrstr(const Rune*, const Rune*);
|
||||
int runetochar(char*, const Rune*);
|
||||
Rune tolowerrune(Rune);
|
||||
Rune totitlerune(Rune);
|
||||
Rune toupperrune(Rune);
|
||||
char* utfecpy(char*, char*, const char*);
|
||||
int utflen(const char*);
|
||||
int utfnlen(const char*, long);
|
||||
char* utfrrune(const char*, long);
|
||||
char* utfrune(const char*, long);
|
||||
char* utfutf(const char*, const char*);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,63 +8,65 @@
|
|||
#undef ulong
|
||||
#undef uvlong
|
||||
#undef vlong
|
||||
#ifndef KENC
|
||||
# define uchar _wmiiuchar
|
||||
# define ushort _wmiiushort
|
||||
# define uint _wmiiuint
|
||||
# define ulong _wmiiulong
|
||||
# define vlong _wmiivlong
|
||||
# define uvlong _wmiiuvlong
|
||||
#endif
|
||||
#define uchar _x_uchar
|
||||
#define ushort _x_ushort
|
||||
#define uint _x_uint
|
||||
#define ulong _x_ulong
|
||||
#define uvlong _x_uvlong
|
||||
#define vlong _x_vlong
|
||||
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned long ulong;
|
||||
typedef unsigned long long uvlong;
|
||||
typedef long long vlong;
|
||||
|
||||
typedef long long vlong;
|
||||
|
||||
#define strlcat wmii_strlcat
|
||||
/* util.c */
|
||||
uint tokenize(char *res[], uint reslen, char *str, char delim);
|
||||
char *estrdup(const char *str);
|
||||
void *erealloc(void *ptr, uint size);
|
||||
void *emallocz(uint size);
|
||||
void *emalloc(uint size);
|
||||
void fatal(const char *fmt, ...);
|
||||
int max(int a, int b);
|
||||
int min(int a, int b);
|
||||
char *str_nil(char *s);
|
||||
int utflcpy(char *to, const char *from, int l);
|
||||
uint strlcat(char *dst, const char *src, unsigned int siz);
|
||||
void* emalloc(uint);
|
||||
void* emallocz(uint);
|
||||
void* erealloc(void*, uint);
|
||||
char* estrdup(const char*);
|
||||
void fatal(const char*, ...);
|
||||
int max(int, int);
|
||||
int min(int, int);
|
||||
char* str_nil(char*);
|
||||
uint strlcat(char*, const char*, uint);
|
||||
uint tokenize(char **, uint, char*, char);
|
||||
int utflcpy(char*, const char*, int);
|
||||
|
||||
char *argv0;
|
||||
void *__p;
|
||||
int __i;
|
||||
#undef ARGBEGIN
|
||||
#undef ARGEND
|
||||
#undef ARGF
|
||||
#undef EARGF
|
||||
#define ARGBEGIN \
|
||||
int _argi=0, _argtmp=0, _inargv=0; char *_argv=nil; \
|
||||
if(!argv0) argv0=ARGF(); \
|
||||
int _argtmp=0, _inargv=0; char *_argv=nil; \
|
||||
if(!argv0) argv0=*argv; argv++, argc--; \
|
||||
_inargv=1; USED(_inargv); \
|
||||
while(argc && argv[0][0] == '-') { \
|
||||
_argi=1; _argv=*argv++; argc--; \
|
||||
while(_argv[_argi]) switch(_argv[_argi++])
|
||||
#define ARGEND }_inargv=0;USED(_argtmp);USED(_argv);USED(_argi);USED(_inargv)
|
||||
_argv=&argv[0][1]; argv++; argc--; \
|
||||
if(_argv[0] == '-' && _argv[1] == '\0') \
|
||||
break; \
|
||||
while(*_argv) switch(*_argv++)
|
||||
#define ARGEND }_inargv=0;USED(_argtmp, _argv, _inargv)
|
||||
|
||||
#define ARGF() ((_inargv && _argv[_argi]) ? \
|
||||
(_argtmp=_argi, _argi=strlen(_argv), __i=_argi,_argv+_argtmp) \
|
||||
: ((argc > 0) ? (--argc, ++argv, __i=argc, __p=argv, *(argv-1)) : ((char*)0)))
|
||||
|
||||
#define EARGF(f) ((_inargv && _argv[_argi]) ? \
|
||||
(_argtmp=_argi, _argi=strlen(_argv), __i=_argi, _argv+_argtmp) \
|
||||
: ((argc > 0) ? (--argc, ++argv, __i=argc, __p=argv, *(argv-1)) : ((f), (char*)0)))
|
||||
#define EARGF(f) ((_inargv && *_argv) ? \
|
||||
(_argtmp=strlen(_argv), _argv+=_argtmp, _argv-_argtmp) \
|
||||
: ((argc > 0) ? \
|
||||
(--argc, ++argv, _used(argc), *(argv-1)) \
|
||||
: ((f), (char*)0)))
|
||||
#define ARGF() EARGF(_used(0))
|
||||
|
||||
static inline void
|
||||
_used(long a, ...) {
|
||||
if(a){}
|
||||
}
|
||||
#ifndef KENC
|
||||
# undef USED
|
||||
# undef SET
|
||||
# define USED(x) if(x){}else
|
||||
# define SET(x) ((x)=0)
|
||||
# undef USED
|
||||
# undef SET
|
||||
# define USED(...) _used((long)__VA_ARGS__)
|
||||
# define SET(x) USED(&x)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ bad:
|
|||
}
|
||||
|
||||
int
|
||||
runetochar(char *str, Rune *rune)
|
||||
runetochar(char *str, const Rune *rune)
|
||||
{
|
||||
long c;
|
||||
|
||||
|
@ -132,17 +132,15 @@ runetochar(char *str, Rune *rune)
|
|||
}
|
||||
|
||||
int
|
||||
runelen(long c)
|
||||
runelen(Rune c)
|
||||
{
|
||||
Rune rune;
|
||||
char str[10];
|
||||
|
||||
rune = c;
|
||||
return runetochar(str, &rune);
|
||||
return runetochar(str, &c);
|
||||
}
|
||||
|
||||
int
|
||||
runenlen(Rune *r, int nrune)
|
||||
runenlen(const Rune *r, int nrune)
|
||||
{
|
||||
int nb, c;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <plan9.h>
|
||||
|
||||
Rune*
|
||||
runestrcat(Rune *s1, Rune *s2)
|
||||
runestrcat(Rune *s1, const Rune *s2)
|
||||
{
|
||||
|
||||
runestrcpy(runestrchr(s1, 0), s2);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "utf.h"
|
||||
|
||||
Rune*
|
||||
runestrchr(Rune *s, Rune c)
|
||||
runestrchr(const Rune *s, Rune c)
|
||||
{
|
||||
Rune c0 = c;
|
||||
Rune c1;
|
||||
|
@ -25,11 +25,11 @@ runestrchr(Rune *s, Rune c)
|
|||
if(c == 0) {
|
||||
while(*s++)
|
||||
;
|
||||
return s-1;
|
||||
return (Rune*)s-1;
|
||||
}
|
||||
|
||||
while(c1 = *s++)
|
||||
if(c1 == c0)
|
||||
return s-1;
|
||||
return (Rune*)s-1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "utf.h"
|
||||
|
||||
int
|
||||
runestrcmp(Rune *s1, Rune *s2)
|
||||
runestrcmp(const Rune *s1, const Rune *s2)
|
||||
{
|
||||
Rune c1, c2;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "utf.h"
|
||||
|
||||
Rune*
|
||||
runestrcpy(Rune *s1, Rune *s2)
|
||||
runestrcpy(Rune *s1, const Rune *s2)
|
||||
{
|
||||
Rune *os1;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <plan9.h>
|
||||
|
||||
Rune*
|
||||
runestrdup(Rune *s)
|
||||
runestrdup(const Rune *s)
|
||||
{
|
||||
Rune *ns;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "utf.h"
|
||||
|
||||
Rune*
|
||||
runestrecpy(Rune *s1, Rune *es1, Rune *s2)
|
||||
runestrecpy(Rune *s1, Rune *es1, const Rune *s2)
|
||||
{
|
||||
if(s1 >= es1)
|
||||
return s1;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <plan9.h>
|
||||
|
||||
long
|
||||
runestrlen(Rune *s)
|
||||
runestrlen(const Rune *s)
|
||||
{
|
||||
|
||||
return runestrchr(s, 0) - s;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "utf.h"
|
||||
|
||||
Rune*
|
||||
runestrncat(Rune *s1, Rune *s2, long n)
|
||||
runestrncat(Rune *s1, const Rune *s2, long n)
|
||||
{
|
||||
Rune *os1;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "utf.h"
|
||||
|
||||
int
|
||||
runestrncmp(Rune *s1, Rune *s2, long n)
|
||||
runestrncmp(const Rune *s1, const Rune *s2, long n)
|
||||
{
|
||||
Rune c1, c2;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "utf.h"
|
||||
|
||||
Rune*
|
||||
runestrncpy(Rune *s1, Rune *s2, long n)
|
||||
runestrncpy(Rune *s1, const Rune *s2, long n)
|
||||
{
|
||||
int i;
|
||||
Rune *os1;
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
#include "utf.h"
|
||||
|
||||
Rune*
|
||||
runestrrchr(Rune *s, Rune c)
|
||||
runestrrchr(const Rune *s, Rune c)
|
||||
{
|
||||
Rune *r;
|
||||
const Rune *r;
|
||||
|
||||
if(c == 0)
|
||||
return runestrchr(s, 0);
|
||||
r = 0;
|
||||
while(s = runestrchr(s, c))
|
||||
r = s++;
|
||||
return r;
|
||||
return (Rune*)r;
|
||||
}
|
||||
|
|
|
@ -21,14 +21,15 @@
|
|||
* 0 if none
|
||||
*/
|
||||
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;
|
||||
|
||||
c0 = *s2;
|
||||
if(c0 == 0)
|
||||
return s1;
|
||||
return (Rune*)s1;
|
||||
s2++;
|
||||
for(p=runestrchr(s1, c0); p; p=runestrchr(p+1, c0)) {
|
||||
pa = p;
|
||||
|
|
19
mk/gcc.mk
19
mk/gcc.mk
|
@ -1,17 +1,16 @@
|
|||
CFLAGS += \
|
||||
-std=c99 \
|
||||
-pipe \
|
||||
-pedantic \
|
||||
-Wall \
|
||||
-Wno-parentheses \
|
||||
-Wno-missing-braces \
|
||||
-Wno-switch \
|
||||
-Wno-comment \
|
||||
-Wno-sign-compare \
|
||||
-Wno-uninitialized \
|
||||
-Wno-unused-parameter \
|
||||
-Wimplicit \
|
||||
-Wreturn-type \
|
||||
-Wtrigraphs \
|
||||
-Wstrict-prototypes \
|
||||
-Wmissing-prototypes \
|
||||
-Wno-comment \
|
||||
-Wno-missing-braces \
|
||||
-Wno-parentheses \
|
||||
-Wno-sign-compare \
|
||||
-Wno-switch \
|
||||
-Wpointer-arith \
|
||||
-Wreturn-type \
|
||||
-Wstrict-prototypes \
|
||||
-Wtrigraphs \
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env wmii9rc
|
||||
# WMII Configuration
|
||||
|
||||
ifs='' {nl=`{echo}}
|
||||
|
||||
confpath=`{echo $WMII_CONFPATH | sed 'y/:/ /'}
|
||||
oldpath=$path
|
||||
path=($PLAN9/bin $path)
|
||||
|
@ -11,24 +13,6 @@ if(echo $0 | grep -s '(^|/)rc\.wmii\.local$') {
|
|||
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
|
||||
MODKEY=Mod1
|
||||
UP=k
|
||||
|
@ -37,8 +21,8 @@ LEFT=h
|
|||
RIGHT=l
|
||||
|
||||
WMII_FONT='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*'
|
||||
WMII_NORMCOLORS=('#888888' '#222222' '#333333')
|
||||
WMII_FOCUSCOLORS=('#ffffff' '#285577' '#4C7899')
|
||||
WMII_NORMCOLORS=('#222222' '#5FBF77' '#2A7F3F')
|
||||
WMII_FOCUSCOLORS=('#ffffff' '#153F1F' '#2A7F3F')
|
||||
WMII_BACKGROUND='#333333'
|
||||
|
||||
WMII_TERM=(xterm)
|
||||
|
@ -58,7 +42,6 @@ wmiir write /tagrules <<!
|
|||
|
||||
# Status Bar Info
|
||||
fn status { echo -n `{uptime | sed 's/.*://; s/,//g'} '|' `{date} }
|
||||
|
||||
fn viewtitle { echo $* }
|
||||
|
||||
# Convenience Functions
|
||||
|
@ -86,6 +69,11 @@ fn actionlist {
|
|||
} | sort | uniq
|
||||
}
|
||||
|
||||
fn config_whatis {
|
||||
prog = `{@{path=$confpath whatis $1} | grep -v '^fn|= ' || echo /dev/null}
|
||||
shift; echo $prog $*
|
||||
}
|
||||
|
||||
fn run_command { @{
|
||||
rfork ns
|
||||
path=$oldpath
|
||||
|
@ -93,9 +81,16 @@ fn run_command { @{
|
|||
}
|
||||
}
|
||||
|
||||
fn getfuns { env | sed -n 's/^fn#'^$1^'-([^=]+).*/\1/p' }
|
||||
fn initkeys { getfuns Key | wmiir write /keys }
|
||||
fn read_tags { wmiir ls /tag | sed 's,/,,; /^sel$/d' }
|
||||
fn getfuns {
|
||||
env | sed -n 's/^fn#'^$1^'-([^=]+).*/\1/p'
|
||||
}
|
||||
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 ' }
|
||||
|
||||
# Events
|
||||
|
@ -231,11 +226,11 @@ key Shift-$MODKEY-^`{seq 0 9} || fn $key {
|
|||
|
||||
# WM Configuration
|
||||
wmiir write /ctl <<!
|
||||
grabmod $MODKEY
|
||||
border 2
|
||||
font $WMII_FONT
|
||||
focuscolors $WMII_FOCUSCOLORS
|
||||
normcolors $WMII_NORMCOLORS
|
||||
grabmod $MODKEY
|
||||
border 2
|
||||
font $WMII_FONT
|
||||
focuscolors $WMII_FOCUSCOLORS
|
||||
normcolors $WMII_NORMCOLORS
|
||||
!
|
||||
xsetroot -solid $WMII_BACKGROUND
|
||||
|
||||
|
@ -252,9 +247,8 @@ Action status
|
|||
Action rehash
|
||||
|
||||
# Tag Bar Setup
|
||||
ifs='#
|
||||
'{ for(bar in `{comm -23 <{wmiir ls /lbar} <{read_tags}})
|
||||
wmiir remove /lbar/$bar
|
||||
ifs=$nl{
|
||||
wmiir rm `{comm -23 <{wmiir ls /lbar} <{read_tags}}
|
||||
seltag=`{wmiir read /tag/sel/ctl | sed 1q}
|
||||
for(tag in `{read_tags}) {
|
||||
if(~ $tag $seltag)
|
||||
|
@ -276,3 +270,4 @@ wmiir read /event |
|
|||
event = $1; shift
|
||||
Event-$event $*
|
||||
} >[2]/dev/null </dev/null
|
||||
|
||||
|
|
34
rc/wmiirc.sh
34
rc/wmiirc.sh
|
@ -9,15 +9,15 @@ LEFT=h
|
|||
RIGHT=l
|
||||
|
||||
# Colors tuples: "<text> <background> <border>"
|
||||
WMII_NORMCOLORS='#888888 #222222 #333333'
|
||||
WMII_FOCUSCOLORS='#ffffff #285577 #4c7899'
|
||||
WMII_NORMCOLORS='#222222 #5FBF77 #2A7F3F'
|
||||
WMII_FOCUSCOLORS='#ffffff #153F1F #2A7F3F'
|
||||
|
||||
WMII_BACKGROUND='#333333'
|
||||
WMII_FONT='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*'
|
||||
|
||||
set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS)
|
||||
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_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_TERM="xterm"
|
||||
|
||||
# Column Rules
|
||||
|
@ -40,7 +40,7 @@ status() {
|
|||
|
||||
# Event processing
|
||||
# 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() {
|
||||
cat <<'!'
|
||||
# Events
|
||||
|
@ -188,7 +188,7 @@ Action() {
|
|||
proglist() {
|
||||
paths=$(echo "$@" | sed 'y/:/ /')
|
||||
ls -lL $paths 2>/dev/null \
|
||||
| awk '$1 ~ /^[^d].*x/ && NF > 2 { print $NF }' \
|
||||
| awk '$1 ~ /^[^d].*x/ { print $NF }' \
|
||||
| sort | uniq
|
||||
}
|
||||
|
||||
|
@ -200,18 +200,14 @@ proglist $PATH >$progsfile &
|
|||
xsetroot -solid "$WMII_BACKGROUND" &
|
||||
|
||||
# Setup Tag Bar
|
||||
seltag="$(wmiir read /tag/sel/ctl 2>/dev/null)"
|
||||
wmiir ls /lbar |
|
||||
while read bar; do
|
||||
wmiir remove "/lbar/$bar"
|
||||
done
|
||||
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"
|
||||
(IFS="$(echo)"; wmiir rm $(wmiir ls /lbar))
|
||||
seltag="$(wmiir read /tag/sel/ctl 2>/dev/null | sed 1q)"
|
||||
wmiir ls /tag | sed -e 's|/||; /^sel$/d' | while read tag; do
|
||||
if [ "$tag" = "$seltag" ]; then
|
||||
echo "$WMII_FOCUSCOLORS" "$tag"
|
||||
else
|
||||
echo "$WMII_NORMCOLORS" "$tag" | wmiir create "/lbar/$tag"
|
||||
fi
|
||||
echo "$WMII_NORMCOLORS" "$tag"
|
||||
fi | wmiir create "/lbar/$tag"
|
||||
done
|
||||
|
||||
# More functions
|
||||
|
@ -234,9 +230,9 @@ conf_which() {
|
|||
# Stop any running instances of wmiirc
|
||||
echo Start wmiirc | wmiir write /event || exit 1
|
||||
|
||||
wmiir read /event |
|
||||
while read event; do
|
||||
wmiir read /event | while read event; do
|
||||
set -- $event
|
||||
event=$1; shift
|
||||
Event_$event $@
|
||||
done 2>/dev/null
|
||||
|
||||
|
|
Loading…
Reference in New Issue