mirror of
https://github.com/0intro/wmii
synced 2024-12-22 19:36:51 +03:00
fixed several issues, cleaned up namespaces somewhat, adapted them to wmirc
This commit is contained in:
parent
b45e29ac20
commit
3d3499ff4a
@ -22,20 +22,22 @@ Area *alloc_area(Page *p, XRectangle * r, char *layout)
|
||||
*a = zero_area;
|
||||
a->rect = *r;
|
||||
a->page = p;
|
||||
snprintf(buf, MAX_BUF, "/p/%s/a/%d", p->file[P_PREFIX]->name, id);
|
||||
snprintf(buf, MAX_BUF, "/%s/a/%d", p->file[P_PREFIX]->name, id);
|
||||
a->file[A_PREFIX] = ixp_create(ixps, buf);
|
||||
snprintf(buf, MAX_BUF, "/p/%s/a/%d/f", p->file[P_PREFIX]->name, id);
|
||||
snprintf(buf, MAX_BUF, "/%s/a/%d/f", p->file[P_PREFIX]->name, id);
|
||||
a->file[A_FRAME_PREFIX] = ixp_create(ixps, buf);
|
||||
snprintf(buf, MAX_BUF, "/p/%s/a/%d/f/sel", p->file[P_PREFIX]->name, id);
|
||||
snprintf(buf, MAX_BUF, "/%s/a/%d/f/sel", p->file[P_PREFIX]->name, id);
|
||||
a->file[A_SEL_FRAME] = ixp_create(ixps, buf);
|
||||
snprintf(buf, MAX_BUF, "/p/%s/a/%d/ctl", p->file[P_PREFIX]->name, id);
|
||||
a->file[A_SEL_FRAME]->bind = 1;
|
||||
snprintf(buf, MAX_BUF, "/%s/a/%d/ctl", p->file[P_PREFIX]->name, id);
|
||||
a->file[A_CTL] = ixp_create(ixps, buf);
|
||||
snprintf(buf, MAX_BUF, "/p/%s/a/%d/geometry", p->file[P_PREFIX]->name, id);
|
||||
snprintf(buf, MAX_BUF, "/%s/a/%d/geometry", p->file[P_PREFIX]->name, id);
|
||||
a->file[A_GEOMETRY] = ixp_create(ixps, buf);
|
||||
snprintf(buf, MAX_BUF, "/p/%s/a/%d/layout", p->file[P_PREFIX]->name, id);
|
||||
snprintf(buf, MAX_BUF, "/%s/a/%d/layout", p->file[P_PREFIX]->name, id);
|
||||
a->file[A_LAYOUT] = wmii_create_ixpfile(ixps, buf, layout);
|
||||
a->layout = get_layout(layout);
|
||||
p->area = (Area **) attach_item_end((void **) p->area, a, sizeof(Area *));
|
||||
p->file[P_SEL_AREA]->content = a->file[A_PREFIX]->content;
|
||||
p->sel = index_item((void **) p->area, a);
|
||||
return a;
|
||||
}
|
||||
@ -88,12 +90,21 @@ void detach_frame_from_area(Frame * f, int ignore_sel_and_destroy)
|
||||
|
||||
void draw_area(Area * a)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; a->frame && a->frame[i]; i++)
|
||||
draw_frame(a->frame[i]);
|
||||
}
|
||||
|
||||
void hide_area(Area * a)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; a->frame && a->frame[i]; i++)
|
||||
XUnmapWindow(dpy, a->frame[i]->win);
|
||||
}
|
||||
|
||||
void show_area(Area * a)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; a->frame && a->frame[i]; i++)
|
||||
XMapWindow(dpy, a->frame[i]->win);
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
static Frame zero_frame = { 0 };
|
||||
|
||||
static void mouse();
|
||||
static void select_client(void *obj, char *cmd);
|
||||
static void handle_after_write_frame(IXPServer * s, File * f);
|
||||
static void handle_before_read_frame(IXPServer * s, File * f);
|
||||
@ -47,10 +46,10 @@ Frame *alloc_frame(XRectangle * r)
|
||||
snprintf(buf, MAX_BUF, "/detached/f/%d/ctl", id);
|
||||
f->file[F_CTL] = ixp_create(ixps, buf);
|
||||
f->file[F_CTL]->after_write = handle_after_write_frame;
|
||||
snprintf(buf, MAX_BUF, "/detached/f/%d/size", id);
|
||||
f->file[F_SIZE] = ixp_create(ixps, buf);
|
||||
f->file[F_SIZE]->before_read = handle_before_read_frame;
|
||||
f->file[F_SIZE]->after_write = handle_after_write_frame;
|
||||
snprintf(buf, MAX_BUF, "/detached/f/%d/geometry", id);
|
||||
f->file[F_GEOMETRY] = ixp_create(ixps, buf);
|
||||
f->file[F_GEOMETRY]->before_read = handle_before_read_frame;
|
||||
f->file[F_GEOMETRY]->after_write = handle_after_write_frame;
|
||||
snprintf(buf, MAX_BUF, "/detached/f/%d/border", id);
|
||||
f->file[F_BORDER] = wmii_create_ixpfile(ixps, buf, def[WM_BORDER]->content);
|
||||
f->file[F_BORDER]->after_write = handle_after_write_frame;
|
||||
@ -189,8 +188,7 @@ static void check_dimensions(Frame * f, unsigned int tabh, unsigned int bw)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
resize_incremental(Frame * f, unsigned int tabh, unsigned int bw)
|
||||
static void resize_incremental(Frame * f, unsigned int tabh, unsigned int bw)
|
||||
{
|
||||
Client *c = f->client ? f->client[f->sel] : 0;
|
||||
if (!c)
|
||||
@ -216,20 +214,13 @@ resize_incremental(Frame * f, unsigned int tabh, unsigned int bw)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
resize_frame(Frame * f, XRectangle * r, XPoint * pt, int ignore_layout)
|
||||
void resize_frame(Frame * f, XRectangle * r, XPoint * pt)
|
||||
{
|
||||
Area *a = f->area;
|
||||
unsigned int tabh = tab_height(f);
|
||||
unsigned int bw = border_width(f);
|
||||
/* do layout stuff if necessary */
|
||||
if (!ignore_layout) {
|
||||
Area *a = f->area;
|
||||
if (a && a->layout) {
|
||||
|
||||
a->layout->resize(f, r, pt);
|
||||
} else
|
||||
f->rect = *r;
|
||||
} else
|
||||
f->rect = *r;
|
||||
|
||||
/* resize if client requests special size */
|
||||
check_dimensions(f, tabh, bw);
|
||||
@ -238,8 +229,7 @@ resize_frame(Frame * f, XRectangle * r, XPoint * pt, int ignore_layout)
|
||||
&& ((char *) f->file[F_HANDLE_INC]->content)[0] == '1')
|
||||
resize_incremental(f, tabh, bw);
|
||||
|
||||
XMoveResizeWindow(dpy, f->win, f->rect.x, f->rect.y, f->rect.width,
|
||||
f->rect.height);
|
||||
XMoveResizeWindow(dpy, f->win, f->rect.x, f->rect.y, f->rect.width, f->rect.height);
|
||||
resize_client(f, (tabh ? tabh : bw), bw);
|
||||
}
|
||||
|
||||
@ -319,6 +309,7 @@ void draw_frame(Frame * f)
|
||||
|
||||
void handle_frame_buttonpress(XButtonEvent * e, Frame * f)
|
||||
{
|
||||
Align align;
|
||||
int bindex;
|
||||
int size = count_items((void **) f->client);
|
||||
int cindex = e->x / f->rect.width / size;
|
||||
@ -330,7 +321,13 @@ void handle_frame_buttonpress(XButtonEvent * e, Frame * f)
|
||||
return;
|
||||
}
|
||||
if (e->button == Button1) {
|
||||
mouse();
|
||||
if (!(f = SELFRAME(page[sel])))
|
||||
return;
|
||||
align = cursor_to_align(f->cursor);
|
||||
if (align == CENTER)
|
||||
mouse_move(f);
|
||||
else
|
||||
mouse_resize(f, align);
|
||||
return;
|
||||
}
|
||||
bindex = F_EVENT_B2PRESS - 2 + e->button;
|
||||
@ -348,7 +345,7 @@ void attach_client_to_frame(Frame * f, Client * c)
|
||||
f->sel = index_item((void **) f->client, c);
|
||||
c->frame = f;
|
||||
reparent_client(c, f->win, border_width(f), tab_height(f));
|
||||
resize_frame(f, &f->rect, 0, 1);
|
||||
resize_frame(f, &f->rect, 0);
|
||||
show_client(c);
|
||||
sel_client(c);
|
||||
}
|
||||
@ -376,22 +373,6 @@ void detach_client_from_frame(Client * c)
|
||||
}
|
||||
}
|
||||
|
||||
static void mouse()
|
||||
{
|
||||
Frame *f;
|
||||
Align align;
|
||||
|
||||
if (!page)
|
||||
return;
|
||||
if (!(f = SELFRAME(page[sel])))
|
||||
return;
|
||||
align = cursor_to_align(f->cursor);
|
||||
if (align == CENTER)
|
||||
mouse_move(f);
|
||||
else
|
||||
mouse_resize(f, align);
|
||||
}
|
||||
|
||||
static void select_client(void *obj, char *cmd)
|
||||
{
|
||||
Frame *f = obj;
|
||||
@ -418,7 +399,7 @@ static void handle_before_read_frame(IXPServer * s, File * f)
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; frame && frame[i]; i++) {
|
||||
if (f == frame[i]->file[F_SIZE]) {
|
||||
if (f == frame[i]->file[F_GEOMETRY]) {
|
||||
char buf[64];
|
||||
snprintf(buf, 64, "%d,%d,%d,%d", frame[i]->rect.x,
|
||||
frame[i]->rect.y, frame[i]->rect.width,
|
||||
@ -449,12 +430,12 @@ static void handle_after_write_frame(IXPServer * s, File * f)
|
||||
draw_page(frame[i]->area->page);
|
||||
}
|
||||
return;
|
||||
} else if (f == frame[i]->file[F_SIZE]) {
|
||||
char *size = frame[i]->file[F_SIZE]->content;
|
||||
} else if (f == frame[i]->file[F_GEOMETRY]) {
|
||||
char *size = frame[i]->file[F_GEOMETRY]->content;
|
||||
if (size && strrchr(size, ',')) {
|
||||
XRectangle frect;
|
||||
blitz_strtorect(&rect, &frect, size);
|
||||
resize_frame(frame[i], &frect, 0, 0);
|
||||
resize_frame(frame[i], &frect, 0);
|
||||
draw_page(frame[i]->area->page);
|
||||
}
|
||||
return;
|
||||
|
@ -56,7 +56,7 @@ static void arrange_column(Area * a, Column * col)
|
||||
col->frame[i]->rect.height = height;
|
||||
col->frame[i]->rect.y = i * height;
|
||||
}
|
||||
resize_frame(col->frame[i], &col->frame[i]->rect, 0, 1);
|
||||
resize_frame(col->frame[i], &col->frame[i]->rect, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,13 +236,13 @@ static void drop_resize(Frame * f, XRectangle * new)
|
||||
Frame *f = west->frame[i];
|
||||
f->rect.x = west->rect.x;
|
||||
f->rect.width = west->rect.width;
|
||||
resize_frame(f, &f->rect, 0, 1);
|
||||
resize_frame(f, &f->rect, 0);
|
||||
}
|
||||
for (i = 0; col->frame && col->frame[i]; i++) {
|
||||
Frame *f = col->frame[i];
|
||||
f->rect.x = col->rect.x;
|
||||
f->rect.width = col->rect.width;
|
||||
resize_frame(f, &f->rect, 0, 1);
|
||||
resize_frame(f, &f->rect, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -260,13 +260,13 @@ static void drop_resize(Frame * f, XRectangle * new)
|
||||
Frame *f = col->frame[i];
|
||||
f->rect.x = col->rect.x;
|
||||
f->rect.width = col->rect.width;
|
||||
resize_frame(f, &f->rect, 0, 1);
|
||||
resize_frame(f, &f->rect, 0);
|
||||
}
|
||||
for (i = 0; east->frame && east->frame[i]; i++) {
|
||||
Frame *f = east->frame[i];
|
||||
f->rect.x = east->rect.x;
|
||||
f->rect.width = east->rect.width;
|
||||
resize_frame(f, &f->rect, 0, 1);
|
||||
resize_frame(f, &f->rect, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -284,8 +284,8 @@ static void drop_resize(Frame * f, XRectangle * new)
|
||||
north->rect.height = new->y - north->rect.y;
|
||||
f->rect.width += new->y - north->rect.y;
|
||||
f->rect.y = new->y;
|
||||
resize_frame(north, &north->rect, 0, 1);
|
||||
resize_frame(f, &f->rect, 0, 1);
|
||||
resize_frame(north, &north->rect, 0);
|
||||
resize_frame(f, &f->rect, 0);
|
||||
}
|
||||
}
|
||||
if (new->y + new->height > f->rect.y + f->rect.height) {
|
||||
@ -297,8 +297,8 @@ static void drop_resize(Frame * f, XRectangle * new)
|
||||
south->rect.x = new->x + new->width;
|
||||
f->rect.x = new->x;
|
||||
f->rect.width = new->width;
|
||||
resize_frame(f, &f->rect, 0, 1);
|
||||
resize_frame(south, &south->rect, 0, 1);
|
||||
resize_frame(f, &f->rect, 0);
|
||||
resize_frame(south, &south->rect, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -340,8 +340,8 @@ static void _drop_move(Frame * f, XRectangle * new, XPoint * pt)
|
||||
fp->rect = tmpr;
|
||||
tgt->frame[idxf] = tgt->frame[idxfp];
|
||||
tgt->frame[idxfp] = tmpf;
|
||||
resize_frame(f, &f->rect, 0, 1);
|
||||
resize_frame(fp, &fp->rect, 0, 1);
|
||||
resize_frame(f, &f->rect, 0);
|
||||
resize_frame(fp, &fp->rect, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ static void detach_float(Area * a, Client * c)
|
||||
}
|
||||
}
|
||||
|
||||
static void resize_float(Frame * f, XRectangle * new, XPoint * pt)
|
||||
static void resize_float(Frame *f, XRectangle *new, XPoint *pt)
|
||||
{
|
||||
f->rect = *new;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ void mouse_move(Frame * f)
|
||||
case ButtonRelease:
|
||||
if (!first) {
|
||||
draw_pseudo_border(&frect);
|
||||
resize_frame(f, &frect, &pt, 0);
|
||||
resize_frame(f, &frect, &pt);
|
||||
}
|
||||
draw_page(page[sel]);
|
||||
free(rects);
|
||||
@ -567,7 +567,7 @@ void mouse_resize(Frame * f, Align align)
|
||||
draw_pseudo_border(&frect);
|
||||
pt.x = px;
|
||||
pt.y = py;
|
||||
resize_frame(f, &frect, &pt, 0);
|
||||
resize_frame(f, &frect, &pt);
|
||||
}
|
||||
XUngrabPointer(dpy, CurrentTime /* ev.xbutton.time */ );
|
||||
XUngrabServer(dpy);
|
||||
|
@ -16,7 +16,7 @@ static Page zero_page = { 0 };
|
||||
static void select_frame(void *obj, char *cmd);
|
||||
static void handle_after_write_page(IXPServer * s, File * f);
|
||||
|
||||
/* action table for /page/?/ namespace */
|
||||
/* action table for /?/ namespace */
|
||||
Action page_acttbl[] = {
|
||||
{"select", select_frame},
|
||||
{0, 0}
|
||||
@ -25,18 +25,21 @@ Action page_acttbl[] = {
|
||||
Page *alloc_page()
|
||||
{
|
||||
Page *p = emalloc(sizeof(Page));
|
||||
char buf[MAX_BUF];
|
||||
char buf[MAX_BUF], buf2[16];
|
||||
int id = count_items((void **) page) + 1;
|
||||
|
||||
snprintf(buf2, sizeof(buf2), "%d", id);
|
||||
*p = zero_page;
|
||||
snprintf(buf, sizeof(buf), "/p/%d", id);
|
||||
snprintf(buf, sizeof(buf), "/%d", id);
|
||||
p->file[P_PREFIX] = ixp_create(ixps, buf);
|
||||
snprintf(buf, sizeof(buf), "/p/%d/a", id);
|
||||
snprintf(buf, sizeof(buf), "/%d/name", id);
|
||||
p->file[P_NAME] = wmii_create_ixpfile(ixps, buf, buf2);
|
||||
snprintf(buf, sizeof(buf), "/%d/a", id);
|
||||
p->file[P_AREA_PREFIX] = ixp_create(ixps, buf);
|
||||
snprintf(buf, sizeof(buf), "/p/%d/a/sel", id);
|
||||
snprintf(buf, sizeof(buf), "/%d/a/sel", id);
|
||||
p->file[P_SEL_AREA] = ixp_create(ixps, buf);
|
||||
p->file[P_SEL_AREA]->bind = 1; /* mount point */
|
||||
snprintf(buf, sizeof(buf), "/p/%d/ctl", id);
|
||||
snprintf(buf, sizeof(buf), "/%d/ctl", id);
|
||||
p->file[P_CTL] = ixp_create(ixps, buf);
|
||||
p->file[P_CTL]->after_write = handle_after_write_page;
|
||||
alloc_area(p, &rect, "float");
|
||||
|
16
cmd/wm/wm.c
16
cmd/wm/wm.c
@ -577,22 +577,22 @@ static void init_default()
|
||||
def[WM_DETACHED_CLIENT] = ixp_create(ixps, "/detached/c");
|
||||
def[WM_TRANS_COLOR] = wmii_create_ixpfile(ixps, "/default/transcolor", BLITZ_SEL_FG_COLOR);
|
||||
def[WM_TRANS_COLOR]->after_write = handle_after_write;
|
||||
def[WM_SEL_BG_COLOR] = wmii_create_ixpfile(ixps, "/default/selstyle/bgcolor", BLITZ_SEL_BG_COLOR);
|
||||
def[WM_SEL_FG_COLOR] = wmii_create_ixpfile(ixps, "/default/selstyle/fgcolor", BLITZ_SEL_FG_COLOR);
|
||||
def[WM_SEL_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/default/selstyle/fgcolor", BLITZ_SEL_BORDER_COLOR);
|
||||
def[WM_NORM_BG_COLOR] = wmii_create_ixpfile(ixps, "/default/normstyle/bgcolor", BLITZ_NORM_BG_COLOR);
|
||||
def[WM_NORM_FG_COLOR] = wmii_create_ixpfile(ixps, "/default/normstyle/fgcolor", BLITZ_NORM_FG_COLOR);
|
||||
def[WM_NORM_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/default/normstyle/fgcolor", BLITZ_NORM_BORDER_COLOR);
|
||||
def[WM_SEL_BG_COLOR] = wmii_create_ixpfile(ixps, "/default/sstyle/bgcolor", BLITZ_SEL_BG_COLOR);
|
||||
def[WM_SEL_FG_COLOR] = wmii_create_ixpfile(ixps, "/default/sstyle/fgcolor", BLITZ_SEL_FG_COLOR);
|
||||
def[WM_SEL_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/default/sstyle/fgcolor", BLITZ_SEL_BORDER_COLOR);
|
||||
def[WM_NORM_BG_COLOR] = wmii_create_ixpfile(ixps, "/default/nstyle/bgcolor", BLITZ_NORM_BG_COLOR);
|
||||
def[WM_NORM_FG_COLOR] = wmii_create_ixpfile(ixps, "/default/nstyle/fgcolor", BLITZ_NORM_FG_COLOR);
|
||||
def[WM_NORM_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/default/nstyle/fgcolor", BLITZ_NORM_BORDER_COLOR);
|
||||
def[WM_FONT] = wmii_create_ixpfile(ixps, "/default/font", BLITZ_FONT);
|
||||
def[WM_FONT]->after_write = handle_after_write;
|
||||
def[WM_PAGE_SIZE] = wmii_create_ixpfile(ixps, "/default/pageize", "0,0,east,south-16");
|
||||
def[WM_PAGE_GEOMETRY] = wmii_create_ixpfile(ixps, "/default/pagegeometry ", "0,0,east,south-16");
|
||||
def[WM_SNAP_VALUE] = wmii_create_ixpfile(ixps, "/default/snapvalue", "20"); /* 0..1000 */
|
||||
def[WM_BORDER] = wmii_create_ixpfile(ixps, "/default/border", "1");
|
||||
def[WM_TAB] = wmii_create_ixpfile(ixps, "/default/tab", "1");
|
||||
def[WM_HANDLE_INC] = wmii_create_ixpfile(ixps, "/default/handleinc", "1");
|
||||
def[WM_LOCKED] = wmii_create_ixpfile(ixps, "/default/locked", "1");
|
||||
def[WM_LAYOUT] = wmii_create_ixpfile(ixps, "/default/layout", LAYOUT);
|
||||
def[WM_SEL_PAGE] = ixp_create(ixps, "/p/sel");
|
||||
def[WM_SEL_PAGE] = ixp_create(ixps, "/sel");
|
||||
def[WM_EVENT_PAGE_UPDATE] = ixp_create(ixps, "/default/event/pageupdate");
|
||||
def[WM_EVENT_CLIENT_UPDATE] = ixp_create(ixps, "/default/event/clientupdate");
|
||||
def[WM_EVENT_B1PRESS] = ixp_create(ixps, "/default/event/b1press");
|
||||
|
@ -12,6 +12,7 @@
|
||||
/* array indexes of page file pointers */
|
||||
enum {
|
||||
P_PREFIX,
|
||||
P_NAME,
|
||||
P_AREA_PREFIX,
|
||||
P_SEL_AREA,
|
||||
P_CTL,
|
||||
@ -35,7 +36,7 @@ enum {
|
||||
F_CLIENT_PREFIX,
|
||||
F_SEL_CLIENT,
|
||||
F_CTL,
|
||||
F_SIZE,
|
||||
F_GEOMETRY,
|
||||
F_BORDER,
|
||||
F_TAB,
|
||||
F_HANDLE_INC,
|
||||
@ -73,7 +74,7 @@ enum {
|
||||
WM_NORM_BORDER_COLOR,
|
||||
WM_NORM_FG_COLOR,
|
||||
WM_FONT,
|
||||
WM_PAGE_SIZE,
|
||||
WM_PAGE_GEOMETRY,
|
||||
WM_BORDER,
|
||||
WM_TAB,
|
||||
WM_HANDLE_INC,
|
||||
@ -92,7 +93,7 @@ enum {
|
||||
};
|
||||
|
||||
#define PROTO_DEL 1
|
||||
#define BORDER_WIDTH 3
|
||||
#define BORDER_WIDTH 1
|
||||
#define LAYOUT "column"
|
||||
#define GAP 5
|
||||
|
||||
@ -241,7 +242,7 @@ void sel_frame(Frame * f, int raise);
|
||||
Frame *win_to_frame(Window w);
|
||||
Frame *alloc_frame(XRectangle * r);
|
||||
void destroy_frame(Frame * f);
|
||||
void resize_frame(Frame * f, XRectangle * r, XPoint * pt, int ignore_layout);
|
||||
void resize_frame(Frame * f, XRectangle * r, XPoint * pt);
|
||||
void draw_frame(Frame * f);
|
||||
void handle_frame_buttonpress(XButtonEvent * e, Frame * f);
|
||||
void attach_client_to_frame(Frame * f, Client * c);
|
||||
|
@ -22,10 +22,9 @@
|
||||
typedef enum {
|
||||
K_CTL,
|
||||
K_LOOKUP,
|
||||
K_SIZE,
|
||||
K_GRAB_KB,
|
||||
K_TEXT_FONT,
|
||||
K_TEXT_COLOR,
|
||||
K_FONT,
|
||||
K_FG_COLOR,
|
||||
K_BG_COLOR,
|
||||
K_BORDER_COLOR,
|
||||
K_LAST
|
||||
@ -55,6 +54,7 @@ static File *files[K_LAST];
|
||||
static int grabkb = 0;
|
||||
static unsigned int num_lock_mask, valid_mask;
|
||||
static char buf[MAX_BUF];
|
||||
static XFontStruct *font;
|
||||
|
||||
static Shortcut zero_shortcut = { "", 0, 0, 0, 0 };
|
||||
|
||||
@ -301,20 +301,19 @@ static void update()
|
||||
/*
|
||||
* Function assumes following fs-structure:
|
||||
*
|
||||
* /box/style/text-align "<align>"
|
||||
* /box/style/text-font "<value>"
|
||||
* /box/style/text-color "#RRGGBBAA"
|
||||
* /box/style/bg-color "#RRGGBBAA"
|
||||
* /box/style/font "<value>"
|
||||
* /box/style/fgcolor "#RRGGBBAA"
|
||||
* /box/style/bgcolor "#RRGGBBAA"
|
||||
* /box/style/bordercolor "#RRGGBBAA"
|
||||
*/
|
||||
static void draw_shortcut_box(char *text)
|
||||
{
|
||||
Draw d = { 0 };
|
||||
|
||||
d.font = blitz_getfont(dpy, files[K_TEXT_FONT]->content);
|
||||
d.font = font;
|
||||
krect.width = XTextWidth(d.font, text, strlen(text)) + krect.height;
|
||||
center();
|
||||
XMoveResizeWindow(dpy, win, krect.x, krect.y, krect.width,
|
||||
krect.height);
|
||||
XMoveResizeWindow(dpy, win, krect.x, krect.y, krect.width, krect.height);
|
||||
|
||||
/* default stuff */
|
||||
d.gc = gc;
|
||||
@ -324,9 +323,8 @@ static void draw_shortcut_box(char *text)
|
||||
d.rect.width = krect.width;
|
||||
d.rect.height = krect.height;
|
||||
d.bg = blitz_loadcolor(dpy, screen_num, files[K_BG_COLOR]->content);
|
||||
d.fg = blitz_loadcolor(dpy, screen_num, files[K_TEXT_COLOR]->content);
|
||||
d.border =
|
||||
blitz_loadcolor(dpy, screen_num, files[K_BORDER_COLOR]->content);
|
||||
d.fg = blitz_loadcolor(dpy, screen_num, files[K_FG_COLOR]->content);
|
||||
d.border = blitz_loadcolor(dpy, screen_num, files[K_BORDER_COLOR]->content);
|
||||
blitz_drawlabel(dpy, &d);
|
||||
}
|
||||
|
||||
@ -372,10 +370,6 @@ static void handle_after_write(IXPServer * s, File * f)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (files[K_SIZE] == f) {
|
||||
char *size = files[K_SIZE]->content;
|
||||
if (size && strrchr(size, ','))
|
||||
blitz_strtorect(&rect, &krect, size);
|
||||
} else if (f == files[K_GRAB_KB]) {
|
||||
grabkb = _strtonum(files[K_GRAB_KB]->content, 0, 1);
|
||||
if (!grabkb) {
|
||||
@ -384,24 +378,15 @@ static void handle_after_write(IXPServer * s, File * f)
|
||||
XSync(dpy, False);
|
||||
} else
|
||||
update();
|
||||
} else if (f == files[K_FONT]) {
|
||||
XFreeFont(dpy, font);
|
||||
font = blitz_getfont(dpy, files[K_FONT]->content);
|
||||
} else if (f == files[K_LOOKUP]) {
|
||||
update();
|
||||
}
|
||||
check_event(0);
|
||||
}
|
||||
|
||||
static void handle_before_read(IXPServer * s, File * f)
|
||||
{
|
||||
if (f != files[K_SIZE])
|
||||
return;
|
||||
snprintf(buf, sizeof(buf), "%d,%d,%d,%d", krect.x, krect.y,
|
||||
krect.width, krect.height);
|
||||
if (f->content)
|
||||
free(f->content);
|
||||
f->content = strdup(buf);
|
||||
f->size = strlen(buf);
|
||||
}
|
||||
|
||||
static void run(char *size)
|
||||
{
|
||||
XSetWindowAttributes wa;
|
||||
@ -415,22 +400,14 @@ static void run(char *size)
|
||||
files[K_CTL]->after_write = handle_after_write;
|
||||
files[K_LOOKUP] = ixp_create(ixps, "/lookup");
|
||||
files[K_LOOKUP]->after_write = handle_after_write;
|
||||
files[K_SIZE] = ixp_create(ixps, "/size");
|
||||
files[K_SIZE]->before_read = handle_before_read;
|
||||
files[K_SIZE]->after_write = handle_after_write;
|
||||
files[K_GRAB_KB] = wmii_create_ixpfile(ixps, "/grab-keyb", "0");
|
||||
files[K_GRAB_KB] = wmii_create_ixpfile(ixps, "/grabkeyb", "0");
|
||||
files[K_GRAB_KB]->after_write = handle_after_write;
|
||||
files[K_TEXT_FONT] =
|
||||
wmii_create_ixpfile(ixps, "/box/style/text-font", BLITZ_FONT);
|
||||
files[K_TEXT_COLOR] =
|
||||
wmii_create_ixpfile(ixps, "/box/style/text-color",
|
||||
BLITZ_SEL_FG_COLOR);
|
||||
files[K_BG_COLOR] =
|
||||
wmii_create_ixpfile(ixps, "/box/style/bg-color",
|
||||
BLITZ_SEL_BG_COLOR);
|
||||
files[K_BORDER_COLOR] =
|
||||
wmii_create_ixpfile(ixps, "/box/style/border-color",
|
||||
BLITZ_SEL_BORDER_COLOR);
|
||||
files[K_FONT] = wmii_create_ixpfile(ixps, "/box/font", BLITZ_FONT);
|
||||
files[K_FONT]->after_write = handle_after_write;
|
||||
font = blitz_getfont(dpy, files[K_FONT]->content);
|
||||
files[K_FG_COLOR] = wmii_create_ixpfile(ixps, "/box/fgcolor", BLITZ_SEL_FG_COLOR);
|
||||
files[K_BG_COLOR] = wmii_create_ixpfile(ixps, "/box/bgcolor", BLITZ_SEL_BG_COLOR);
|
||||
files[K_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/box/bordercolor", BLITZ_SEL_BORDER_COLOR);
|
||||
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
|
160
cmd/wmimenu.c
160
cmd/wmimenu.c
@ -23,18 +23,18 @@
|
||||
/* array indexes for file pointers */
|
||||
typedef enum {
|
||||
M_CTL,
|
||||
M_SIZE,
|
||||
M_GEOMETRY,
|
||||
M_PRE_COMMAND,
|
||||
M_COMMAND,
|
||||
M_HISTORY,
|
||||
M_LOOKUP,
|
||||
M_TEXT_FONT,
|
||||
M_SELECTED_BG_COLOR,
|
||||
M_SELECTED_TEXT_COLOR,
|
||||
M_SELECTED_BORDER_COLOR,
|
||||
M_NORMAL_BG_COLOR,
|
||||
M_NORMAL_TEXT_COLOR,
|
||||
M_NORMAL_BORDER_COLOR,
|
||||
M_FONT,
|
||||
M_SEL_BG_COLOR,
|
||||
M_SEL_TEXT_COLOR,
|
||||
M_SEL_BORDER_COLOR,
|
||||
M_NORM_BG_COLOR,
|
||||
M_NORM_TEXT_COLOR,
|
||||
M_NORM_BORDER_COLOR,
|
||||
M_RETARDED,
|
||||
M_LAST
|
||||
} InputIndexes;
|
||||
@ -61,6 +61,7 @@ static File **history = 0;
|
||||
static int sel_history = 0;
|
||||
static Pixmap pmap;
|
||||
static const int seek = 30; /* 30px */
|
||||
static XFontStruct *font;
|
||||
|
||||
static void check_event(Connection * c);
|
||||
static void draw_menu(void);
|
||||
@ -93,10 +94,7 @@ static void add_history(char *cmd)
|
||||
{
|
||||
char buf[MAX_BUF];
|
||||
snprintf(buf, MAX_BUF, "/history/%ld", (long) time(0));
|
||||
history = (File **) attach_item_begin((void **) history,
|
||||
wmii_create_ixpfile(ixps, buf,
|
||||
cmd),
|
||||
sizeof(File *));
|
||||
history = (File **) attach_item_begin((void **) history, wmii_create_ixpfile(ixps, buf, cmd), sizeof(File *));
|
||||
}
|
||||
|
||||
static void _exec(char *cmd)
|
||||
@ -178,13 +176,11 @@ void set_text(char *text)
|
||||
static void update_offsets()
|
||||
{
|
||||
int i;
|
||||
XFontStruct *font;
|
||||
unsigned int w = cmdw + 2 * seek;
|
||||
|
||||
if (!items)
|
||||
return;
|
||||
|
||||
font = blitz_getfont(dpy, files[M_TEXT_FONT]->content);
|
||||
|
||||
/* calc next offset */
|
||||
for (i = offset[OFF_CURR]; items[i]; i++) {
|
||||
@ -204,14 +200,12 @@ static void update_offsets()
|
||||
break;
|
||||
}
|
||||
offset[OFF_PREV] = i + 1;
|
||||
XFreeFont(dpy, font);
|
||||
}
|
||||
|
||||
static int update_items(char *pattern)
|
||||
{
|
||||
size_t plen = pattern ? strlen(pattern) : 0, size = 0, max = 0, len;
|
||||
int matched = pattern ? plen == 0 : 1;
|
||||
XFontStruct *font;
|
||||
File *f, *p, *maxitem = 0;
|
||||
|
||||
cmdw = 0;
|
||||
@ -224,8 +218,6 @@ static int update_items(char *pattern)
|
||||
if (!f || !is_directory(f))
|
||||
return 0;
|
||||
|
||||
font = blitz_getfont(dpy, files[M_TEXT_FONT]->content);
|
||||
|
||||
/* build new items */
|
||||
for (p = f->content; p; p = p->next) {
|
||||
size++;
|
||||
@ -273,7 +265,6 @@ static int update_items(char *pattern)
|
||||
}
|
||||
items[size] = 0;
|
||||
update_offsets();
|
||||
XFreeFont(dpy, font);
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -283,19 +274,15 @@ static void draw_menu()
|
||||
Draw d = { 0 };
|
||||
unsigned int offx = 0;
|
||||
int i = 0;
|
||||
XFontStruct *font = blitz_getfont(dpy, files[M_TEXT_FONT]->content);
|
||||
|
||||
d.gc = gc;
|
||||
d.font = font;
|
||||
d.drawable = pmap;
|
||||
d.rect = mrect;
|
||||
d.rect.x = 0;
|
||||
d.rect.y = 0;
|
||||
d.bg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_NORMAL_BG_COLOR]->content);
|
||||
d.border =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_NORMAL_BORDER_COLOR]->content);
|
||||
d.bg = blitz_loadcolor(dpy, screen_num, files[M_NORM_BG_COLOR]->content);
|
||||
d.border = blitz_loadcolor(dpy, screen_num, files[M_NORM_BORDER_COLOR]->content);
|
||||
blitz_drawlabelnoborder(dpy, &d);
|
||||
|
||||
/* print command */
|
||||
@ -303,7 +290,7 @@ static void draw_menu()
|
||||
d.font = font;
|
||||
d.fg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_NORMAL_TEXT_COLOR]->content);
|
||||
files[M_NORM_TEXT_COLOR]->content);
|
||||
d.data = files[M_COMMAND]->content;
|
||||
if (cmdw && items && items[0])
|
||||
d.rect.width = cmdw;
|
||||
@ -312,12 +299,8 @@ static void draw_menu()
|
||||
|
||||
d.align = CENTER;
|
||||
if (items && items[0]) {
|
||||
d.bg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_NORMAL_BG_COLOR]->content);
|
||||
d.fg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_NORMAL_TEXT_COLOR]->content);
|
||||
d.bg = blitz_loadcolor(dpy, screen_num, files[M_NORM_BG_COLOR]->content);
|
||||
d.fg = blitz_loadcolor(dpy, screen_num, files[M_NORM_TEXT_COLOR]->content);
|
||||
d.data = offset[OFF_CURR] ? "<" : 0;
|
||||
d.rect.x = offx;
|
||||
d.rect.width = seek;
|
||||
@ -332,50 +315,26 @@ static void draw_menu()
|
||||
XTextWidth(d.font, d.data, strlen(d.data)) + mrect.height;
|
||||
offx += d.rect.width;
|
||||
if (i == item) {
|
||||
d.bg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_SELECTED_BG_COLOR]->content);
|
||||
d.fg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_SELECTED_TEXT_COLOR]->content);
|
||||
d.border =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_SELECTED_BORDER_COLOR]->
|
||||
content);
|
||||
d.bg = blitz_loadcolor(dpy, screen_num, files[M_SEL_BG_COLOR]->content);
|
||||
d.fg = blitz_loadcolor(dpy, screen_num, files[M_SEL_TEXT_COLOR]->content);
|
||||
d.border = blitz_loadcolor(dpy, screen_num, files[M_SEL_BORDER_COLOR]-> content);
|
||||
blitz_drawlabel(dpy, &d);
|
||||
} else if (!i && item == -1) {
|
||||
/* fg and bg are inverted */
|
||||
d.fg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_SELECTED_BG_COLOR]->content);
|
||||
d.bg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_SELECTED_TEXT_COLOR]->content);
|
||||
d.border =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_SELECTED_BORDER_COLOR]->
|
||||
content);
|
||||
d.fg = blitz_loadcolor(dpy, screen_num, files[M_SEL_BG_COLOR]->content);
|
||||
d.bg = blitz_loadcolor(dpy, screen_num, files[M_SEL_TEXT_COLOR]->content);
|
||||
d.border = blitz_loadcolor(dpy, screen_num, files[M_SEL_BORDER_COLOR]->content);
|
||||
blitz_drawlabel(dpy, &d);
|
||||
} else {
|
||||
d.bg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_NORMAL_BG_COLOR]->content);
|
||||
d.fg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_NORMAL_TEXT_COLOR]->content);
|
||||
d.border =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_NORMAL_BORDER_COLOR]->content);
|
||||
d.bg = blitz_loadcolor(dpy, screen_num, files[M_NORM_BG_COLOR]->content);
|
||||
d.fg = blitz_loadcolor(dpy, screen_num, files[M_NORM_TEXT_COLOR]->content);
|
||||
d.border = blitz_loadcolor(dpy, screen_num, files[M_NORM_BORDER_COLOR]->content);
|
||||
blitz_drawlabelnoborder(dpy, &d);
|
||||
}
|
||||
}
|
||||
|
||||
d.bg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_NORMAL_BG_COLOR]->content);
|
||||
d.fg =
|
||||
blitz_loadcolor(dpy, screen_num,
|
||||
files[M_NORMAL_TEXT_COLOR]->content);
|
||||
d.bg = blitz_loadcolor(dpy, screen_num, files[M_NORM_BG_COLOR]->content);
|
||||
d.fg = blitz_loadcolor(dpy, screen_num, files[M_NORM_TEXT_COLOR]->content);
|
||||
d.data = items[i] ? ">" : 0;
|
||||
d.rect.x = mrect.width - seek;
|
||||
d.rect.width = seek;
|
||||
@ -383,7 +342,6 @@ static void draw_menu()
|
||||
}
|
||||
XCopyArea(dpy, pmap, win, gc, 0, 0, mrect.width, mrect.height, 0, 0);
|
||||
XSync(dpy, False);
|
||||
XFreeFont(dpy, font);
|
||||
}
|
||||
|
||||
static void handle_kpress(XKeyEvent * e)
|
||||
@ -561,19 +519,20 @@ static void handle_after_write(IXPServer * s, File * f)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (files[M_SIZE] == f) {
|
||||
char *size = files[M_SIZE]->content;
|
||||
} else if (files[M_GEOMETRY] == f) {
|
||||
char *size = files[M_GEOMETRY]->content;
|
||||
if (size && strrchr(size, ',')) {
|
||||
blitz_strtorect(&rect, &mrect, size);
|
||||
XFreePixmap(dpy, pmap);
|
||||
XMoveResizeWindow(dpy, win, mrect.x, mrect.y,
|
||||
mrect.width, mrect.height);
|
||||
XMoveResizeWindow(dpy, win, mrect.x, mrect.y, mrect.width, mrect.height);
|
||||
XSync(dpy, False);
|
||||
pmap = XCreatePixmap(dpy, win, mrect.width, mrect.height,
|
||||
DefaultDepth(dpy, screen_num));
|
||||
pmap = XCreatePixmap(dpy, win, mrect.width, mrect.height, DefaultDepth(dpy, screen_num));
|
||||
XSync(dpy, False);
|
||||
draw_menu();
|
||||
}
|
||||
} else if (files[M_FONT] == f) {
|
||||
XFreeFont(dpy, font);
|
||||
font = blitz_getfont(dpy, files[M_FONT]->content);
|
||||
} else if (files[M_COMMAND] == f) {
|
||||
update_items(files[M_COMMAND]->content);
|
||||
draw_menu();
|
||||
@ -584,7 +543,7 @@ static void handle_after_write(IXPServer * s, File * f)
|
||||
static void handle_before_read(IXPServer * s, File * f)
|
||||
{
|
||||
char buf[64];
|
||||
if (f != files[M_SIZE])
|
||||
if (f != files[M_GEOMETRY])
|
||||
return;
|
||||
snprintf(buf, sizeof(buf), "%d,%d,%d,%d", mrect.x, mrect.y,
|
||||
mrect.width, mrect.height);
|
||||
@ -605,35 +564,23 @@ static void run(char *size)
|
||||
exit(1);
|
||||
}
|
||||
files[M_CTL]->after_write = handle_after_write;
|
||||
files[M_SIZE] = ixp_create(ixps, "/size");
|
||||
files[M_SIZE]->before_read = handle_before_read;
|
||||
files[M_SIZE]->after_write = handle_after_write;
|
||||
files[M_GEOMETRY] = ixp_create(ixps, "/geometry");
|
||||
files[M_GEOMETRY]->before_read = handle_before_read;
|
||||
files[M_GEOMETRY]->after_write = handle_after_write;
|
||||
files[M_PRE_COMMAND] = ixp_create(ixps, "/precmd");
|
||||
files[M_COMMAND] = ixp_create(ixps, "/cmd");
|
||||
files[M_COMMAND]->after_write = handle_after_write;
|
||||
files[M_HISTORY] = ixp_create(ixps, "/history");
|
||||
add_history("");
|
||||
files[M_LOOKUP] = ixp_create(ixps, "/lookup");
|
||||
files[M_TEXT_FONT] =
|
||||
wmii_create_ixpfile(ixps, "/style/text-font", BLITZ_FONT);
|
||||
files[M_SELECTED_BG_COLOR] =
|
||||
wmii_create_ixpfile(ixps, "/sel-style/bg-color",
|
||||
BLITZ_SEL_BG_COLOR);
|
||||
files[M_SELECTED_TEXT_COLOR] =
|
||||
wmii_create_ixpfile(ixps, "/sel-style/text-color",
|
||||
BLITZ_SEL_FG_COLOR);
|
||||
files[M_SELECTED_BORDER_COLOR] =
|
||||
wmii_create_ixpfile(ixps, "/sel-style/border-color",
|
||||
BLITZ_SEL_BORDER_COLOR);
|
||||
files[M_NORMAL_BG_COLOR] =
|
||||
wmii_create_ixpfile(ixps, "/norm-style/bg-color",
|
||||
BLITZ_NORM_BG_COLOR);
|
||||
files[M_NORMAL_TEXT_COLOR] =
|
||||
wmii_create_ixpfile(ixps, "/norm-style/text-color",
|
||||
BLITZ_NORM_FG_COLOR);
|
||||
files[M_NORMAL_BORDER_COLOR] =
|
||||
wmii_create_ixpfile(ixps, "/norm-style/border-color",
|
||||
BLITZ_NORM_BORDER_COLOR);
|
||||
files[M_FONT] = wmii_create_ixpfile(ixps, "/font", BLITZ_FONT);
|
||||
font = blitz_getfont(dpy, files[M_FONT]->content);
|
||||
files[M_SEL_BG_COLOR] = wmii_create_ixpfile(ixps, "/sstyle/bgcolor", BLITZ_SEL_BG_COLOR);
|
||||
files[M_SEL_TEXT_COLOR] = wmii_create_ixpfile(ixps, "/sstyle/fgcolor", BLITZ_SEL_FG_COLOR);
|
||||
files[M_SEL_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/sstyle/bordercolor", BLITZ_SEL_BORDER_COLOR);
|
||||
files[M_NORM_BG_COLOR] = wmii_create_ixpfile(ixps, "/nstyle/bgcolor", BLITZ_NORM_BG_COLOR);
|
||||
files[M_NORM_TEXT_COLOR] = wmii_create_ixpfile(ixps, "/nstyle/fgcolor", BLITZ_NORM_FG_COLOR);
|
||||
files[M_NORM_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/nstyle/bordercolor", BLITZ_NORM_BORDER_COLOR);
|
||||
files[M_RETARDED] = ixp_create(ixps, "/retarded");
|
||||
|
||||
wa.override_redirect = 1;
|
||||
@ -648,14 +595,12 @@ static void run(char *size)
|
||||
if (!mrect.width)
|
||||
mrect.width = DisplayWidth(dpy, screen_num);
|
||||
if (!mrect.height)
|
||||
mrect.height = 40;
|
||||
mrect.height = 20;
|
||||
|
||||
win = XCreateWindow(dpy, RootWindow(dpy, screen_num), mrect.x, mrect.y,
|
||||
mrect.width, mrect.height, 0, DefaultDepth(dpy,
|
||||
screen_num),
|
||||
mrect.width, mrect.height, 0, DefaultDepth(dpy, screen_num),
|
||||
CopyFromParent, DefaultVisual(dpy, screen_num),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask,
|
||||
&wa);
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
XDefineCursor(dpy, win, XCreateFontCursor(dpy, XC_xterm));
|
||||
XSync(dpy, False);
|
||||
|
||||
@ -664,13 +609,10 @@ static void run(char *size)
|
||||
gcv.graphics_exposures = False;
|
||||
|
||||
gc = XCreateGC(dpy, win, 0, 0);
|
||||
pmap =
|
||||
XCreatePixmap(dpy, win, mrect.width, mrect.height,
|
||||
DefaultDepth(dpy, screen_num));
|
||||
pmap = XCreatePixmap(dpy, win, mrect.width, mrect.height, DefaultDepth(dpy, screen_num));
|
||||
|
||||
/* main event loop */
|
||||
run_server_with_fd_support(ixps, ConnectionNumber(dpy),
|
||||
check_event, 0);
|
||||
run_server_with_fd_support(ixps, ConnectionNumber(dpy), check_event, 0);
|
||||
deinit_server(ixps);
|
||||
XFreePixmap(dpy, pmap);
|
||||
XFreeGC(dpy, gc);
|
||||
|
4
rc/kmode
4
rc/kmode
@ -1,10 +1,10 @@
|
||||
#!9PREFIX/bin/rc
|
||||
# activate shortcuts of the given mode
|
||||
|
||||
wmir write /keys/grab-keyb 0
|
||||
wmir write /keys/grabkeyb 0
|
||||
wmir write /keys/lookup /mode/$1
|
||||
|
||||
plab_cmd=`{wmir read /wm/event/page-update | sed -e 's/\\//'}
|
||||
plab_cmd=`{wmir read /wm/event/pageupdate | sed -e 's/\\//'}
|
||||
if (! ~ $#plab_cmd 0) eval $"plab_cmd
|
||||
|
||||
#wmir write /bar/$plab/data \
|
||||
|
163
rc/wmirc
163
rc/wmirc
@ -1,17 +1,16 @@
|
||||
#!9PREFIX/bin/rc
|
||||
# configure wmii
|
||||
|
||||
TAB_HEIGHT=16
|
||||
TAB=1
|
||||
BAR_HEIGHT=16
|
||||
BORDER_WIDTH=3
|
||||
|
||||
SELECTED_BG_COLOR='#307080'
|
||||
SELECTED_FG_COLOR='#fefefe'
|
||||
SELECTED_BORDER_COLOR='#5090a0'
|
||||
NORMAL_BG_COLOR='#004050'
|
||||
NORMAL_FG_COLOR='#cccccc'
|
||||
NORMAL_BORDER_COLOR='#206070'
|
||||
TEXT_FONT='fixed'
|
||||
SEL_BG_COLOR='#307080'
|
||||
SEL_FG_COLOR='#fefefe'
|
||||
SEL_BORDER_COLOR='#5090a0'
|
||||
NORM_BG_COLOR='#004050'
|
||||
NORM_FG_COLOR='#cccccc'
|
||||
NORM_BORDER_COLOR='#206070'
|
||||
FONT='fixed'
|
||||
|
||||
MODKEY=M
|
||||
NORTHKEY=k
|
||||
@ -27,17 +26,15 @@ fn kbind {
|
||||
}
|
||||
|
||||
fn selstyle {
|
||||
wmir write $1/text-font $TEXT_FONT
|
||||
wmir write $1/text-color $SELECTED_FG_COLOR
|
||||
wmir write $1/bg-color $SELECTED_BG_COLOR
|
||||
wmir write $1/border-color $SELECTED_BORDER_COLOR
|
||||
wmir write $1/fgcolor $SEL_FG_COLOR
|
||||
wmir write $1/bgcolor $SEL_BG_COLOR
|
||||
wmir write $1/bordercolor $SEL_BORDER_COLOR
|
||||
}
|
||||
|
||||
fn normstyle {
|
||||
wmir write $1/text-font $TEXT_FONT
|
||||
wmir write $1/text-color $NORMAL_FG_COLOR
|
||||
wmir write $1/bg-color $NORMAL_BG_COLOR
|
||||
wmir write $1/border-color $NORMAL_BORDER_COLOR
|
||||
wmir write $1/fgcolor $NORM_FG_COLOR
|
||||
wmir write $1/bgcolor $NORM_BG_COLOR
|
||||
wmir write $1/bordercolor $NORM_BORDER_COLOR
|
||||
}
|
||||
|
||||
fn items {
|
||||
@ -55,13 +52,12 @@ fn items {
|
||||
}
|
||||
|
||||
fn frameconf {
|
||||
wmir write $1/event/b3press 'wmir write /wm/page/sel/ctl toggle'
|
||||
wmir write $1/event/b2press 'wmir write /wm/ctl close'
|
||||
normstyle $1/norm-style
|
||||
selstyle $1/sel-style
|
||||
wmir write $1/tab-height $TAB_HEIGHT
|
||||
normstyle $1/nstyle
|
||||
selstyle $1/sstyle
|
||||
wmir write $1/tab $TAB
|
||||
if(~ $2 refresh)
|
||||
wmir write $1/size +0,+0,+0,+0 # causes refresh
|
||||
wmir write $1/geometry +0,+0,+0,+0 # causes refresh
|
||||
}
|
||||
|
||||
fn framesconf {
|
||||
@ -80,18 +76,18 @@ fn barsucks {
|
||||
}
|
||||
|
||||
wmir write /bar/ctl reset
|
||||
wmir write /bar/font $TEXT_FONT
|
||||
wmir write /bar/fgcolor $NORMAL_FG_COLOR
|
||||
wmir write /bar/bgcolor $NORMAL_BG_COLOR
|
||||
wmir write /bar/bordercolor $NORMAL_BORDER_COLOR
|
||||
wmir write /bar/font $FONT
|
||||
wmir write /bar/fgcolor $NORM_FG_COLOR
|
||||
wmir write /bar/bgcolor $NORM_BG_COLOR
|
||||
wmir write /bar/bordercolor $NORM_BORDER_COLOR
|
||||
|
||||
plab=`{wmir read /bar/new}
|
||||
wmir write /bar/$plab/b1press 'wmir write /wm/ctl pager'
|
||||
|
||||
clab=`{wmir read /bar/new}
|
||||
wmir write /bar/$clab/fgcolor $SELECTED_FG_COLOR
|
||||
wmir write /bar/$clab/bgcolor $SELECTED_BG_COLOR
|
||||
wmir write /bar/$clab/bordercolor $SELECTED_BG_COLOR
|
||||
wmir write /bar/$clab/fgcolor $SEL_FG_COLOR
|
||||
wmir write /bar/$clab/bgcolor $SEL_BG_COLOR
|
||||
wmir write /bar/$clab/bordercolor $SEL_BG_COLOR
|
||||
barsucks $clab
|
||||
|
||||
wmir write /bar/expandable 2
|
||||
@ -101,40 +97,26 @@ wmir write /bar/ctl 'display 1'
|
||||
|
||||
# WMIIWM CONFIGURATION
|
||||
|
||||
# default layout (tiled, max, grid or vsplit):
|
||||
wmir write /wm/default/page/layout tiled
|
||||
# default layout (column, float):
|
||||
wmir write /wm/default/layout column
|
||||
wmir write /wm/default/font $FONT
|
||||
wmir write /wm/default/transcolor $SEL_BG_COLOR
|
||||
wmir write /wm/default/handleinc 1
|
||||
|
||||
# width of the left frame in tiled layout in percent:
|
||||
wmir write /wm/default/page/tile-width 60
|
||||
|
||||
wmir write /wm/default/core/trans-color $SELECTED_BG_COLOR
|
||||
wmir write /wm/default/frame/handle-inc 1
|
||||
|
||||
# some broken WIMP apps:
|
||||
wmir create /wm/default/client/'xmms:*'/manage 0
|
||||
wmir create /wm/default/client/'Gimp:*'/manage 0
|
||||
|
||||
wmir write /wm/default/frame/border-width $BORDER_WIDTH
|
||||
wmir write /wm/default/page/size '0,0,east,south-'^$BAR_HEIGHT
|
||||
wmir write /wm/event/client-update \
|
||||
'text=`{wmir read /wm/page/sel/mode/sel/client/sel/name} \
|
||||
wmir write /wm/default/border 1
|
||||
wmir write /wm/default/pagegeometry '0,0,east,south-'^$BAR_HEIGHT
|
||||
wmir write /wm/event/clientupdate \
|
||||
'text=`{wmir read /wm/sel/a/sel/f/sel/c/sel/name} \
|
||||
wmir write /bar/'^$clab^'/data $"text'
|
||||
wmir write /wm/event/page-update \
|
||||
'text=`{wmir read /wm/page/sel/name} ^ \
|
||||
`{wmir read /wm/page/sel/mode/name|awk ''{print substr($0,0,1)}''} ^ \
|
||||
wmir write /wm/event/pageupdate \
|
||||
'text=`{wmir read /wm/sel/name} ^ \
|
||||
`{wmir read /wm/sel/a/sel/layout|awk ''{print substr($0,0,1)}''} ^ \
|
||||
`{wmir read /keys/lookup|awk ''{print substr($0,7,1)}''} \
|
||||
wmir write /bar/'^$plab^'/data $"text'
|
||||
|
||||
for(page in `{wmir read /wm/page | grep '^[0-9]'}) {
|
||||
framesconf /wm/page/$page/floating refresh
|
||||
framesconf /wm/page/$page/managed refresh
|
||||
}
|
||||
frameconf /wm/default/frame norefresh
|
||||
for(i in norm-style norm-style/client)
|
||||
normstyle /wm/default/core/pager/$i
|
||||
for(i in sel-style sel-style/client)
|
||||
selstyle /wm/default/core/pager/$i
|
||||
wmir write /wm/page/sel/managed/size 0,0,east,south-$BAR_HEIGHT >[2]/dev/null
|
||||
for(frame in `{wmir read /wm/sel/a/sel | grep '^[0-9]'})
|
||||
framesconf /wm/sel/a/sel/$frame refresh
|
||||
frameconf /wm/default norefresh
|
||||
|
||||
|
||||
# WMIKEYS CONFIGURATION
|
||||
@ -143,21 +125,21 @@ kbind bare $MODKEY-Escape 'kmode normal'
|
||||
|
||||
kbind move Escape 'kmode normal'
|
||||
kbind move $MODKEY-C-r 'kmode resize'
|
||||
kbind move $NORTHKEY 'wmir write /wm/page/sel/mode/sel/size -0,-30,-0,-0'
|
||||
kbind move $SOUTHKEY 'wmir write /wm/page/sel/mode/sel/size +0,+30,+0,+0'
|
||||
kbind move $WESTKEY 'wmir write /wm/page/sel/mode/sel/size -40,-0,-0,-0'
|
||||
kbind move $EASTKEY 'wmir write /wm/page/sel/mode/sel/size +40,+0,+0,+0'
|
||||
kbind move S-$NORTHKEY 'wmir write /wm/page/sel/mode/sel/size -0,north,-0,-0'
|
||||
kbind move S-$SOUTHKEY 'wmir write /wm/page/sel/mode/sel/size +0,south-'^$BAR_HEIGHT^',+0,+0'
|
||||
kbind move S-$WESTKEY 'wmir write /wm/page/sel/mode/sel/size west,-0,-0,-0'
|
||||
kbind move S-$EASTKEY 'wmir write /wm/page/sel/mode/sel/size east,+0,+0,+0'
|
||||
kbind move $NORTHKEY 'wmir write /wm/sel/a/sel/f/sel/geometry -0,-30,-0,-0'
|
||||
kbind move $SOUTHKEY 'wmir write /wm/sel/a/sel/f/sel/geometry +0,+30,+0,+0'
|
||||
kbind move $WESTKEY 'wmir write /wm/sel/a/sel/f/sel/geometry -40,-0,-0,-0'
|
||||
kbind move $EASTKEY 'wmir write /wm/sel/a/sel/f/sel/geometry +40,+0,+0,+0'
|
||||
kbind move S-$NORTHKEY 'wmir write /wm/sel/a/sel/f/sel/geometry -0,north,-0,-0'
|
||||
kbind move S-$SOUTHKEY 'wmir write /wm/sel/a/sel/f/sel/geometry +0,south-'^$BAR_HEIGHT^',+0,+0'
|
||||
kbind move S-$WESTKEY 'wmir write /wm/sel/a/sel/f/sel/geometry west,-0,-0,-0'
|
||||
kbind move S-$EASTKEY 'wmir write /wm/sel/a/sel/f/sel/geometry east,+0,+0,+0'
|
||||
|
||||
kbind resize Escape 'kmode normal'
|
||||
kbind resize $MODKEY-C-m 'kmode move'
|
||||
kbind resize $NORTHKEY 'wmir write /wm/page/sel/mode/sel/size +0,+0,+0,-30'
|
||||
kbind resize $SOUTHKEY 'wmir write /wm/page/sel/mode/sel/size +0,+0,+0,+30'
|
||||
kbind resize $WESTKEY 'wmir write /wm/page/sel/mode/sel/size +0,+0,-40,+0'
|
||||
kbind resize $EASTKEY 'wmir write /wm/page/sel/mode/sel/size +0,+0,+40,+0'
|
||||
kbind resize $NORTHKEY 'wmir write /wm/sel/a/sel/f/sel/geometry +0,+0,+0,-30'
|
||||
kbind resize $SOUTHKEY 'wmir write /wm/sel/a/sel/f/sel/geometry +0,+0,+0,+30'
|
||||
kbind resize $WESTKEY 'wmir write /wm/sel/a/sel/f/sel/geometry +0,+0,-40,+0'
|
||||
kbind resize $EASTKEY 'wmir write /wm/sel/a/sel/f/sel/geometry +0,+0,+40,+0'
|
||||
|
||||
kbind normal $MODKEY-C-b 'kmode bare'
|
||||
kbind normal $MODKEY-C-m 'kmode move'
|
||||
@ -171,47 +153,38 @@ kbind normal $MODKEY-t 'extern xterm ''+sb'' -bg ''#003040'' -fg ''#dddddd'' -cr
|
||||
kbind normal $MODKEY-d 'wmir write /wm/ctl detach'
|
||||
kbind normal $MODKEY-a 'wmir write /wm/ctl attach'
|
||||
kbind normal $MODKEY-S-a 'wmir write /wm/ctl icons'
|
||||
kbind normal $MODKEY-S-space 'wmir write /wm/page/sel/ctl toggle'
|
||||
kbind normal $MODKEY-Return 'wmir write /wm/page/sel/ctl ''select zoomed'''
|
||||
kbind normal $MODKEY-Return 'wmir write /wm/sel/ctl ''select zoomed'''
|
||||
kbind normal $MODKEY-C-y 'wmir write /wm/ctl new'
|
||||
kbind normal $MODKEY-u 'wmir write /wm/page/sel/mode/sel/locked 0'
|
||||
kbind normal $MODKEY-S-u 'wmir write /wm/page/sel/mode/sel/locked 1'
|
||||
kbind normal $MODKEY-m 'wmir write /wm/ctl togglemax'
|
||||
kbind normal $MODKEY-S-t 'wmir write /wm/page/sel/managed/name tiled'
|
||||
kbind normal $MODKEY-S-g 'wmir write /wm/page/sel/managed/name grid'
|
||||
kbind normal $MODKEY-S-v 'wmir write /wm/page/sel/managed/name vsplit'
|
||||
kbind normal $MODKEY-S-f 'wmir write /wm/page/sel/managed/name float'
|
||||
kbind normal $MODKEY-S-m 'wmir write /wm/page/sel/managed/name max'
|
||||
kbind normal $MODKEY-u 'wmir write /wm/sel/a/sel/f/sel/locked 0'
|
||||
kbind normal $MODKEY-S-u 'wmir write /wm/sel/a/sel/f/sel/locked 1'
|
||||
kbind normal $MODKEY-$WESTKEY 'wmir write /wm/ctl ''select prev'''
|
||||
kbind normal $MODKEY-$EASTKEY 'wmir write /wm/ctl ''select next'''
|
||||
kbind normal $MODKEY-Tab 'wmir write /wm/page/sel/ctl ''select next'''
|
||||
kbind normal $MODKEY-$SOUTHKEY 'wmir write /wm/page/sel/ctl ''select next'''
|
||||
kbind normal $MODKEY-$NORTHKEY 'wmir write /wm/page/sel/ctl ''select prev'''
|
||||
kbind normal $MODKEY-S-Tab 'wmir write /wm/page/sel/mode/sel/ctl ''select next'''
|
||||
kbind normal $MODKEY-S-$SOUTHKEY 'wmir write /wm/page/sel/mode/sel/ctl ''select next'''
|
||||
kbind normal $MODKEY-S-$NORTHKEY 'wmir write /wm/page/sel/mode/sel/ctl ''select prev'''
|
||||
kbind normal $MODKEY-space 'wmir write /wm/page/sel/ctl ''select toggled'''
|
||||
kbind normal $MODKEY-Tab 'wmir write /wm/sel/ctl ''select next'''
|
||||
kbind normal $MODKEY-$SOUTHKEY 'wmir write /wm/sel/ctl ''select next'''
|
||||
kbind normal $MODKEY-$NORTHKEY 'wmir write /wm/sel/ctl ''select prev'''
|
||||
kbind normal $MODKEY-S-Tab 'wmir write /wm/sel/a/sel/f/sel/ctl ''select next'''
|
||||
kbind normal $MODKEY-S-$SOUTHKEY 'wmir write /wm/sel/a/sel/f/sel/ctl ''select next'''
|
||||
kbind normal $MODKEY-S-$NORTHKEY 'wmir write /wm/sel/a/sel/f/sel/ctl ''select prev'''
|
||||
kbind normal $MODKEY-space 'wmir write /wm/sel/ctl ''select toggled'''
|
||||
kbind normal $MODKEY-S-p 'wmir write /wm/ctl pager'
|
||||
kbind normal $MODKEY-S-0 'wmir write /wm/ctl ''select 10'''
|
||||
for(i in 1 2 3 4 5 6 7 8 9) {
|
||||
kbind normal $MODKEY-S-$i 'wmir write /wm/ctl ''select '^$i^''''
|
||||
}
|
||||
|
||||
wmir write /keys/size center,center,100,$BAR_HEIGHT
|
||||
wmir write /keys/geometry center,center,100,$BAR_HEIGHT
|
||||
wmir write /keys/font $FONT
|
||||
selstyle /keys/box/style
|
||||
kmode normal
|
||||
|
||||
|
||||
# WMIMENU CONFIGURATION
|
||||
|
||||
items actions $WMII_CONFDIR:$HOME/.wmii-3
|
||||
wmir create /menu/items/actions/rmpage 'wmir write /wm/ctl destroy'
|
||||
items programs $OLD_PATH
|
||||
wmir write /menu/size 0,south,east,$BAR_HEIGHT
|
||||
normstyle /menu/style >[2]/dev/null
|
||||
normstyle /menu/norm-style >[2]/dev/null
|
||||
selstyle /menu/sel-style >[2]/dev/null
|
||||
|
||||
wmir write /menu/geometry 0,south,east,$BAR_HEIGHT
|
||||
wmir write /menu/font $FONT
|
||||
normstyle /menu/nstyle >[2]/dev/null
|
||||
selstyle /menu/sstyle >[2]/dev/null
|
||||
|
||||
# MISC
|
||||
xsetroot -mod 2 2 -fg '#003040' -bg '#004050'
|
||||
|
Loading…
Reference in New Issue
Block a user