mirror of
https://github.com/0intro/wmii
synced 2024-12-24 04:16:50 +03:00
removed several files, merged wm and wmiikeys
This commit is contained in:
parent
0ca97a565d
commit
13a12b6a7d
6
Makefile
6
Makefile
@ -6,11 +6,11 @@ include config.mk
|
||||
SUBDIRS = libcext liblitz libixp libwmii cmd
|
||||
|
||||
BIN = cmd/wm/wmii cmd/wm/wmiiwm cmd/wmiibar cmd/wmiifs \
|
||||
cmd/wmiikeys cmd/wmiiplumb cmd/wmiir cmd/wmiiwarp
|
||||
#cmd/wmiikeys cmd/wmiimenu cmd/wmiiplumb cmd/wmiir cmd/wmiiwarp
|
||||
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 \
|
||||
cmd/wmiikeys.1 cmd/wmiimenu.1 cmd/wmiir.1
|
||||
cmd/wmiimenu.1 cmd/wmiir.1
|
||||
|
||||
all:
|
||||
@echo wmii build options:
|
||||
|
15
cmd/Makefile
15
cmd/Makefile
@ -18,17 +18,14 @@ OBJ_r = ${SRC_r:.c=.o}
|
||||
SRC_fs = wmiifs.c
|
||||
OBJ_fs = ${SRC_fs:.c=.o}
|
||||
|
||||
SRC_keys = wmiikeys.c
|
||||
OBJ_keys = ${SRC_keys:.c=.o}
|
||||
|
||||
SRC_plumb = wmiiplumb.c
|
||||
OBJ_plumb = ${SRC_plumb:.c=.o}
|
||||
|
||||
SRC_warp = wmiiwarp.c
|
||||
OBJ_warp = ${SRC_warp:.c=.o}
|
||||
|
||||
#all: wmiibar wmiimenu wmiir wmiifs wmiikeys wmiiplumb wmiiwarp
|
||||
all: wmiifs wmiibar wmiikeys wmiir wmiiplumb wmiiwarp
|
||||
#all: wmiibar wmiimenu wmiir wmiifs wmiiplumb wmiiwarp
|
||||
all: wmiifs wmiibar wmiir wmiiplumb wmiiwarp
|
||||
@echo built wmii commands
|
||||
|
||||
.c.o:
|
||||
@ -61,12 +58,6 @@ wmiifs: ${OBJ_fs}
|
||||
# Solaris
|
||||
# @${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}
|
||||
@echo LD $@
|
||||
@${CC} -o $@ ${OBJ_plumb} ${LDFLAGS}
|
||||
@ -76,4 +67,4 @@ wmiiwarp: ${OBJ_warp}
|
||||
@${CC} -o $@ ${OBJ_warp} ${LDFLAGS}
|
||||
|
||||
clean:
|
||||
rm -f wmiibar wmiimenu wmiir wmiikeys wmiiplumb wmiifs wmiiwarp *.o
|
||||
rm -f wmiibar wmiimenu wmiir wmiiplumb wmiifs wmiiwarp *.o
|
||||
|
@ -10,7 +10,7 @@ LDFLAGS += -L../../liblitz -llitz -L../../libwmii -lwmii \
|
||||
# Solaris
|
||||
# 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}
|
||||
|
||||
all: wmiiwm
|
||||
|
@ -114,12 +114,12 @@ focus_client(Client *c)
|
||||
|
||||
if(old && (old != c)) {
|
||||
c->revert = old;
|
||||
grab_window(old->win, AnyModifier, Button1);
|
||||
grab_mouse(old->win, AnyModifier, Button1);
|
||||
draw_client(old);
|
||||
}
|
||||
ungrab_window(c->win, AnyModifier, AnyButton);
|
||||
grab_window(c->win, Mod1Mask, Button1);
|
||||
grab_window(c->win, Mod1Mask, Button3);
|
||||
ungrab_mouse(c->win, AnyModifier, AnyButton);
|
||||
grab_mouse(c->win, Mod1Mask, Button1);
|
||||
grab_mouse(c->win, Mod1Mask, Button3);
|
||||
XRaiseWindow(dpy, c->frame.win);
|
||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||
XDefineCursor(dpy, c->win, normal_cursor);
|
||||
@ -138,7 +138,7 @@ map_client(Client * c)
|
||||
void
|
||||
unmap_client(Client * c)
|
||||
{
|
||||
ungrab_window(c->win, AnyModifier, AnyButton);
|
||||
ungrab_mouse(c->win, AnyModifier, AnyButton);
|
||||
XUnmapWindow(dpy, c->win);
|
||||
set_client_state(c, WithdrawnState);
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ static void handle_buttonpress(XEvent * e);
|
||||
static void handle_configurerequest(XEvent * e);
|
||||
static void handle_destroynotify(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_motionnotify(XEvent * e);
|
||||
static void handle_propertynotify(XEvent * e);
|
||||
@ -35,6 +37,8 @@ init_x_event_handler()
|
||||
handler[ConfigureRequest] = handle_configurerequest;
|
||||
handler[DestroyNotify] = handle_destroynotify;
|
||||
handler[Expose] = handle_expose;
|
||||
handler[KeyPress] = handle_keypress;
|
||||
handler[KeymapNotify] = handle_keymapnotify;
|
||||
handler[MapRequest] = handle_maprequest;
|
||||
handler[MotionNotify] = handle_motionnotify;
|
||||
handler[PropertyNotify] = handle_propertynotify;
|
||||
@ -54,7 +58,7 @@ check_x_event(IXPConn *c)
|
||||
}
|
||||
|
||||
static void
|
||||
handle_buttonpress(XEvent * e)
|
||||
handle_buttonpress(XEvent *e)
|
||||
{
|
||||
Client *c;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
@ -167,7 +171,7 @@ handle_configurerequest(XEvent *e)
|
||||
}
|
||||
|
||||
static void
|
||||
handle_destroynotify(XEvent * e)
|
||||
handle_destroynotify(XEvent *e)
|
||||
{
|
||||
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
||||
Client *c = win_to_client(ev->window);
|
||||
@ -178,7 +182,7 @@ handle_destroynotify(XEvent * e)
|
||||
}
|
||||
|
||||
static void
|
||||
handle_expose(XEvent * e)
|
||||
handle_expose(XEvent *e)
|
||||
{
|
||||
static Client *c;
|
||||
if(e->xexpose.count == 0) {
|
||||
@ -188,7 +192,25 @@ handle_expose(XEvent * e)
|
||||
}
|
||||
|
||||
static void
|
||||
handle_maprequest(XEvent * e)
|
||||
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
|
||||
handle_maprequest(XEvent *e)
|
||||
{
|
||||
XMapRequestEvent *ev = &e->xmaprequest;
|
||||
static XWindowAttributes wa;
|
||||
@ -217,7 +239,7 @@ handle_maprequest(XEvent * e)
|
||||
}
|
||||
|
||||
static void
|
||||
handle_motionnotify(XEvent * e)
|
||||
handle_motionnotify(XEvent *e)
|
||||
{
|
||||
Client *c = win_to_frame(e->xmotion.window);
|
||||
if(c) {
|
||||
@ -230,7 +252,7 @@ handle_motionnotify(XEvent * e)
|
||||
}
|
||||
|
||||
static void
|
||||
handle_propertynotify(XEvent * e)
|
||||
handle_propertynotify(XEvent *e)
|
||||
{
|
||||
XPropertyEvent *ev = &e->xproperty;
|
||||
Client *c;
|
||||
@ -243,7 +265,7 @@ handle_propertynotify(XEvent * e)
|
||||
}
|
||||
|
||||
static void
|
||||
handle_unmapnotify(XEvent * e)
|
||||
handle_unmapnotify(XEvent *e)
|
||||
{
|
||||
XUnmapEvent *ev = &e->xunmap;
|
||||
Client *c;
|
||||
@ -266,4 +288,3 @@ static void handle_clientmessage(XEvent *e)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
216
cmd/wm/fs.c
216
cmd/wm/fs.c
@ -23,14 +23,14 @@
|
||||
/*
|
||||
* filesystem specification
|
||||
* / Droot
|
||||
* /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/bar Fbar 0, 1
|
||||
* /def/snap Fsnap 0..n
|
||||
* /def/inc Finc 0..n
|
||||
* /def/ Ddef
|
||||
* /def/border Fborder 0..n
|
||||
* /def/bar Fbar 0, 1
|
||||
* /def/snap Fsnap 0..n
|
||||
* /def/inc Finc 0..n
|
||||
* /keys/ Dkeys
|
||||
* /keys/grab Fgrab interface to grab shortcuts
|
||||
* /keys/foo Fkey
|
||||
* /event Fevent
|
||||
* /ctl Fctl command interface (root)
|
||||
* /new/ Dpage returns new page
|
||||
@ -114,7 +114,8 @@ qid_to_name(Qid *qid)
|
||||
|
||||
switch(typ) {
|
||||
case Droot: return "/"; break;
|
||||
case Ddefault: return "default"; break;
|
||||
case Ddef: return "def"; break;
|
||||
case Dkeys: return "keys"; break;
|
||||
case Dpage:
|
||||
if(pg == sel)
|
||||
return "sel";
|
||||
@ -140,9 +141,6 @@ qid_to_name(Qid *qid)
|
||||
return buf;
|
||||
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 Fsnap: return "border"; break;
|
||||
case Fbar: return "bar"; break;
|
||||
@ -150,6 +148,8 @@ qid_to_name(Qid *qid)
|
||||
case Fgeom: return "geometry"; break;
|
||||
case Fname: return "name"; break;
|
||||
case Fevent: return "event"; break;
|
||||
case Fkey: return key[pg]->name; break;
|
||||
case Fgrab: return "grab"; break;
|
||||
default: return nil; break;
|
||||
}
|
||||
}
|
||||
@ -166,18 +166,16 @@ name_to_type(char *name, unsigned char dtyp)
|
||||
else if(dtyp == Dpage)
|
||||
return Darea;
|
||||
}
|
||||
if(!strncmp(name, "default", 8))
|
||||
return Ddefault;
|
||||
if(!strncmp(name, "def", 4))
|
||||
return Ddef;
|
||||
if(!strncmp(name, "keys", 5))
|
||||
return Dkeys;
|
||||
if(!strncmp(name, "grab", 5))
|
||||
return Fgrab;
|
||||
if(!strncmp(name, "ctl", 4))
|
||||
return Fctl;
|
||||
if(!strncmp(name, "font", 5))
|
||||
return Ffont;
|
||||
if(!strncmp(name, "event", 6))
|
||||
return Fevent;
|
||||
if(!strncmp(name, "selcolor", 9))
|
||||
return Fselcolor;
|
||||
if(!strncmp(name, "normcolor", 10))
|
||||
return Fnormcolor;
|
||||
if(!strncmp(name, "snap", 5))
|
||||
return Fsnap;
|
||||
if(!strncmp(name, "name", 5))
|
||||
@ -190,6 +188,8 @@ name_to_type(char *name, unsigned char dtyp)
|
||||
return Finc;
|
||||
if(!strncmp(name, "geometry", 9))
|
||||
return Fgeom;
|
||||
if(key_of_name(name))
|
||||
return Fkey;
|
||||
if(!strncmp(name, "sel", 4))
|
||||
goto dyndir;
|
||||
i = (unsigned short) cext_strtonum(name, 1, 0xffff, &err);
|
||||
@ -231,9 +231,13 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
|
||||
case Droot:
|
||||
*new = root_qid;
|
||||
break;
|
||||
case Ddefault:
|
||||
case Ddef:
|
||||
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;
|
||||
case Dpage:
|
||||
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);
|
||||
}
|
||||
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:
|
||||
new->type = IXP_QTFILE;
|
||||
new->path = mkqpath(type, dpgid, daid, dcid);
|
||||
@ -448,34 +461,27 @@ type_to_stat(Stat *stat, char *name, Qid *dir)
|
||||
case Dclient:
|
||||
case Darea:
|
||||
case Dpage:
|
||||
case Ddefault:
|
||||
case Ddef:
|
||||
case Dkeys:
|
||||
case Droot:
|
||||
return mkstat(stat, dir, name, 0, DMDIR | DMREAD | DMEXEC);
|
||||
break;
|
||||
case Fctl:
|
||||
case Fgrab:
|
||||
return mkstat(stat, dir, name, 0, DMWRITE);
|
||||
break;
|
||||
case Fevent:
|
||||
return mkstat(stat, dir, name, 0, DMREAD);
|
||||
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:
|
||||
if(dtyp == Ddefault)
|
||||
if(dtyp == Ddef)
|
||||
snprintf(buf, sizeof(buf), "%d", def.border);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%d", page[dpg]->area[darea]->client[dcl]->frame.border);
|
||||
return mkstat(stat, dir, name, strlen(buf), DMREAD | DMWRITE);
|
||||
break;
|
||||
case Fbar:
|
||||
if(dtyp == Ddefault)
|
||||
if(dtyp == Ddef)
|
||||
snprintf(buf, sizeof(buf), "%d", def.bar);
|
||||
else
|
||||
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];
|
||||
return mkstat(stat, dir, name, strlen(c->name), DMREAD);
|
||||
break;
|
||||
case Fkey:
|
||||
return mkstat(stat, dir, name, 0, 0);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -561,6 +570,26 @@ xread(IXPConn *c, Fcall *fcall)
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
}
|
||||
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:
|
||||
/* jump to offset */
|
||||
len = type_to_stat(&stat, "ctl", &m->qid);
|
||||
@ -646,7 +675,19 @@ xread(IXPConn *c, Fcall *fcall)
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
}
|
||||
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);
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
fcall->count += type_to_stat(&stat, "selcolor", &m->qid);
|
||||
@ -715,27 +756,15 @@ xread(IXPConn *c, Fcall *fcall)
|
||||
case Fctl:
|
||||
return Enoperm;
|
||||
break;
|
||||
case Ffont:
|
||||
if((fcall->count = strlen(def.font)))
|
||||
memcpy(p, def.font, fcall->count);
|
||||
break;
|
||||
case Fevent:
|
||||
ixp_server_enqueue_fcall(c, fcall);
|
||||
return nil;
|
||||
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:
|
||||
/*fprintf(stderr, "Fborder: qpath_type(m->qid.path)=%d, m->qid.dtype=%d\n",
|
||||
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);
|
||||
else
|
||||
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);
|
||||
break;
|
||||
case Fbar:
|
||||
if(m->qid.dtype == Ddefault)
|
||||
if(m->qid.dtype == Ddef)
|
||||
snprintf(buf, sizeof(buf), "%u", def.bar);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->frame.bar);
|
||||
@ -854,38 +883,6 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
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:
|
||||
if(fcall->count > sizeof(buf))
|
||||
return "snap value out of range 0..0xffff";
|
||||
@ -904,7 +901,7 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
i = cext_strtonum(buf, 0, 0xffff, &err);
|
||||
if(err)
|
||||
return "border value out of range 0..0xffff";
|
||||
if(m->qid.dtype == Ddefault)
|
||||
if(m->qid.dtype == Ddef)
|
||||
def.border = i;
|
||||
else {
|
||||
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);
|
||||
if(err)
|
||||
return "bar value out of range 0, 1";
|
||||
if(m->qid.dtype == Ddefault)
|
||||
if(m->qid.dtype == Ddef)
|
||||
def.border = i;
|
||||
else {
|
||||
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);
|
||||
/* TODO: resize client */
|
||||
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:
|
||||
return "invalid write";
|
||||
break;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
33
cmd/wm/wm.c
33
cmd/wm/wm.c
@ -254,7 +254,7 @@ map_detached_clients()
|
||||
XMoveResizeWindow(dpy, det[i]->win, cr.x, cr.y, cr.width, cr.height);
|
||||
configure_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);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
@ -334,6 +334,7 @@ void
|
||||
select_page(char *arg)
|
||||
{
|
||||
size_t new = sel;
|
||||
const char *err;
|
||||
|
||||
if(!npage || !arg)
|
||||
return;
|
||||
@ -347,7 +348,7 @@ select_page(char *arg)
|
||||
else
|
||||
new = 0;
|
||||
} else {
|
||||
int idx = blitz_strtonum(arg, 0, npage);
|
||||
int idx = cext_strtonum(arg, 0, npage, &err);
|
||||
if(idx < npage)
|
||||
new = idx;
|
||||
}
|
||||
@ -553,30 +554,6 @@ cleanup()
|
||||
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
|
||||
main(int argc, char *argv[])
|
||||
@ -665,9 +642,9 @@ main(int argc, char *argv[])
|
||||
def.border = DEF_BORDER;
|
||||
def.snap = DEF_SNAP;
|
||||
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);
|
||||
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);
|
||||
|
||||
init_atoms();
|
||||
|
33
cmd/wm/wm.h
33
cmd/wm/wm.h
@ -20,13 +20,13 @@ enum {
|
||||
/* 8-bit qid.path.type */
|
||||
enum {
|
||||
Droot,
|
||||
Ddefault,
|
||||
Ddef,
|
||||
Dpage,
|
||||
Darea,
|
||||
Dclient,
|
||||
Ffont,
|
||||
Fselcolor,
|
||||
Fnormcolor,
|
||||
Dkeys,
|
||||
Fkey,
|
||||
Fgrab,
|
||||
Fborder,
|
||||
Fsnap,
|
||||
Fbar,
|
||||
@ -96,6 +96,15 @@ struct Client {
|
||||
} frame;
|
||||
};
|
||||
|
||||
typedef struct Key Key;
|
||||
struct Key {
|
||||
unsigned short id;
|
||||
char name[128];
|
||||
unsigned long mod;
|
||||
KeyCode key;
|
||||
Key *next;
|
||||
};
|
||||
|
||||
/* global variables */
|
||||
Page **page;
|
||||
size_t npage;
|
||||
@ -109,6 +118,9 @@ size_t detsz;
|
||||
Client **client;
|
||||
size_t nclient;
|
||||
size_t clientsz;
|
||||
Key **key;
|
||||
size_t keysz;
|
||||
size_t nkey;
|
||||
|
||||
Display *dpy;
|
||||
IXPServer *ixps;
|
||||
@ -195,6 +207,15 @@ unsigned long long mkqpath(unsigned char type, unsigned short pg,
|
||||
void do_pend_fcall(char *event);
|
||||
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 */
|
||||
void mouse_resize(Client *c, Align align);
|
||||
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 xy_to_align(XRectangle * rect, int x, int y);
|
||||
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 *alloc_page();
|
||||
@ -225,8 +248,6 @@ Client *win_to_client(Window w);
|
||||
int win_proto(Window w);
|
||||
int win_state(Window w);
|
||||
/*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 detached_clients();
|
||||
void attach_detached_client();
|
||||
|
@ -852,7 +852,7 @@ main(int argc, char *argv[])
|
||||
ixp_server_open_conn(&srv, ConnectionNumber(dpy), check_x_event, nil);
|
||||
|
||||
/* default settings */
|
||||
cext_strlcpy(defcolstr, BLITZ_SEL_COLOR, sizeof(defcolstr));
|
||||
cext_strlcpy(defcolstr, BLITZ_SELCOLORS, sizeof(defcolstr));
|
||||
blitz_loadcolor(dpy, screen, defcolstr, &defcolor);
|
||||
|
||||
/* X stuff */
|
||||
|
@ -6,7 +6,7 @@ include ../config.mk
|
||||
CFLAGS += -I../libixp -I../libcext
|
||||
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}
|
||||
|
||||
all: liblitz
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include <cext.h>
|
||||
|
||||
#define BLITZ_FONT "fixed"
|
||||
#define BLITZ_SEL_COLOR "#ffffff #555588 #8888bb"
|
||||
#define BLITZ_NORM_COLOR "#dddddd #666666 #999999"
|
||||
#define BLITZ_SELCOLORS "#ffffff #555588 #8888bb"
|
||||
#define BLITZ_NORMCOLORS "#dddddd #666666 #999999"
|
||||
|
||||
typedef enum {
|
||||
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);
|
||||
int blitz_distance(XRectangle * origin, XRectangle * target);
|
||||
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);
|
||||
|
@ -150,12 +150,15 @@ draw_text(Display * dpy, Draw * d)
|
||||
void
|
||||
blitz_drawmeter(Display * dpy, Draw * d)
|
||||
{
|
||||
const char *err;
|
||||
unsigned int offy, mh, val, w = d->rect.width - 4;
|
||||
|
||||
if (!d->data || strncmp(d->data, "%m:", 3))
|
||||
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);
|
||||
xdraw_border(dpy, d);
|
||||
|
||||
|
@ -47,6 +47,7 @@ int blitz_strtoalign(Align *result, char *val)
|
||||
*/
|
||||
int blitz_strtorect(XRectangle *root, XRectangle *r, char *val)
|
||||
{
|
||||
const char *err;
|
||||
char buf[64];
|
||||
char *x, *y, *w, *h;
|
||||
char *p;
|
||||
@ -73,13 +74,13 @@ int blitz_strtorect(XRectangle *root, XRectangle *r, char *val)
|
||||
}
|
||||
}
|
||||
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')))
|
||||
ry = blitz_strtonum(y, 0, 65535);
|
||||
ry = cext_strtonum(y, 0, 65535, &err);
|
||||
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')))
|
||||
rh = blitz_strtonum(h, 0, 65535);
|
||||
rh = cext_strtonum(h, 0, 65535, &err);
|
||||
|
||||
if (!sx && !sw && x && w
|
||||
&& x[0] != '-' && x[0] != '+' && w[0] != '-' && w[0] != '+') {
|
||||
@ -155,34 +156,34 @@ int blitz_strtorect(XRectangle *root, XRectangle *r, char *val)
|
||||
if (x) {
|
||||
p = strchr(x, '-');
|
||||
if (p)
|
||||
rx -= blitz_strtonum(++p, 0, 65535);
|
||||
rx -= cext_strtonum(++p, 0, 65535, &err);
|
||||
p = strchr(x, '+');
|
||||
if (p)
|
||||
rx += blitz_strtonum(++p, 0, 65535);
|
||||
rx += cext_strtonum(++p, 0, 65535, &err);
|
||||
}
|
||||
if (y) {
|
||||
p = strchr(y, '-');
|
||||
if (p)
|
||||
ry -= blitz_strtonum(++p, 0, 65535);
|
||||
ry -= cext_strtonum(++p, 0, 65535, &err);
|
||||
p = strchr(y, '+');
|
||||
if (p)
|
||||
ry += blitz_strtonum(++p, 0, 65535);
|
||||
ry += cext_strtonum(++p, 0, 65535, &err);
|
||||
}
|
||||
if (w) {
|
||||
p = strchr(w, '-');
|
||||
if (p)
|
||||
rw -= blitz_strtonum(++p, 0, 65535);
|
||||
rw -= cext_strtonum(++p, 0, 65535, &err);
|
||||
p = strchr(w, '+');
|
||||
if (p)
|
||||
rw += blitz_strtonum(++p, 0, 65535);
|
||||
rw += cext_strtonum(++p, 0, 65535, &err);
|
||||
}
|
||||
if (h) {
|
||||
p = strchr(h, '-');
|
||||
if (p)
|
||||
rh -= blitz_strtonum(++p, 0, 65535);
|
||||
rh -= cext_strtonum(++p, 0, 65535, &err);
|
||||
p = strchr(h, '+');
|
||||
if (p)
|
||||
rh += blitz_strtonum(++p, 0, 65535);
|
||||
rh += cext_strtonum(++p, 0, 65535, &err);
|
||||
}
|
||||
|
||||
if (rw < 1)
|
||||
|
80
rc/wmiirc
80
rc/wmiirc
@ -5,10 +5,6 @@ CLIENT_BAR=0
|
||||
CLIENT_BORDER=3
|
||||
HANDLEINC=1
|
||||
|
||||
SEL_COLOR='#ffffff #444466 #666688'
|
||||
NORM_COLOR='#dddddd #555555 #777777'
|
||||
FONT=fixed
|
||||
|
||||
fn xwrite { echo -n $2 | wmiir write $1 }
|
||||
|
||||
# WMIIWM CONFIGURATION
|
||||
@ -34,5 +30,79 @@ echo -n key | wmiir write /bar/new/data
|
||||
|
||||
# MISC
|
||||
xsetroot -mod 2 2 -bg '#444466' -fg '#555555'
|
||||
keys&
|
||||
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'}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user