removed several files, merged wm and wmiikeys

This commit is contained in:
Anselm R. Garbe 2006-02-09 19:40:12 +01:00
parent 0ca97a565d
commit 13a12b6a7d
15 changed files with 325 additions and 178 deletions

View File

@ -6,11 +6,11 @@ include config.mk
SUBDIRS = libcext liblitz libixp libwmii cmd SUBDIRS = libcext liblitz libixp libwmii cmd
BIN = cmd/wm/wmii cmd/wm/wmiiwm cmd/wmiibar cmd/wmiifs \ BIN = cmd/wm/wmii cmd/wm/wmiiwm cmd/wmiibar cmd/wmiifs \
cmd/wmiikeys cmd/wmiiplumb cmd/wmiir cmd/wmiiwarp cmd/wmiiplumb cmd/wmiir cmd/wmiiwarp
#cmd/wmiikeys cmd/wmiimenu cmd/wmiiplumb cmd/wmiir cmd/wmiiwarp #cmd/wmiimenu cmd/wmiiplumb cmd/wmiir cmd/wmiiwarp
MAN1 = cmd/wm/wmii.1 cmd/wm/wmiiwm.1 cmd/wmiibar.1 cmd/wmiifs.1 \ MAN1 = cmd/wm/wmii.1 cmd/wm/wmiiwm.1 cmd/wmiibar.1 cmd/wmiifs.1 \
cmd/wmiikeys.1 cmd/wmiimenu.1 cmd/wmiir.1 cmd/wmiimenu.1 cmd/wmiir.1
all: all:
@echo wmii build options: @echo wmii build options:

View File

@ -18,17 +18,14 @@ OBJ_r = ${SRC_r:.c=.o}
SRC_fs = wmiifs.c SRC_fs = wmiifs.c
OBJ_fs = ${SRC_fs:.c=.o} OBJ_fs = ${SRC_fs:.c=.o}
SRC_keys = wmiikeys.c
OBJ_keys = ${SRC_keys:.c=.o}
SRC_plumb = wmiiplumb.c SRC_plumb = wmiiplumb.c
OBJ_plumb = ${SRC_plumb:.c=.o} OBJ_plumb = ${SRC_plumb:.c=.o}
SRC_warp = wmiiwarp.c SRC_warp = wmiiwarp.c
OBJ_warp = ${SRC_warp:.c=.o} OBJ_warp = ${SRC_warp:.c=.o}
#all: wmiibar wmiimenu wmiir wmiifs wmiikeys wmiiplumb wmiiwarp #all: wmiibar wmiimenu wmiir wmiifs wmiiplumb wmiiwarp
all: wmiifs wmiibar wmiikeys wmiir wmiiplumb wmiiwarp all: wmiifs wmiibar wmiir wmiiplumb wmiiwarp
@echo built wmii commands @echo built wmii commands
.c.o: .c.o:
@ -61,12 +58,6 @@ wmiifs: ${OBJ_fs}
# Solaris # Solaris
# @${CC} -o $@ ${OBJ_fs} ${LDFLAGS} -lsocket # @${CC} -o $@ ${OBJ_fs} ${LDFLAGS} -lsocket
wmiikeys: ${OBJ_keys}
@echo LD $@
@${CC} -o $@ ${OBJ_keys} ${LDFLAGS}
# Solaris
# @${CC} -o $@ ${OBJ_keys} ${LDFLAGS} -lsocket
wmiiplumb: ${OBJ_plumb} wmiiplumb: ${OBJ_plumb}
@echo LD $@ @echo LD $@
@${CC} -o $@ ${OBJ_plumb} ${LDFLAGS} @${CC} -o $@ ${OBJ_plumb} ${LDFLAGS}
@ -76,4 +67,4 @@ wmiiwarp: ${OBJ_warp}
@${CC} -o $@ ${OBJ_warp} ${LDFLAGS} @${CC} -o $@ ${OBJ_warp} ${LDFLAGS}
clean: clean:
rm -f wmiibar wmiimenu wmiir wmiikeys wmiiplumb wmiifs wmiiwarp *.o rm -f wmiibar wmiimenu wmiir wmiiplumb wmiifs wmiiwarp *.o

View File

@ -10,7 +10,7 @@ LDFLAGS += -L../../liblitz -llitz -L../../libwmii -lwmii \
# Solaris # Solaris
# LDFLAGS += -lsocket # LDFLAGS += -lsocket
SRC = area.c fs.c wm.c client.c event.c mouse.c page.c column.c SRC = area.c fs.c wm.c kb.c client.c event.c mouse.c page.c column.c
OBJ = ${SRC:.c=.o} OBJ = ${SRC:.c=.o}
all: wmiiwm all: wmiiwm

View File

@ -114,12 +114,12 @@ focus_client(Client *c)
if(old && (old != c)) { if(old && (old != c)) {
c->revert = old; c->revert = old;
grab_window(old->win, AnyModifier, Button1); grab_mouse(old->win, AnyModifier, Button1);
draw_client(old); draw_client(old);
} }
ungrab_window(c->win, AnyModifier, AnyButton); ungrab_mouse(c->win, AnyModifier, AnyButton);
grab_window(c->win, Mod1Mask, Button1); grab_mouse(c->win, Mod1Mask, Button1);
grab_window(c->win, Mod1Mask, Button3); grab_mouse(c->win, Mod1Mask, Button3);
XRaiseWindow(dpy, c->frame.win); XRaiseWindow(dpy, c->frame.win);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
XDefineCursor(dpy, c->win, normal_cursor); XDefineCursor(dpy, c->win, normal_cursor);
@ -138,7 +138,7 @@ map_client(Client * c)
void void
unmap_client(Client * c) unmap_client(Client * c)
{ {
ungrab_window(c->win, AnyModifier, AnyButton); ungrab_mouse(c->win, AnyModifier, AnyButton);
XUnmapWindow(dpy, c->win); XUnmapWindow(dpy, c->win);
set_client_state(c, WithdrawnState); set_client_state(c, WithdrawnState);
} }

View File

@ -15,6 +15,8 @@ static void handle_buttonpress(XEvent * e);
static void handle_configurerequest(XEvent * e); static void handle_configurerequest(XEvent * e);
static void handle_destroynotify(XEvent * e); static void handle_destroynotify(XEvent * e);
static void handle_expose(XEvent * e); static void handle_expose(XEvent * e);
static void handle_keypress(XEvent * e);
static void handle_keymapnotify(XEvent * e);
static void handle_maprequest(XEvent * e); static void handle_maprequest(XEvent * e);
static void handle_motionnotify(XEvent * e); static void handle_motionnotify(XEvent * e);
static void handle_propertynotify(XEvent * e); static void handle_propertynotify(XEvent * e);
@ -35,6 +37,8 @@ init_x_event_handler()
handler[ConfigureRequest] = handle_configurerequest; handler[ConfigureRequest] = handle_configurerequest;
handler[DestroyNotify] = handle_destroynotify; handler[DestroyNotify] = handle_destroynotify;
handler[Expose] = handle_expose; handler[Expose] = handle_expose;
handler[KeyPress] = handle_keypress;
handler[KeymapNotify] = handle_keymapnotify;
handler[MapRequest] = handle_maprequest; handler[MapRequest] = handle_maprequest;
handler[MotionNotify] = handle_motionnotify; handler[MotionNotify] = handle_motionnotify;
handler[PropertyNotify] = handle_propertynotify; handler[PropertyNotify] = handle_propertynotify;
@ -187,6 +191,24 @@ handle_expose(XEvent * e)
} }
} }
static void
handle_keypress(XEvent *e)
{
XKeyEvent *ev = &e->xkey;
ev->state &= valid_mask;
handle_key(root, ev->state, (KeyCode) ev->keycode);
}
static void
handle_keymapnotify(XEvent *e)
{
size_t i;
for(i = 0; i < nkey; i++) {
ungrab_key(key[i]);
grab_key(key[i]);
}
}
static void static void
handle_maprequest(XEvent *e) handle_maprequest(XEvent *e)
{ {
@ -266,4 +288,3 @@ static void handle_clientmessage(XEvent *e)
return; return;
} }
} }

View File

@ -24,13 +24,13 @@
* filesystem specification * filesystem specification
* / Droot * / Droot
* /def/ Ddef * /def/ Ddef
* /def/font Ffont <xlib font name>
* /def/selcolor Fselcolor <#RRGGBB> <#RRGGBB> <#RRGGBB>
* /def/normcolor Fnormcolor <#RRGGBB> <#RRGGBB> <#RRGGBB>
* /def/border Fborder 0..n * /def/border Fborder 0..n
* /def/bar Fbar 0, 1 * /def/bar Fbar 0, 1
* /def/snap Fsnap 0..n * /def/snap Fsnap 0..n
* /def/inc Finc 0..n * /def/inc Finc 0..n
* /keys/ Dkeys
* /keys/grab Fgrab interface to grab shortcuts
* /keys/foo Fkey
* /event Fevent * /event Fevent
* /ctl Fctl command interface (root) * /ctl Fctl command interface (root)
* /new/ Dpage returns new page * /new/ Dpage returns new page
@ -114,7 +114,8 @@ qid_to_name(Qid *qid)
switch(typ) { switch(typ) {
case Droot: return "/"; break; case Droot: return "/"; break;
case Ddefault: return "default"; break; case Ddef: return "def"; break;
case Dkeys: return "keys"; break;
case Dpage: case Dpage:
if(pg == sel) if(pg == sel)
return "sel"; return "sel";
@ -140,9 +141,6 @@ qid_to_name(Qid *qid)
return buf; return buf;
break; break;
case Fctl: return "ctl"; break; case Fctl: return "ctl"; break;
case Ffont: return "font"; break;
case Fselcolor: return "selcolor"; break;
case Fnormcolor: return "normcolor"; break;
case Fborder: return "border"; break; case Fborder: return "border"; break;
case Fsnap: return "border"; break; case Fsnap: return "border"; break;
case Fbar: return "bar"; break; case Fbar: return "bar"; break;
@ -150,6 +148,8 @@ qid_to_name(Qid *qid)
case Fgeom: return "geometry"; break; case Fgeom: return "geometry"; break;
case Fname: return "name"; break; case Fname: return "name"; break;
case Fevent: return "event"; break; case Fevent: return "event"; break;
case Fkey: return key[pg]->name; break;
case Fgrab: return "grab"; break;
default: return nil; break; default: return nil; break;
} }
} }
@ -166,18 +166,16 @@ name_to_type(char *name, unsigned char dtyp)
else if(dtyp == Dpage) else if(dtyp == Dpage)
return Darea; return Darea;
} }
if(!strncmp(name, "default", 8)) if(!strncmp(name, "def", 4))
return Ddefault; return Ddef;
if(!strncmp(name, "keys", 5))
return Dkeys;
if(!strncmp(name, "grab", 5))
return Fgrab;
if(!strncmp(name, "ctl", 4)) if(!strncmp(name, "ctl", 4))
return Fctl; return Fctl;
if(!strncmp(name, "font", 5))
return Ffont;
if(!strncmp(name, "event", 6)) if(!strncmp(name, "event", 6))
return Fevent; return Fevent;
if(!strncmp(name, "selcolor", 9))
return Fselcolor;
if(!strncmp(name, "normcolor", 10))
return Fnormcolor;
if(!strncmp(name, "snap", 5)) if(!strncmp(name, "snap", 5))
return Fsnap; return Fsnap;
if(!strncmp(name, "name", 5)) if(!strncmp(name, "name", 5))
@ -190,6 +188,8 @@ name_to_type(char *name, unsigned char dtyp)
return Finc; return Finc;
if(!strncmp(name, "geometry", 9)) if(!strncmp(name, "geometry", 9))
return Fgeom; return Fgeom;
if(key_of_name(name))
return Fkey;
if(!strncmp(name, "sel", 4)) if(!strncmp(name, "sel", 4))
goto dyndir; goto dyndir;
i = (unsigned short) cext_strtonum(name, 1, 0xffff, &err); i = (unsigned short) cext_strtonum(name, 1, 0xffff, &err);
@ -231,9 +231,13 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
case Droot: case Droot:
*new = root_qid; *new = root_qid;
break; break;
case Ddefault: case Ddef:
new->type = IXP_QTDIR; new->type = IXP_QTDIR;
new->path = mkqpath(Ddefault, 0, 0, 0); new->path = mkqpath(Ddef, 0, 0, 0);
break;
case Dkeys:
new->type = IXP_QTDIR;
new->path = mkqpath(Dkeys, 0, 0, 0);
break; break;
case Dpage: case Dpage:
new->type = IXP_QTDIR; new->type = IXP_QTDIR;
@ -305,6 +309,15 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
new->path = mkqpath(Dclient, dpgid, daid, a->client[i - 1]->id); new->path = mkqpath(Dclient, dpgid, daid, a->client[i - 1]->id);
} }
break; break;
case Fkey:
{
Key *k;
if(!(k = key_of_name(wname)))
return -1;
new->type = IXP_QTFILE;
new->path = mkqpath(Fkey, k->id, 0, 0);
}
break;
default: default:
new->type = IXP_QTFILE; new->type = IXP_QTFILE;
new->path = mkqpath(type, dpgid, daid, dcid); new->path = mkqpath(type, dpgid, daid, dcid);
@ -448,34 +461,27 @@ type_to_stat(Stat *stat, char *name, Qid *dir)
case Dclient: case Dclient:
case Darea: case Darea:
case Dpage: case Dpage:
case Ddefault: case Ddef:
case Dkeys:
case Droot: case Droot:
return mkstat(stat, dir, name, 0, DMDIR | DMREAD | DMEXEC); return mkstat(stat, dir, name, 0, DMDIR | DMREAD | DMEXEC);
break; break;
case Fctl: case Fctl:
case Fgrab:
return mkstat(stat, dir, name, 0, DMWRITE); return mkstat(stat, dir, name, 0, DMWRITE);
break; break;
case Fevent: case Fevent:
return mkstat(stat, dir, name, 0, DMREAD); return mkstat(stat, dir, name, 0, DMREAD);
break; break;
case Ffont:
return mkstat(stat, dir, name, strlen(def.font), DMREAD | DMWRITE);
break;
case Fselcolor:
return mkstat(stat, dir, name, 24, DMREAD | DMWRITE);
break;
case Fnormcolor:
return mkstat(stat, dir, name, 24, DMREAD | DMWRITE);
break;
case Fborder: case Fborder:
if(dtyp == Ddefault) if(dtyp == Ddef)
snprintf(buf, sizeof(buf), "%d", def.border); snprintf(buf, sizeof(buf), "%d", def.border);
else else
snprintf(buf, sizeof(buf), "%d", page[dpg]->area[darea]->client[dcl]->frame.border); snprintf(buf, sizeof(buf), "%d", page[dpg]->area[darea]->client[dcl]->frame.border);
return mkstat(stat, dir, name, strlen(buf), DMREAD | DMWRITE); return mkstat(stat, dir, name, strlen(buf), DMREAD | DMWRITE);
break; break;
case Fbar: case Fbar:
if(dtyp == Ddefault) if(dtyp == Ddef)
snprintf(buf, sizeof(buf), "%d", def.bar); snprintf(buf, sizeof(buf), "%d", def.bar);
else else
snprintf(buf, sizeof(buf), "%d", page[dpg]->area[darea]->client[dcl]->frame.bar); snprintf(buf, sizeof(buf), "%d", page[dpg]->area[darea]->client[dcl]->frame.bar);
@ -499,6 +505,9 @@ type_to_stat(Stat *stat, char *name, Qid *dir)
c = page[dpg]->area[darea]->client[dcl]; c = page[dpg]->area[darea]->client[dcl];
return mkstat(stat, dir, name, strlen(c->name), DMREAD); return mkstat(stat, dir, name, strlen(c->name), DMREAD);
break; break;
case Fkey:
return mkstat(stat, dir, name, 0, 0);
break;
} }
return 0; return 0;
} }
@ -561,6 +570,26 @@ xread(IXPConn *c, Fcall *fcall)
p = ixp_enc_stat(p, &stat); p = ixp_enc_stat(p, &stat);
} }
break; break;
case Dkeys:
/* jump to offset */
len = type_to_stat(&stat, "grab", &m->qid);
for(i = 0; i < nkey; i++) {
len += type_to_stat(&stat, key[i]->name, &m->qid);
fprintf(stderr, "len=%d <= fcall->offset=%lld\n", len, fcall->offset);
if(len <= fcall->offset)
continue;
break;
}
/* offset found, proceeding */
for(; i < nkey; i++) {
fprintf(stderr, "offset xread %s\n", key[i]->name);
len = type_to_stat(&stat, key[i]->name, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
p = ixp_enc_stat(p, &stat);
}
break;
case Dpage: case Dpage:
/* jump to offset */ /* jump to offset */
len = type_to_stat(&stat, "ctl", &m->qid); len = type_to_stat(&stat, "ctl", &m->qid);
@ -646,7 +675,19 @@ xread(IXPConn *c, Fcall *fcall)
p = ixp_enc_stat(p, &stat); p = ixp_enc_stat(p, &stat);
} }
break; break;
case Ddefault: case Dkeys:
fcall->count = type_to_stat(&stat, "grab", &m->qid);
p = ixp_enc_stat(p, &stat);
for(i = 0; i < nkey; i++) {
fprintf(stderr, "normal xread %s\n", key[i]->name);
len = type_to_stat(&stat, key[i]->name, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
p = ixp_enc_stat(p, &stat);
}
break;
case Ddef:
fcall->count = type_to_stat(&stat, "font", &m->qid); fcall->count = type_to_stat(&stat, "font", &m->qid);
p = ixp_enc_stat(p, &stat); p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "selcolor", &m->qid); fcall->count += type_to_stat(&stat, "selcolor", &m->qid);
@ -715,27 +756,15 @@ xread(IXPConn *c, Fcall *fcall)
case Fctl: case Fctl:
return Enoperm; return Enoperm;
break; break;
case Ffont:
if((fcall->count = strlen(def.font)))
memcpy(p, def.font, fcall->count);
break;
case Fevent: case Fevent:
ixp_server_enqueue_fcall(c, fcall); ixp_server_enqueue_fcall(c, fcall);
return nil; return nil;
break; break;
case Fselcolor:
if((fcall->count = strlen(def.selcolor)))
memcpy(p, def.selcolor, fcall->count);
break;
case Fnormcolor:
if((fcall->count = strlen(def.normcolor)))
memcpy(p, def.normcolor, fcall->count);
break;
case Fborder: case Fborder:
/*fprintf(stderr, "Fborder: qpath_type(m->qid.path)=%d, m->qid.dtype=%d\n", /*fprintf(stderr, "Fborder: qpath_type(m->qid.path)=%d, m->qid.dtype=%d\n",
qpath_type(m->qid.path), m->qid.dtype);*/ qpath_type(m->qid.path), m->qid.dtype);*/
if(m->qid.dtype == Ddefault) if(m->qid.dtype == Ddef)
snprintf(buf, sizeof(buf), "%u", def.border); snprintf(buf, sizeof(buf), "%u", def.border);
else else
snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->frame.border); snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->frame.border);
@ -743,7 +772,7 @@ xread(IXPConn *c, Fcall *fcall)
memcpy(p, buf, fcall->count); memcpy(p, buf, fcall->count);
break; break;
case Fbar: case Fbar:
if(m->qid.dtype == Ddefault) if(m->qid.dtype == Ddef)
snprintf(buf, sizeof(buf), "%u", def.bar); snprintf(buf, sizeof(buf), "%u", def.bar);
else else
snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->frame.bar); snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->frame.bar);
@ -854,38 +883,6 @@ xwrite(IXPConn *c, Fcall *fcall)
break; break;
} }
break; break;
case Ffont:
if(def.font)
free(def.font);
def.font = cext_emallocz(fcall->count + 1);
memcpy(def.font, fcall->data, fcall->count);
XFreeFont(dpy, xfont);
xfont = blitz_getfont(dpy, def.font);
/* TODO: update geometry */
break;
case Fselcolor:
if((fcall->count != 24)
|| (fcall->data[0] != '#') || (fcall->data[8] != '#')
|| (fcall->data[16] != '#')
)
return "wrong color format";
memcpy(def.selcolor, fcall->data, fcall->count);
def.selcolor[fcall->count] = 0;
blitz_loadcolor(dpy, screen, def.selcolor, &def.sel);
XSetForeground(dpy, gc_xor, def.sel.bg);
/* TODO: update color */
break;
case Fnormcolor:
if((fcall->count != 24)
|| (fcall->data[0] != '#') || (fcall->data[8] != '#')
|| (fcall->data[16] != '#')
)
return "wrong color format";
memcpy(def.normcolor, fcall->data, fcall->count);
def.normcolor[fcall->count] = 0;
blitz_loadcolor(dpy, screen, def.normcolor, &def.norm);
/* TODO: update color */
break;
case Fsnap: case Fsnap:
if(fcall->count > sizeof(buf)) if(fcall->count > sizeof(buf))
return "snap value out of range 0..0xffff"; return "snap value out of range 0..0xffff";
@ -904,7 +901,7 @@ xwrite(IXPConn *c, Fcall *fcall)
i = cext_strtonum(buf, 0, 0xffff, &err); i = cext_strtonum(buf, 0, 0xffff, &err);
if(err) if(err)
return "border value out of range 0..0xffff"; return "border value out of range 0..0xffff";
if(m->qid.dtype == Ddefault) if(m->qid.dtype == Ddef)
def.border = i; def.border = i;
else { else {
page[pg]->area[area]->client[cl]->frame.border = i; page[pg]->area[area]->client[cl]->frame.border = i;
@ -919,7 +916,7 @@ xwrite(IXPConn *c, Fcall *fcall)
i = cext_strtonum(buf, 0, 1, &err); i = cext_strtonum(buf, 0, 1, &err);
if(err) if(err)
return "bar value out of range 0, 1"; return "bar value out of range 0, 1";
if(m->qid.dtype == Ddefault) if(m->qid.dtype == Ddef)
def.border = i; def.border = i;
else { else {
page[pg]->area[area]->client[cl]->frame.border = i; page[pg]->area[area]->client[cl]->frame.border = i;
@ -945,6 +942,59 @@ xwrite(IXPConn *c, Fcall *fcall)
blitz_strtorect(&rect, &page[pg]->area[area]->client[cl]->frame.rect, buf); blitz_strtorect(&rect, &page[pg]->area[area]->client[cl]->frame.rect, buf);
/* TODO: resize client */ /* TODO: resize client */
break; break;
case Fgrab:
if(fcall->count > 2048)
return Enoperm;
{
static size_t lastcount;
static char last[2048]; /* iounit */
char fcallbuf[2048], tmp[2048]; /* iounit */
char *p1, *p2;
Key *k;
if(!fcall->offset) {
while(nkey) {
Key *k = key[0];
ungrab_key(k);
cext_array_detach((void **)key, k, &keysz);
nkey--;
destroy_key(k);
}
}
if(!fcall->count)
break;
memcpy(fcallbuf, fcall->data, fcall->count);
fcallbuf[fcall->count] = 0;
if(fcall->offset) {
p1 = strrchr(last, '\n');
p2 = strchr(fcallbuf, '\n');
memcpy(tmp, p1, lastcount - (p1 - last));
memcpy(tmp + (lastcount - (p1 - last)), p2, p2 - fcallbuf);
tmp[(lastcount - (p1 - last)) + (p2 - fcallbuf)] = 0;
k = create_key(tmp);
key = (Key **)cext_array_attach((void **)key, k, sizeof(Key *), &keysz);
nkey++;
grab_key(k);
}
else p2 = fcallbuf;
lastcount = fcall->count;
memcpy(last, fcall->data, fcall->count);
while(p2 - fcallbuf < fcall->count) {
p1 = strchr(p2, '\n');
if(!p1)
return "cannot grab, no \n supplied";
*p1 = 0;
k = create_key(p2);
key = (Key **)cext_array_attach((void **)key, k, sizeof(Key *), &keysz);
nkey++;
grab_key(k);
*p1 = '\n';
p2 = ++p1;
}
lastcount = fcall->count;
memcpy(last, fcall->data, fcall->count);
}
break;
default: default:
return "invalid write"; return "invalid write";
break; break;

View File

@ -602,3 +602,26 @@ mouse_resize(Client *c, Align align)
} }
} }
} }
void
grab_mouse(Window w, unsigned long mod, unsigned int button)
{
XGrabButton(dpy, button, mod, w, False,
ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
if((mod != AnyModifier) && num_lock_mask) {
XGrabButton(dpy, button, mod | num_lock_mask, w, False,
ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(dpy, button, mod | num_lock_mask | LockMask, w,
False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
}
}
void
ungrab_mouse(Window w, unsigned long mod, unsigned int button)
{
XUngrabButton(dpy, button, mod, w);
if(mod != AnyModifier && num_lock_mask) {
XUngrabButton(dpy, button, mod | num_lock_mask, w);
XUngrabButton(dpy, button, mod | num_lock_mask | LockMask, w);
}
}

View File

@ -254,7 +254,7 @@ map_detached_clients()
XMoveResizeWindow(dpy, det[i]->win, cr.x, cr.y, cr.width, cr.height); XMoveResizeWindow(dpy, det[i]->win, cr.x, cr.y, cr.width, cr.height);
configure_client(det[i]); configure_client(det[i]);
map_client(det[i]); map_client(det[i]);
grab_window(det[i]->win, AnyModifier, Button1); grab_mouse(det[i]->win, AnyModifier, Button1);
XRaiseWindow(dpy, det[i]->win); XRaiseWindow(dpy, det[i]->win);
XSync(dpy, False); XSync(dpy, False);
} }
@ -334,6 +334,7 @@ void
select_page(char *arg) select_page(char *arg)
{ {
size_t new = sel; size_t new = sel;
const char *err;
if(!npage || !arg) if(!npage || !arg)
return; return;
@ -347,7 +348,7 @@ select_page(char *arg)
else else
new = 0; new = 0;
} else { } else {
int idx = blitz_strtonum(arg, 0, npage); int idx = cext_strtonum(arg, 0, npage, &err);
if(idx < npage) if(idx < npage)
new = idx; new = idx;
} }
@ -553,30 +554,6 @@ cleanup()
XSync(dpy, False); XSync(dpy, False);
} }
void
grab_window(Window w, unsigned long mod, unsigned int button)
{
XGrabButton(dpy, button, mod, w, False,
ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
if((mod != AnyModifier) && num_lock_mask) {
XGrabButton(dpy, button, mod | num_lock_mask, w, False,
ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(dpy, button, mod | num_lock_mask | LockMask, w,
False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
}
}
void
ungrab_window(Window w, unsigned long mod, unsigned int button)
{
XUngrabButton(dpy, button, mod, w);
if(mod != AnyModifier && num_lock_mask) {
XUngrabButton(dpy, button, mod | num_lock_mask, w);
XUngrabButton(dpy, button, mod | num_lock_mask | LockMask, w);
}
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
@ -665,9 +642,9 @@ main(int argc, char *argv[])
def.border = DEF_BORDER; def.border = DEF_BORDER;
def.snap = DEF_SNAP; def.snap = DEF_SNAP;
def.inc = def.bar = True; def.inc = def.bar = True;
cext_strlcpy(def.selcolor, BLITZ_SEL_COLOR, sizeof(def.selcolor)); cext_strlcpy(def.selcolor, BLITZ_SELCOLORS, sizeof(def.selcolor));
blitz_loadcolor(dpy, screen, def.selcolor, &def.sel); blitz_loadcolor(dpy, screen, def.selcolor, &def.sel);
cext_strlcpy(def.normcolor, BLITZ_NORM_COLOR, sizeof(def.normcolor)); cext_strlcpy(def.normcolor, BLITZ_NORMCOLORS, sizeof(def.normcolor));
blitz_loadcolor(dpy, screen, def.normcolor, &def.norm); blitz_loadcolor(dpy, screen, def.normcolor, &def.norm);
init_atoms(); init_atoms();

View File

@ -20,13 +20,13 @@ enum {
/* 8-bit qid.path.type */ /* 8-bit qid.path.type */
enum { enum {
Droot, Droot,
Ddefault, Ddef,
Dpage, Dpage,
Darea, Darea,
Dclient, Dclient,
Ffont, Dkeys,
Fselcolor, Fkey,
Fnormcolor, Fgrab,
Fborder, Fborder,
Fsnap, Fsnap,
Fbar, Fbar,
@ -96,6 +96,15 @@ struct Client {
} frame; } frame;
}; };
typedef struct Key Key;
struct Key {
unsigned short id;
char name[128];
unsigned long mod;
KeyCode key;
Key *next;
};
/* global variables */ /* global variables */
Page **page; Page **page;
size_t npage; size_t npage;
@ -109,6 +118,9 @@ size_t detsz;
Client **client; Client **client;
size_t nclient; size_t nclient;
size_t clientsz; size_t clientsz;
Key **key;
size_t keysz;
size_t nkey;
Display *dpy; Display *dpy;
IXPServer *ixps; IXPServer *ixps;
@ -195,6 +207,15 @@ unsigned long long mkqpath(unsigned char type, unsigned short pg,
void do_pend_fcall(char *event); void do_pend_fcall(char *event);
void new_ixp_conn(IXPConn *c); void new_ixp_conn(IXPConn *c);
/* kb.c */
void handle_key(Window w, unsigned long mod, KeyCode keycode);
void grab_key(Key *k);
void ungrab_key(Key *k);
Key * key_of_name(char *name);
int index_of_id(unsigned short id);
Key *create_key(char *name);
void destroy_key(Key *k);
/* mouse.c */ /* mouse.c */
void mouse_resize(Client *c, Align align); void mouse_resize(Client *c, Align align);
void mouse_move(Client *c); void mouse_move(Client *c);
@ -202,6 +223,8 @@ Cursor cursor_for_motion(Client *c, int x, int y);
Align cursor_to_align(Cursor cursor); Align cursor_to_align(Cursor cursor);
Align xy_to_align(XRectangle * rect, int x, int y); Align xy_to_align(XRectangle * rect, int x, int y);
void drop_move(Client *c, XRectangle *new, XPoint *pt); void drop_move(Client *c, XRectangle *new, XPoint *pt);
void grab_mouse(Window w, unsigned long mod, unsigned int button);
void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
/* page.c */ /* page.c */
Page *alloc_page(); Page *alloc_page();
@ -225,8 +248,6 @@ Client *win_to_client(Window w);
int win_proto(Window w); int win_proto(Window w);
int win_state(Window w); int win_state(Window w);
/*void handle_after_write(IXPServer * s, File * f);*/ /*void handle_after_write(IXPServer * s, File * f);*/
void grab_window(Window w, unsigned long mod, unsigned int button);
void ungrab_window(Window w, unsigned long mod, unsigned int button);
void pager(); void pager();
void detached_clients(); void detached_clients();
void attach_detached_client(); void attach_detached_client();

View File

@ -852,7 +852,7 @@ main(int argc, char *argv[])
ixp_server_open_conn(&srv, ConnectionNumber(dpy), check_x_event, nil); ixp_server_open_conn(&srv, ConnectionNumber(dpy), check_x_event, nil);
/* default settings */ /* default settings */
cext_strlcpy(defcolstr, BLITZ_SEL_COLOR, sizeof(defcolstr)); cext_strlcpy(defcolstr, BLITZ_SELCOLORS, sizeof(defcolstr));
blitz_loadcolor(dpy, screen, defcolstr, &defcolor); blitz_loadcolor(dpy, screen, defcolstr, &defcolor);
/* X stuff */ /* X stuff */

View File

@ -6,7 +6,7 @@ include ../config.mk
CFLAGS += -I../libixp -I../libcext CFLAGS += -I../libixp -I../libcext
LDFLAGS += -L../libixp -lixp -L../libcext -lcext LDFLAGS += -L../libixp -lixp -L../libcext -lcext
SRC = draw.c geometry.c kb.c mouse.c util.c SRC = draw.c geometry.c
OBJ = ${SRC:.c=.o} OBJ = ${SRC:.c=.o}
all: liblitz all: liblitz

View File

@ -7,8 +7,8 @@
#include <cext.h> #include <cext.h>
#define BLITZ_FONT "fixed" #define BLITZ_FONT "fixed"
#define BLITZ_SEL_COLOR "#ffffff #555588 #8888bb" #define BLITZ_SELCOLORS "#ffffff #555588 #8888bb"
#define BLITZ_NORM_COLOR "#dddddd #666666 #999999" #define BLITZ_NORMCOLORS "#dddddd #666666 #999999"
typedef enum { typedef enum {
CENTER, WEST, NWEST, NORTH, NEAST, EAST, CENTER, WEST, NWEST, NORTH, NEAST, EAST,
@ -45,13 +45,3 @@ int blitz_strtorect(XRectangle * root, XRectangle * r, char *val);
Bool blitz_ispointinrect(int x, int y, XRectangle * r); Bool blitz_ispointinrect(int x, int y, XRectangle * r);
int blitz_distance(XRectangle * origin, XRectangle * target); int blitz_distance(XRectangle * origin, XRectangle * target);
void blitz_getbasegeometry(unsigned int size, unsigned int *cols, unsigned int *rows); void blitz_getbasegeometry(unsigned int size, unsigned int *cols, unsigned int *rows);
/* mouse.c */
char *blitz_buttontostr(unsigned int button);
unsigned int blitz_strtobutton(char *val);
/* kb.c */
unsigned long blitz_strtomod(char *val);
/* util.c */
long long blitz_strtonum(const char *numstr, long long minval, long long maxval);

View File

@ -150,12 +150,15 @@ draw_text(Display * dpy, Draw * d)
void void
blitz_drawmeter(Display * dpy, Draw * d) blitz_drawmeter(Display * dpy, Draw * d)
{ {
const char *err;
unsigned int offy, mh, val, w = d->rect.width - 4; unsigned int offy, mh, val, w = d->rect.width - 4;
if (!d->data || strncmp(d->data, "%m:", 3)) if (!d->data || strncmp(d->data, "%m:", 3))
return; return;
val = blitz_strtonum(&d->data[3], 0, 100); val = cext_strtonum(&d->data[3], 0, 100, &err);
if(err)
val = 100;
draw_bg(dpy, d); draw_bg(dpy, d);
xdraw_border(dpy, d); xdraw_border(dpy, d);

View File

@ -47,6 +47,7 @@ int blitz_strtoalign(Align *result, char *val)
*/ */
int blitz_strtorect(XRectangle *root, XRectangle *r, char *val) int blitz_strtorect(XRectangle *root, XRectangle *r, char *val)
{ {
const char *err;
char buf[64]; char buf[64];
char *x, *y, *w, *h; char *x, *y, *w, *h;
char *p; char *p;
@ -73,13 +74,13 @@ int blitz_strtorect(XRectangle *root, XRectangle *r, char *val)
} }
} }
if (x && (sx = (x[0] >= '0') && (x[0] <= '9'))) if (x && (sx = (x[0] >= '0') && (x[0] <= '9')))
rx = blitz_strtonum(x, 0, 65535); rx = cext_strtonum(x, 0, 65535, &err);
if (y && (sy = (y[0] >= '0') && (y[0] <= '9'))) if (y && (sy = (y[0] >= '0') && (y[0] <= '9')))
ry = blitz_strtonum(y, 0, 65535); ry = cext_strtonum(y, 0, 65535, &err);
if (w && (sw = (w[0] >= '0') && (w[0] <= '9'))) if (w && (sw = (w[0] >= '0') && (w[0] <= '9')))
rw = blitz_strtonum(w, 0, 65535); rw = cext_strtonum(w, 0, 65535, &err);
if (h && (sh = (h[0] >= '0') && (h[0] <= '9'))) if (h && (sh = (h[0] >= '0') && (h[0] <= '9')))
rh = blitz_strtonum(h, 0, 65535); rh = cext_strtonum(h, 0, 65535, &err);
if (!sx && !sw && x && w if (!sx && !sw && x && w
&& x[0] != '-' && x[0] != '+' && w[0] != '-' && w[0] != '+') { && x[0] != '-' && x[0] != '+' && w[0] != '-' && w[0] != '+') {
@ -155,34 +156,34 @@ int blitz_strtorect(XRectangle *root, XRectangle *r, char *val)
if (x) { if (x) {
p = strchr(x, '-'); p = strchr(x, '-');
if (p) if (p)
rx -= blitz_strtonum(++p, 0, 65535); rx -= cext_strtonum(++p, 0, 65535, &err);
p = strchr(x, '+'); p = strchr(x, '+');
if (p) if (p)
rx += blitz_strtonum(++p, 0, 65535); rx += cext_strtonum(++p, 0, 65535, &err);
} }
if (y) { if (y) {
p = strchr(y, '-'); p = strchr(y, '-');
if (p) if (p)
ry -= blitz_strtonum(++p, 0, 65535); ry -= cext_strtonum(++p, 0, 65535, &err);
p = strchr(y, '+'); p = strchr(y, '+');
if (p) if (p)
ry += blitz_strtonum(++p, 0, 65535); ry += cext_strtonum(++p, 0, 65535, &err);
} }
if (w) { if (w) {
p = strchr(w, '-'); p = strchr(w, '-');
if (p) if (p)
rw -= blitz_strtonum(++p, 0, 65535); rw -= cext_strtonum(++p, 0, 65535, &err);
p = strchr(w, '+'); p = strchr(w, '+');
if (p) if (p)
rw += blitz_strtonum(++p, 0, 65535); rw += cext_strtonum(++p, 0, 65535, &err);
} }
if (h) { if (h) {
p = strchr(h, '-'); p = strchr(h, '-');
if (p) if (p)
rh -= blitz_strtonum(++p, 0, 65535); rh -= cext_strtonum(++p, 0, 65535, &err);
p = strchr(h, '+'); p = strchr(h, '+');
if (p) if (p)
rh += blitz_strtonum(++p, 0, 65535); rh += cext_strtonum(++p, 0, 65535, &err);
} }
if (rw < 1) if (rw < 1)

View File

@ -5,10 +5,6 @@ CLIENT_BAR=0
CLIENT_BORDER=3 CLIENT_BORDER=3
HANDLEINC=1 HANDLEINC=1
SEL_COLOR='#ffffff #444466 #666688'
NORM_COLOR='#dddddd #555555 #777777'
FONT=fixed
fn xwrite { echo -n $2 | wmiir write $1 } fn xwrite { echo -n $2 | wmiir write $1 }
# WMIIWM CONFIGURATION # WMIIWM CONFIGURATION
@ -34,5 +30,79 @@ echo -n key | wmiir write /bar/new/data
# MISC # MISC
xsetroot -mod 2 2 -bg '#444466' -fg '#555555' xsetroot -mod 2 2 -bg '#444466' -fg '#555555'
keys&
status& status&
wmiir write /wm/keys/grab <<END
Control-Alt-k
Control-Alt-c
Control-Alt-q,y
Control-Alt-w,y
Alt-t
Alt-d
Alt-a
Shift-Alt-a
Alt-n
Alt-m
Alt-Return
Shift-Alt-Return
Control-Alt-y
Alt-h
Alt-l
Alt-Tab
Alt-j
Alt-k
Shift-Alt-h
Shift-Alt-l
Shift-Alt-p
Shift-Alt-1
Shift-Alt-2
Shift-Alt-3
Shift-Alt-4
END
wmiir read /wm/event | \
while(key=`{read}) {
xwrite /bar/2/data $key
switch($key) {
case Control-Alt-c
xwrite /wm/sel/sel/sel/ctl kill
case Control-Alt-q,y
quit
case Alt-t
extern xterm -rv &
case Alt-d
xwrite /wm/sel/sel/sel/ctl detach
case Alt-a
xwrite /wm/ctl attach
case Shift-Alt-a
xwrite /wm/ctl detached
case Alt-n
wmiir read /wm/sel/new >/dev/null >[2=1]
case Alt-m
xwrite /wm/sel/sel/sel/ctl max
case Alt-Return
xwrite /wm/sel/sel/ctl 'swap east'
case Shift-Alt-Return
xwrite /wm/sel/sel/ctl 'swap west'
case Control-Alt-y
wmiir read /wm/new >/dev/null >[2=1]
case Alt-h
xwrite /wm/sel/ctl 'select next'
case Alt-l
xwrite /wm/sel/ctl 'select prev'
case Alt-Tab
xwrite /wm/sel/sel/ctl 'select next'
case Alt-j
xwrite /wm/sel/sel/ctl 'select next'
case Alt-k
xwrite /wm/sel/sel/ctl 'select prev'
case Shift-Alt-h
xwrite /wm/ctl 'select prev'
case Shift-Alt-l
xwrite /wm/ctl 'select next'
case Shift-Alt-p
xwrite /wm/ctl pager
case Shift-Alt-[1-9]
xwrite /wm/ctl 'select '^`{echo $k|sed 's/.*-//g'}
}
}