several changes to sanitize /wm fs

This commit is contained in:
garbeam 2005-12-05 03:50:02 +02:00
parent fb790fbac5
commit 98fd32f255
10 changed files with 322 additions and 364 deletions

View File

@ -21,19 +21,19 @@ Area *alloc_area(Page *p, XRectangle * r)
*a = zero_area;
a->rect = *r;
a->page = p;
snprintf(buf, MAX_BUF, "/%s/area/%d", p->files[P_PREFIX]->name, count_items((void **) p->areas));
snprintf(buf, MAX_BUF, "/%s/area/%d", p->files[P_PREFIX]->name, count_items((void **) p->area));
a->files[A_PREFIX] = ixp_create(ixps, buf);
snprintf(buf, MAX_BUF, "/%s/area/%d/frame/sel", p->files[P_PREFIX]->name, count_items((void **) p->areas));
snprintf(buf, MAX_BUF, "/%s/area/%d/frame/sel", p->files[P_PREFIX]->name, count_items((void **) p->area));
a->files[A_SEL_FRAME] = ixp_create(ixps, buf);
snprintf(buf, MAX_BUF, "/%s/area/%d/ctl", p->files[P_PREFIX]->name, count_items((void **) p->areas));
snprintf(buf, MAX_BUF, "/%s/area/%d/ctl", p->files[P_PREFIX]->name, count_items((void **) p->area));
a->files[A_CTL] = ixp_create(ixps, buf);
snprintf(buf, MAX_BUF, "/%s/area/%d/geometry", p->files[P_PREFIX]->name, count_items((void **) p->areas));
snprintf(buf, MAX_BUF, "/%s/area/%d/geometry", p->files[P_PREFIX]->name, count_items((void **) p->area));
a->files[A_GEOMETRY] = ixp_create(ixps, buf);
snprintf(buf, MAX_BUF, "/%s/area/%d/layout", p->files[P_PREFIX]->name, count_items((void **) p->areas));
snprintf(buf, MAX_BUF, "/%s/area/%d/layout", p->files[P_PREFIX]->name, count_items((void **) p->area));
a->files[A_LAYOUT] = ixp_create(ixps, buf);
p->areas =
(Area **) attach_item_end((void **) p->areas, a, sizeof(Area *));
p->sel = index_item((void **) p->areas, a);
p->area =
(Area **) attach_item_end((void **) p->area, a, sizeof(Area *));
p->sel = index_item((void **) p->area, a);
return a;
}
@ -47,9 +47,9 @@ void destroy_area(Area * a)
{
unsigned int i;
a->layout->deinit(a);
for (i = 0; a->frames && a->frames[i]; i++);
destroy_frame(a->frames[i]);
free(a->frames);
for (i = 0; a->frame && a->frame[i]; i++);
destroy_frame(a->frame[i]);
free(a->frame);
free_area(a);
}
@ -59,9 +59,9 @@ void focus_area(Area * a, int raise, int up, int down)
if (!p)
return;
if (down && a->frames)
focus_frame(a->frames[a->sel], raise, 0, down);
p->sel = index_item((void **) p->areas, a);
if (down && a->frame)
focus_frame(a->frame[a->sel], raise, 0, down);
p->sel = index_item((void **) p->area, a);
p->files[P_SEL_AREA]->content = a->files[A_PREFIX]->content;
if (up)
focus_page(p, raise, 0);

View File

@ -41,8 +41,8 @@ Client *alloc_client(Window w)
c->files[C_INSTANCE] = ixp_create(ixps, buf);
}
id++;
clients =
(Client **) attach_item_end((void **) clients, c,
client =
(Client **) attach_item_end((void **) client, c,
sizeof(Client *));
XSelectInput(dpy, c->win, CLIENT_MASK);
return c;
@ -54,14 +54,14 @@ void focus_client(Client * c, int raise, int up)
/* focus client */
if (c) {
f = c->frame;
for (f->sel = 0; f->clients && f->clients[f->sel] != c; f->sel++);
for (f->sel = 0; f->client && f->client[f->sel] != c; f->sel++);
f->files[F_SEL_CLIENT]->content = c->files[C_PREFIX]->content;
if (raise)
XRaiseWindow(dpy, c->win);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
} else
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
invoke_wm_event(defaults[WM_EVENT_CLIENT_UPDATE]);
invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]);
if (up && f)
focus_frame(f, raise, up, 0);
}
@ -207,7 +207,7 @@ void handle_client_property(Client * c, XPropertyEvent * e)
}
if (c->frame)
draw_client(c);
invoke_wm_event(defaults[WM_EVENT_CLIENT_UPDATE]);
invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]);
break;
case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(dpy, c->win, &c->trans);
@ -223,8 +223,8 @@ void handle_client_property(Client * c, XPropertyEvent * e)
void free_client(Client * c)
{
clients =
(Client **) detach_item((void **) clients, c, sizeof(Client *));
client =
(Client **) detach_item((void **) client, c, sizeof(Client *));
ixp_remove_file(ixps, c->files[C_PREFIX]);
if (ixps->errstr)
fprintf(stderr, "wmiiwm: free_client(): %s\n", ixps->errstr);
@ -241,42 +241,42 @@ void draw_client(Client * c)
if (!tabh)
return;
size = count_items((void **) f->clients);
size = count_items((void **) f->client);
tw = f->rect.width;
if (size)
tw /= size;
for (i = 0; f->clients[i] && f->clients[i] != c; i++);
for (i = 0; f->client[i] && f->client[i] != c; i++);
if (!f->clients[i + 1])
if (!f->client[i + 1])
draw_tab(f, c->files[C_NAME]->content, i * tw, 0,
f->rect.width - (i * tw), tabh, ISSELFRAME(f)
&& f->clients[f->sel] == c);
&& f->client[f->sel] == c);
else
draw_tab(f, c->files[C_NAME]->content, i * tw, 0, tw, tabh,
ISSELFRAME(f) && f->clients[f->sel] == c);
ISSELFRAME(f) && f->client[f->sel] == c);
}
void draw_clients(Frame * f)
{
unsigned int tabh = tab_height(f);
int i, size = count_items((void **) f->clients);
int i, size = count_items((void **) f->client);
int tw = f->rect.width;
if (!tabh || !size)
return;
if (size)
tw /= size;
for (i = 0; f->clients[i]; i++) {
if (!f->clients[i + 1]) {
for (i = 0; f->client[i]; i++) {
if (!f->client[i + 1]) {
int xoff = i * tw;
draw_tab(f, f->clients[i]->files[C_NAME]->content,
draw_tab(f, f->client[i]->files[C_NAME]->content,
xoff, 0, f->rect.width - xoff, tabh, ISSELFRAME(f)
&& f->clients[f->sel] == f->clients[i]);
&& f->client[f->sel] == f->client[i]);
break;
} else
draw_tab(f, f->clients[i]->files[C_NAME]->content,
draw_tab(f, f->client[i]->files[C_NAME]->content,
i * tw, 0, tw, tabh, ISSELFRAME(f)
&& f->clients[f->sel] == f->clients[i]);
&& f->client[f->sel] == f->client[i]);
}
XSync(dpy, False);
}

View File

@ -215,7 +215,7 @@ static void handle_maprequest(XEvent * e)
return;
if (wa.override_redirect)
return;
/* there're clients which send map requests twice */
/* there're client which send map requests twice */
c = win_to_client(ev->window);
if (!c)
c = alloc_client(ev->window);
@ -230,14 +230,14 @@ static void handle_motionnotify(XEvent * e)
Frame *f = win_to_frame(e->xmotion.window);
Cursor cursor;
if (f) {
Frame *old = SELFRAME(pages[sel]);
Frame *old = SELFRAME(page[sel]);
if (old != f) {
focus_frame(f, 0, 0, 1);
draw_frame(old);
draw_frame(f);
} else if (f->clients) {
} else if (f->client) {
/* multihead assumption */
XSetInputFocus(dpy, f->clients[f->sel]->win,
XSetInputFocus(dpy, f->client[f->sel]->win,
RevertToPointerRoot, CurrentTime);
XSync(dpy, False);
}
@ -271,8 +271,8 @@ static void handle_unmapnotify(XEvent * e)
if ((c = win_to_client(ev->window))) {
if (c->frame) {
detach_client_from_frame(c, 1, 0);
if (pages)
draw_page(pages[sel]);
if (page)
draw_page(page[sel]);
free_client(c);
} else if (detached) {
if (index_item((void **) detached, c) == -1)
@ -295,7 +295,7 @@ static void handle_enternotify(XEvent * e)
c = win_to_client(ev->window);
if (c && c->frame && (ev->serial != ignore_enternotify_hack)) {
Frame *old = SELFRAME(pages[sel]);
Frame *old = SELFRAME(page[sel]);
XUndefineCursor(dpy, c->frame->win);
if (old != c->frame) {
focus_frame(c->frame, 0, 0, 1);

View File

@ -51,58 +51,36 @@ Frame *alloc_frame(XRectangle * r, int add_frame_border, int floating)
f->files[F_SIZE]->before_read = handle_before_read_frame;
f->files[F_SIZE]->after_write = handle_after_write_frame;
snprintf(buf, MAX_BUF, "/detached/frame/%d/border", id);
f->files[F_BORDER] =
wmii_create_ixpfile(ixps, buf, defaults[WM_BORDER]->content);
f->files[F_BORDER] = wmii_create_ixpfile(ixps, buf, def[WM_BORDER]->content);
f->files[F_BORDER]->after_write = handle_after_write_frame;
snprintf(buf, MAX_BUF, "/detached/frame/%d/tab", id);
f->files[F_TAB] =
wmii_create_ixpfile(ixps, buf, defaults[WM_TAB]->content);
f->files[F_TAB] = wmii_create_ixpfile(ixps, buf, def[WM_TAB]->content);
f->files[F_TAB]->after_write = handle_after_write_frame;
snprintf(buf, MAX_BUF, "/detached/frame/%d/handleinc", id);
f->files[F_HANDLE_INC] =
wmii_create_ixpfile(ixps, buf, defaults[WM_HANDLE_INC]->content);
f->files[F_HANDLE_INC] = wmii_create_ixpfile(ixps, buf, def[WM_HANDLE_INC]->content);
f->files[F_HANDLE_INC]->after_write = handle_after_write_frame;
snprintf(buf, MAX_BUF, "/detached/frame/%d/locked", id);
f->files[F_LOCKED] =
wmii_create_ixpfile(ixps, buf, defaults[WM_LOCKED]->content);
f->files[F_LOCKED] = wmii_create_ixpfile(ixps, buf, def[WM_LOCKED]->content);
snprintf(buf, MAX_BUF, "/detached/frame/%d/selstyle/bgcolor", id);
f->files[F_SEL_BG_COLOR] =
wmii_create_ixpfile(ixps, buf, defaults[WM_SEL_BG_COLOR]->content);
f->files[F_SEL_BG_COLOR] = wmii_create_ixpfile(ixps, buf, def[WM_SEL_BG_COLOR]->content);
snprintf(buf, MAX_BUF, "/detached/frame/%d/selstyle/fgcolor", id);
f->files[F_SEL_FG_COLOR] =
wmii_create_ixpfile(ixps, buf, defaults[WM_SEL_FG_COLOR]->content);
f->files[F_SEL_FG_COLOR] = wmii_create_ixpfile(ixps, buf, def[WM_SEL_FG_COLOR]->content);
snprintf(buf, MAX_BUF, "/detached/frame/%d/selstyle/bordercolor", id);
f->files[F_SEL_BORDER_COLOR] =
wmii_create_ixpfile(ixps, buf,
defaults[WM_SEL_BORDER_COLOR]->content);
f->files[F_SEL_BORDER_COLOR] = wmii_create_ixpfile(ixps, buf, def[WM_SEL_BORDER_COLOR]->content);
snprintf(buf, MAX_BUF, "/detached/frame/%d/normstyle/bgcolor", id);
f->files[F_NORM_BG_COLOR] =
wmii_create_ixpfile(ixps, buf,
defaults[WM_NORM_BG_COLOR]->content);
f->files[F_NORM_BG_COLOR] = wmii_create_ixpfile(ixps, buf, def[WM_NORM_BG_COLOR]->content);
snprintf(buf, MAX_BUF, "/detached/frame/%d/normstyle/fgcolor", id);
f->files[F_NORM_FG_COLOR] =
wmii_create_ixpfile(ixps, buf,
defaults[WM_NORM_FG_COLOR]->content);
f->files[F_NORM_FG_COLOR] = wmii_create_ixpfile(ixps, buf, def[WM_NORM_FG_COLOR]->content);
snprintf(buf, MAX_BUF, "/detached/frame/%d/normstyle/bordercolor", id);
f->files[F_NORM_BORDER_COLOR] =
wmii_create_ixpfile(ixps, buf,
defaults[WM_NORM_BORDER_COLOR]->content);
f->files[F_NORM_BORDER_COLOR] = wmii_create_ixpfile(ixps, buf, def[WM_NORM_BORDER_COLOR]->content);
snprintf(buf, MAX_BUF, "/detached/frame/%d/event/b2press", id);
f->files[F_EVENT_B2PRESS] =
wmii_create_ixpfile(ixps, buf,
defaults[WM_EVENT_B2PRESS]->content);
f->files[F_EVENT_B2PRESS] = wmii_create_ixpfile(ixps, buf, def[WM_EVENT_B2PRESS]->content);
snprintf(buf, MAX_BUF, "/detached/frame/%d/event/b3press", id);
f->files[F_EVENT_B3PRESS] =
wmii_create_ixpfile(ixps, buf,
defaults[WM_EVENT_B3PRESS]->content);
f->files[F_EVENT_B3PRESS] = wmii_create_ixpfile(ixps, buf, def[WM_EVENT_B3PRESS]->content);
snprintf(buf, MAX_BUF, "/detached/frame/%d/event/b4press", id);
f->files[F_EVENT_B4PRESS] =
wmii_create_ixpfile(ixps, buf,
defaults[WM_EVENT_B4PRESS]->content);
f->files[F_EVENT_B4PRESS] = wmii_create_ixpfile(ixps, buf, def[WM_EVENT_B4PRESS]->content);
snprintf(buf, MAX_BUF, "/detached/frame/%d/event/b5press", id);
f->files[F_EVENT_B5PRESS] =
wmii_create_ixpfile(ixps, buf,
defaults[WM_EVENT_B5PRESS]->content);
f->files[F_EVENT_B5PRESS] = wmii_create_ixpfile(ixps, buf, def[WM_EVENT_B5PRESS]->content);
id++;
wa.override_redirect = 1;
@ -127,17 +105,17 @@ Frame *alloc_frame(XRectangle * r, int add_frame_border, int floating)
XDefineCursor(dpy, f->win, f->cursor);
f->gc = XCreateGC(dpy, f->win, 0, 0);
XSync(dpy, False);
frames =
(Frame **) attach_item_end((void **) frames, f, sizeof(Frame *));
frame =
(Frame **) attach_item_end((void **) frame, f, sizeof(Frame *));
return f;
}
void focus_frame(Frame * f, int raise, int up, int down)
{
Area *a = f->area;
if (down && f->clients)
focus_client(f->clients[f->sel], raise, 0);
a->sel = index_item((void **) a->frames, f);
if (down && f->client)
focus_client(f->client[f->sel], raise, 0);
a->sel = index_item((void **) a->frame, f);
a->files[A_SEL_FRAME]->content = f->files[F_PREFIX]->content;
if (raise && a->page->sel == 0) /* only floating windows are raised */
XRaiseWindow(dpy, f->win);
@ -149,15 +127,15 @@ Frame *win_to_frame(Window w)
{
int i;
for (i = 0; frames && frames[i]; i++)
if (frames[i]->win == w)
return frames[i];
for (i = 0; frame && frame[i]; i++)
if (frame[i]->win == w)
return frame[i];
return 0;
}
void destroy_frame(Frame * f)
{
frames = (Frame **) detach_item((void **) frames, f, sizeof(Frame *));
frame = (Frame **) detach_item((void **) frame, f, sizeof(Frame *));
XFreeGC(dpy, f->gc);
XDestroyWindow(dpy, f->win);
ixp_remove_file(ixps, f->files[F_PREFIX]);
@ -180,11 +158,11 @@ unsigned int border_width(Frame * f)
return 0;
}
static void resize_clients(Frame * f, int tabh, int bw)
static void resize_client(Frame * f, int tabh, int bw)
{
int i;
for (i = 0; f->clients && f->clients[i]; i++) {
Client *c = f->clients[i];
for (i = 0; f->client && f->client[i]; i++) {
Client *c = f->client[i];
c->rect.x = bw;
c->rect.y = tabh ? tabh : bw;
c->rect.width = f->rect.width - 2 * bw;
@ -197,7 +175,7 @@ static void resize_clients(Frame * f, int tabh, int bw)
static void check_dimensions(Frame * f, unsigned int tabh, unsigned int bw)
{
Client *c = f->clients ? f->clients[f->sel] : 0;
Client *c = f->client ? f->client[f->sel] : 0;
if (!c)
return;
@ -222,7 +200,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)
{
Client *c = f->clients ? f->clients[f->sel] : 0;
Client *c = f->client ? f->client[f->sel] : 0;
if (!c)
return;
/* increment stuff, see chapter 4.1.2.3 of the ICCCM Manual */
@ -233,7 +211,7 @@ resize_incremental(Frame * f, unsigned int tabh, unsigned int bw)
base_width = c->size.base_width;
base_height = c->size.base_height;
} else if (c->size.flags & PMinSize) {
/* base_{width,height} defaults to min_{width,height} */
/* base_{width,height} default to min_{width,height} */
base_width = c->size.min_width;
base_height = c->size.min_height;
}
@ -270,7 +248,7 @@ resize_frame(Frame * f, XRectangle * r, XPoint * pt, int ignore_layout)
XMoveResizeWindow(dpy, f->win, f->rect.x, f->rect.y, f->rect.width,
f->rect.height);
resize_clients(f, (tabh ? tabh : bw), bw);
resize_client(f, (tabh ? tabh : bw), bw);
}
@ -342,25 +320,13 @@ void draw_frame(Frame * f)
/* define ground plate (i = 0) */
if (ISSELFRAME(f)) {
d.bg =
blitz_loadcolor(dpy, screen_num,
f->files[F_SEL_BG_COLOR]->content);
d.fg =
blitz_loadcolor(dpy, screen_num,
f->files[F_SEL_FG_COLOR]->content);
d.border =
blitz_loadcolor(dpy, screen_num,
f->files[F_SEL_BORDER_COLOR]->content);
d.bg = blitz_loadcolor(dpy, screen_num, f->files[F_SEL_BG_COLOR]->content);
d.fg = blitz_loadcolor(dpy, screen_num, f->files[F_SEL_FG_COLOR]->content);
d.border = blitz_loadcolor(dpy, screen_num, f->files[F_SEL_BORDER_COLOR]->content);
} else {
d.bg =
blitz_loadcolor(dpy, screen_num,
f->files[F_NORM_BG_COLOR]->content);
d.fg =
blitz_loadcolor(dpy, screen_num,
f->files[F_NORM_FG_COLOR]->content);
d.border =
blitz_loadcolor(dpy, screen_num,
f->files[F_NORM_BORDER_COLOR]->content);
d.bg = blitz_loadcolor(dpy, screen_num, f->files[F_NORM_BG_COLOR]->content);
d.fg = blitz_loadcolor(dpy, screen_num, f->files[F_NORM_FG_COLOR]->content);
d.border = blitz_loadcolor(dpy, screen_num, f->files[F_NORM_BORDER_COLOR]->content);
}
d.rect = f->rect;
d.rect.x = d.rect.y = 0;
@ -375,12 +341,12 @@ void draw_frame(Frame * f)
void handle_frame_buttonpress(XButtonEvent * e, Frame * f)
{
int bindex;
int size = count_items((void **) f->clients);
int size = count_items((void **) f->client);
int cindex = e->x / f->rect.width / size;
if (!f->area->page->sel)
XRaiseWindow(dpy, f->win);
if (cindex != f->sel) {
focus_client(f->clients[cindex], 1, 0);
focus_client(f->client[cindex], 1, 0);
draw_frame(f);
return;
}
@ -397,11 +363,11 @@ void handle_frame_buttonpress(XButtonEvent * e, Frame * f)
void attach_client_to_frame(Frame * f, Client * c)
{
int size = count_items((void **) f->clients);
int size = count_items((void **) f->client);
wmii_move_ixpfile(c->files[C_PREFIX], f->files[F_CLIENT_PREFIX]);
f->files[F_SEL_CLIENT]->content = c->files[C_PREFIX]->content;
f->clients =
(Client **) attach_item_end((void **) f->clients, c,
f->client =
(Client **) attach_item_end((void **) f->client, c,
sizeof(Client *));
f->sel = size;
c->frame = f;
@ -415,7 +381,7 @@ void attach_client(Client * c)
{
Page *p = 0;
Frame *f = 0;
if (!pages)
if (!page)
alloc_page("0");
/* transient stuff */
if (c && c->trans && !f) {
@ -425,7 +391,7 @@ void attach_client(Client * c)
f = alloc_frame(&c->rect, 1, 1);
}
}
p = pages[sel];
p = page[sel];
if (!f) {
/* check if we shall manage it */
@ -442,19 +408,19 @@ void attach_client(Client * c)
f = alloc_frame(&c->rect, 1, 0);
if (!f->area)
attach_frame_to_area(p->areas[p->sel], f);
attach_frame_to_area(p->area[p->sel], f);
attach_client_to_frame(f, c);
draw_frame(f);
invoke_wm_event(defaults[WM_EVENT_PAGE_UPDATE]);
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
}
void detach_client_from_frame(Client * c, int unmapped, int destroyed)
{
Frame *f = c->frame;
wmii_move_ixpfile(c->files[C_PREFIX], defaults[WM_DETACHED_CLIENT]);
wmii_move_ixpfile(c->files[C_PREFIX], def[WM_DETACHED_CLIENT]);
c->frame = 0;
f->clients =
(Client **) detach_item((void **) f->clients, c, sizeof(Client *));
f->client =
(Client **) detach_item((void **) f->client, c, sizeof(Client *));
if (f->sel)
f->sel--;
else
@ -468,16 +434,16 @@ void detach_client_from_frame(Client * c, int unmapped, int destroyed)
}
reparent_client(c, root, border_width(f), tab_height(f));
}
if (f->clients) {
focus_client(f->clients[f->sel], 1, 1);
if (f->client) {
focus_client(f->client[f->sel], 1, 1);
draw_frame(f);
} else {
detach_frame_from_area(f, 0);
destroy_frame(f);
if (pages)
focus_page(pages[sel], 0, 1);
if (page)
focus_page(page[sel], 0, 1);
}
invoke_wm_event(defaults[WM_EVENT_PAGE_UPDATE]);
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
}
static void mouse()
@ -485,9 +451,9 @@ static void mouse()
Frame *f;
Align align;
if (!pages)
if (!page)
return;
if (!(f = SELFRAME(pages[sel])))
if (!(f = SELFRAME(page[sel])))
return;
align = cursor_to_align(f->cursor);
if (align == CENTER)
@ -499,7 +465,7 @@ static void mouse()
static void select_client(void *obj, char *cmd)
{
Frame *f = obj;
int size = count_items((void **) f->clients);
int size = count_items((void **) f->client);
if (!f || !cmd || size == 1)
return;
if (!strncmp(cmd, "prev", 5)) {
@ -513,7 +479,7 @@ static void select_client(void *obj, char *cmd)
else
f->sel++;
}
focus_client(f->clients[f->sel], 1, 0);
focus_client(f->client[f->sel], 1, 0);
draw_frame(f);
}
@ -521,12 +487,12 @@ static void handle_before_read_frame(IXPServer * s, File * f)
{
int i = 0;
for (i = 0; frames && frames[i]; i++) {
if (f == frames[i]->files[F_SIZE]) {
for (i = 0; frame && frame[i]; i++) {
if (f == frame[i]->files[F_SIZE]) {
char buf[64];
snprintf(buf, 64, "%d,%d,%d,%d", frames[i]->rect.x,
frames[i]->rect.y, frames[i]->rect.width,
frames[i]->rect.height);
snprintf(buf, 64, "%d,%d,%d,%d", frame[i]->rect.x,
frame[i]->rect.y, frame[i]->rect.width,
frame[i]->rect.height);
if (f->content)
free(f->content);
f->content = estrdup(buf);
@ -540,26 +506,26 @@ static void handle_after_write_frame(IXPServer * s, File * f)
{
int i;
for (i = 0; frames && frames[i]; i++) {
if (f == frames[i]->files[F_CTL]) {
run_action(f, frames[i], frame_acttbl);
for (i = 0; frame && frame[i]; i++) {
if (f == frame[i]->files[F_CTL]) {
run_action(f, frame[i], frame_acttbl);
return;
}
if (f == frames[i]->files[F_TAB]
|| f == frames[i]->files[F_BORDER]
|| f == frames[i]->files[F_HANDLE_INC]) {
if (frames[i]->area) {
frames[i]->area->layout->arrange(frames[i]->area);
draw_page(frames[i]->area->page);
if (f == frame[i]->files[F_TAB]
|| f == frame[i]->files[F_BORDER]
|| f == frame[i]->files[F_HANDLE_INC]) {
if (frame[i]->area) {
frame[i]->area->layout->arrange(frame[i]->area);
draw_page(frame[i]->area->page);
}
return;
} else if (f == frames[i]->files[F_SIZE]) {
char *size = frames[i]->files[F_SIZE]->content;
} else if (f == frame[i]->files[F_SIZE]) {
char *size = frame[i]->files[F_SIZE]->content;
if (size && strrchr(size, ',')) {
XRectangle frect;
blitz_strtorect(&rect, &frect, size);
resize_frame(frames[i], &frect, 0, 0);
draw_page(frames[i]->area->page);
resize_frame(frame[i], &frect, 0, 0);
draw_page(frame[i]->area->page);
}
return;
}

View File

@ -23,7 +23,7 @@ struct Acme {
struct Column {
int sel;
int refresh;
Frame **frames;
Frame **frame;
XRectangle rect;
};
@ -48,15 +48,15 @@ void init_layout_column()
static void arrange_column(Area * a, Column * col)
{
int i;
int n = count_items((void **) col->frames);
int n = count_items((void **) col->frame);
unsigned int height = a->rect.height / n;
for (i = 0; col->frames && col->frames[i]; i++) {
for (i = 0; col->frame && col->frame[i]; i++) {
if (col->refresh) {
col->frames[i]->rect = col->rect;
col->frames[i]->rect.height = height;
col->frames[i]->rect.y = i * height;
col->frame[i]->rect = col->rect;
col->frame[i]->rect.height = height;
col->frame[i]->rect.y = i * height;
}
resize_frame(col->frames[i], &col->frames[i]->rect, 0, 1);
resize_frame(col->frame[i], &col->frame[i]->rect, 0, 1);
}
}
@ -109,50 +109,50 @@ static void init_col(Area * a)
acme->column[cols] = 0; /* null termination of array */
/*
* Frame attaching strategy works as follows: 1. If more clients than
* Frame attaching strategy works as follows: 1. If more client than
* column exist, then each column gets one client, except eastmost
* column, which gets all remaining clients. 2. If lesser clients
* column, which gets all remaining client. 2. If lesser client
* than column exist, than filling begins from eastmost to westmost
* column until no more clients exist.
* column until no more client exist.
*/
n = count_items((void **) clients);
n = count_items((void **) client);
if (n > cols) {
/* 1st. case */
j = 0;
for (i = 0; i < (cols - 1); i++) {
col = acme->column[i];
col->frames =
(Frame **) attach_item_end((void **) col->frames,
alloc_frame(&clients[i]->rect,
col->frame =
(Frame **) attach_item_end((void **) col->frame,
alloc_frame(&client[i]->rect,
1, 1),
sizeof(Frame *));
col->frames[0]->aux = col;
attach_frame_to_area(a, col->frames[0]);
attach_client_to_frame(col->frames[0], clients[j]);
col->frame[0]->aux = col;
attach_frame_to_area(a, col->frame[0]);
attach_client_to_frame(col->frame[0], client[j]);
j++;
}
col = acme->column[cols - 1];
col->frames = emalloc((n - j + 1) * sizeof(Frame *));
col->frame = emalloc((n - j + 1) * sizeof(Frame *));
for (i = 0; i + j < n; i++) {
col->frames[i] = alloc_frame(&clients[j + i]->rect, 1, 1);
col->frames[i]->aux = col;
attach_frame_to_area(a, col->frames[i]);
attach_client_to_frame(col->frames[i], clients[j + i]);
col->frame[i] = alloc_frame(&client[j + i]->rect, 1, 1);
col->frame[i]->aux = col;
attach_frame_to_area(a, col->frame[i]);
attach_client_to_frame(col->frame[i], client[j + i]);
}
col->frames[i] = 0;
col->frame[i] = 0;
} else {
/* 2nd case */
j = 0;
for (i = cols - 1; j < n; i--) {
col = acme->column[i];
col->frames =
(Frame **) attach_item_end((void **) col->frames,
alloc_frame(&clients[i]->rect,
col->frame =
(Frame **) attach_item_end((void **) col->frame,
alloc_frame(&client[i]->rect,
1, 1),
sizeof(Frame *));
col->frames[0]->aux = col;
attach_frame_to_area(a, col->frames[0]);
attach_client_to_frame(col->frames[0], clients[j]);
col->frame[0]->aux = col;
attach_frame_to_area(a, col->frame[0]);
attach_client_to_frame(col->frame[0], client[j]);
j++;
}
}
@ -167,14 +167,14 @@ static void deinit_col(Area * a)
for (i = 0; acme->column && acme->column[i]; i++) {
Column *col = acme->column[i];
int j;
for (j = 0; col->frames && col->frames[j]; j++) {
Frame *f = col->frames[j];
while (f->clients && f->clients[0])
detach_client_from_frame(f->clients[0], 0, 0);
for (j = 0; col->frame && col->frame[j]; j++) {
Frame *f = col->frame[j];
while (f->client && f->client[0])
detach_client_from_frame(f->client[0], 0, 0);
detach_frame_from_area(f, 1);
destroy_frame(f);
}
free(col->frames);
free(col->frame);
}
free(acme->column);
free(acme);
@ -189,7 +189,7 @@ static void attach_col(Area * a, Client * c)
col = acme->column[acme->sel];
f = alloc_frame(&c->rect, 1, 1);
col->frames = (Frame **) attach_item_end((void **) col->frames, f,
col->frame = (Frame **) attach_item_end((void **) col->frame, f,
sizeof(Frame *));
f->aux = col;
col->refresh = 1;
@ -207,7 +207,7 @@ static void detach_col(Area * a, Client * c, int unmapped, int destroyed)
if (!col)
return; /* client was not attached, maybe exit(1) in
* such case */
col->frames = (Frame **) detach_item((void **) col->frames, c->frame,
col->frame = (Frame **) detach_item((void **) col->frame, c->frame,
sizeof(Frame *));
col->refresh = 1;
detach_client_from_frame(c, unmapped, destroyed);
@ -242,14 +242,14 @@ static void drop_resize(Frame * f, XRectangle * new)
col->rect.width += f->rect.x - new->x;
col->rect.x = new->x;
for (i = 0; west->frames && west->frames[i]; i++) {
Frame *f = west->frames[i];
for (i = 0; west->frame && west->frame[i]; i++) {
Frame *f = west->frame[i];
f->rect.x = west->rect.x;
f->rect.width = west->rect.width;
resize_frame(f, &f->rect, 0, 1);
}
for (i = 0; col->frames && col->frames[i]; i++) {
Frame *f = col->frames[i];
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);
@ -266,14 +266,14 @@ static void drop_resize(Frame * f, XRectangle * new)
col->rect.x = new->x;
col->rect.width = new->width;
for (i = 0; col->frames && col->frames[i]; i++) {
Frame *f = col->frames[i];
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);
}
for (i = 0; east->frames && east->frames[i]; i++) {
Frame *f = east->frames[i];
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);
@ -282,15 +282,15 @@ static void drop_resize(Frame * f, XRectangle * new)
}
/* vertical stuff */
n = 0;
for (i = 0; col->frames && col->frames[i]; i++) {
if (col->frames[i] == f)
for (i = 0; col->frame && col->frame[i]; i++) {
if (col->frame[i] == f)
idx = i;
n++;
}
if (new->y < f->rect.y) {
if (idx && new->y > col->frames[idx - 1]->rect.y) {
Frame *north = col->frames[idx - 1];
if (idx && new->y > col->frame[idx - 1]->rect.y) {
Frame *north = col->frame[idx - 1];
north->rect.height = new->y - north->rect.y;
f->rect.width += new->y - north->rect.y;
f->rect.y = new->y;
@ -300,9 +300,9 @@ static void drop_resize(Frame * f, XRectangle * new)
}
if (new->y + new->height > f->rect.y + f->rect.height) {
if ((idx + 1 < n) &&
(new->y + new->height < col->frames[idx + 1]->rect.y
+ col->frames[idx + 1]->rect.height)) {
Frame *south = col->frames[idx + 1];
(new->y + new->height < col->frame[idx + 1]->rect.y
+ col->frame[idx + 1]->rect.height)) {
Frame *south = col->frame[idx + 1];
south->rect.width -= new->x + new->width - south->rect.x;
south->rect.x = new->x + new->width;
f->rect.x = new->x;
@ -335,21 +335,21 @@ static void _drop_move(Frame * f, XRectangle * new, XPoint * pt)
/* use pointer as fixpoint */
if (tgt == src) {
/* only change order within column */
for (i = 0; tgt->frames && tgt->frames[i]; i++) {
Frame *fp = tgt->frames[i];
for (i = 0; tgt->frame && tgt->frame[i]; i++) {
Frame *fp = tgt->frame[i];
if (blitz_ispointinrect(pt->x, pt->y, &fp->rect)) {
if (fp == f)
return; /* just ignore */
else {
int idxf = index_item((void **) tgt->frames, f);
int idxfp = index_item((void **) tgt->frames, fp);
int idxf = index_item((void **) tgt->frame, f);
int idxfp = index_item((void **) tgt->frame, fp);
Frame *tmpf = f;
XRectangle tmpr = f->rect;
f->rect = fp->rect;
fp->rect = tmpr;
tgt->frames[idxf] = tgt->frames[idxfp];
tgt->frames[idxfp] = tmpf;
tgt->frame[idxf] = tgt->frame[idxfp];
tgt->frame[idxfp] = tmpf;
resize_frame(f, &f->rect, 0, 1);
resize_frame(fp, &fp->rect, 0, 1);
}
@ -358,10 +358,10 @@ static void _drop_move(Frame * f, XRectangle * new, XPoint * pt)
}
} else {
/* detach, attach and change order in target column */
src->frames = (Frame **) detach_item((void **) src->frames,
src->frame = (Frame **) detach_item((void **) src->frame,
f, sizeof(Frame *));
tgt->frames =
(Frame **) attach_item_end((void **) tgt->frames, f,
tgt->frame =
(Frame **) attach_item_end((void **) tgt->frame, f,
sizeof(Frame *));
tgt->refresh = 1;
arrange_column(f->area, tgt);

View File

@ -295,12 +295,8 @@ void mouse_move(Frame * f)
Window dummy;
XEvent ev;
/* borders */
int snapw =
rect.width * _strtonum(defaults[WM_SNAP_VALUE]->content, 0,
1000) / 1000;
int snaph =
rect.height * _strtonum(defaults[WM_SNAP_VALUE]->content, 0,
1000) / 1000;
int snapw = rect.width * _strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
int snaph = rect.height * _strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
unsigned int num;
unsigned int dmask;
XRectangle *rects = rectangles(&num);
@ -330,7 +326,7 @@ void mouse_move(Frame * f)
draw_pseudo_border(&frect);
resize_frame(f, &frect, &pt, 0);
}
draw_page(pages[sel]);
draw_page(page[sel]);
free(rects);
XUngrabPointer(dpy, CurrentTime /* ev.xbutton.time */ );
XUngrabServer(dpy);
@ -542,12 +538,8 @@ void mouse_resize(Frame * f, Align align)
Window dummy;
XEvent ev;
/* borders */
int snapw =
rect.width * _strtonum(defaults[WM_SNAP_VALUE]->content, 0,
1000) / 1000;
int snaph =
rect.height * _strtonum(defaults[WM_SNAP_VALUE]->content, 0,
1000) / 1000;
int snapw = rect.width * _strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
int snaph = rect.height * _strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
unsigned int dmask;
unsigned int num;
XRectangle *rects = rectangles(&num);
@ -604,16 +596,16 @@ void drop_move(Frame * f, XRectangle * new, XPoint * pt)
{
Area *a = f->area;
int cx, cy;
unsigned int i, idx = index_item((void **) a->frames, f);
unsigned int i, idx = index_item((void **) a->frame, f);
if ((f->rect.x == new->x) && (f->rect.y == new->y))
return;
cx = (pt ? pt->x : new->x + new->width / 2);
cy = (pt ? pt->y : new->y + new->height / 2);
for (i = 0; a->frames[i]; i++) {
if ((a->frames[i] != f)
&& blitz_ispointinrect(cx, cy, &a->frames[i]->rect)) {
swap((void **) &a->frames[i], (void **) &a->frames[idx]);
for (i = 0; a->frame[i]; i++) {
if ((a->frame[i] != f)
&& blitz_ispointinrect(cx, cy, &a->frame[i]->rect)) {
swap((void **) &a->frame[i], (void **) &a->frame[idx]);
a->sel = i;
a->layout->arrange(a);
return;

View File

@ -26,7 +26,7 @@ Page *alloc_page(char *autodestroy)
{
Page *p = emalloc(sizeof(Page));
char buf[MAX_BUF];
int id = count_items((void **) pages) + 1;
int id = count_items((void **) page) + 1;
*p = zero_page;
snprintf(buf, sizeof(buf), "/page/%d", id);
@ -41,38 +41,37 @@ Page *alloc_page(char *autodestroy)
p->files[P_CTL]->after_write = handle_after_write_page;
snprintf(buf, sizeof(buf), "/page/%d/auto-destroy", id);
p->files[P_AUTO_DESTROY] = wmii_create_ixpfile(ixps, buf, autodestroy);
pages = (Page **) attach_item_end((void **) pages, p, sizeof(Page *));
sel = index_item((void **) pages, p);
defaults[WM_SEL_PAGE]->content = p->files[P_PREFIX]->content;
invoke_wm_event(defaults[WM_EVENT_PAGE_UPDATE]);
page = (Page **) attach_item_end((void **) page, p, sizeof(Page *));
sel = index_item((void **) page, p);
def[WM_SEL_PAGE]->content = p->files[P_PREFIX]->content;
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
return p;
}
void destroy_page(Page * p)
{
unsigned int i;
for (i = 0; p->areas[i]; i++)
destroy_area(p->areas[i]);
for (i = 0; p->area[i]; i++)
destroy_area(p->area[i]);
free_page(p);
if (pages) {
show_page(pages[sel]);
defaults[WM_SEL_PAGE]->content =
pages[sel]->files[P_PREFIX]->content;
focus_page(pages[sel], 0, 1);
invoke_wm_event(defaults[WM_EVENT_PAGE_UPDATE]);
if (page) {
show_page(page[sel]);
def[WM_SEL_PAGE]->content = page[sel]->files[P_PREFIX]->content;
focus_page(page[sel], 0, 1);
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
}
}
void free_page(Page * p)
{
pages = (Page **) detach_item((void **) pages, p, sizeof(Page *));
if (pages) {
page = (Page **) detach_item((void **) page, p, sizeof(Page *));
if (page) {
if (sel - 1 >= 0)
sel--;
else
sel = 0;
}
defaults[WM_SEL_PAGE]->content = 0;
def[WM_SEL_PAGE]->content = 0;
ixp_remove_file(ixps, p->files[P_PREFIX]);
if (ixps->errstr)
fprintf(stderr, "wmiiwm: free_page(): %s\n", ixps->errstr);
@ -81,17 +80,17 @@ void free_page(Page * p)
void focus_page(Page * p, int raise, int down)
{
if (!pages)
if (!page)
return;
if (p != pages[sel]) {
hide_page(pages[sel]);
sel = index_item((void **) pages, p);
show_page(pages[sel]);
defaults[WM_SEL_PAGE]->content = p->files[P_PREFIX]->content;
invoke_wm_event(defaults[WM_EVENT_PAGE_UPDATE]);
if (p != page[sel]) {
hide_page(page[sel]);
sel = index_item((void **) page, p);
show_page(page[sel]);
def[WM_SEL_PAGE]->content = p->files[P_PREFIX]->content;
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
}
if (down)
focus_area(p->areas[p->sel], raise, 0, down);
focus_area(p->area[p->sel], raise, 0, down);
}
void draw_page(Page * p)
@ -99,8 +98,8 @@ void draw_page(Page * p)
int i;
if (!p)
return;
for (i = 0; p->areas && p->areas[i]; i++)
draw_area(p->areas[i]);
for (i = 0; p->area && p->area[i]; i++)
draw_area(p->area[i]);
}
XRectangle *rectangles(unsigned int *num)
@ -158,15 +157,15 @@ static void select_frame(void *obj, char *cmd)
{
int i;
Frame *f, *old;
f = old = pages ? SELFRAME(pages[sel]) : 0;
f = old = page ? SELFRAME(page[sel]) : 0;
if (!f || !cmd)
return;
if (!strncmp(cmd, "prev", 5)) {
i = index_prev_item((void **) f->area->frames, f);
f = f->area->frames[i];
i = index_prev_item((void **) f->area->frame, f);
f = f->area->frame[i];
} else if (!strncmp(cmd, "next", 5)) {
i = index_next_item((void **) f->area->frames, f);
f = f->area->frames[i];
i = index_next_item((void **) f->area->frame, f);
f = f->area->frame[i];
}
if (old != f) {
focus_frame(f, 1, 1, 1);
@ -180,15 +179,15 @@ void hide_page(Page * p)
{
int i;
for (i = 0; p->areas && p->areas[i]; i++)
hide_area(p->areas[i]);
for (i = 0; p->area && p->area[i]; i++)
hide_area(p->area[i]);
}
void show_page(Page * p)
{
int i;
for (i = 0; p->areas && p->areas[i]; i++)
show_area(p->areas[i]);
for (i = 0; p->area && p->area[i]; i++)
show_area(p->area[i]);
}
Layout *get_layout(char *name)
@ -209,8 +208,8 @@ static void handle_after_write_page(IXPServer * s, File * f)
{
int i;
for (i = 0; pages && pages[i]; i++) {
Page *p = pages[i];
for (i = 0; page && page[i]; i++) {
Page *p = page[i];
if (p->files[P_CTL] == f) {
run_action(f, p, page_acttbl);
return;
@ -254,7 +253,7 @@ static void handle_after_write_page(IXPServer * s, File * f)
}
}
if (!p->layout) {
/ make all managed clients floating /
/ make all managed client floating /
int j;
Frame **tmp = 0;
while (p->managed) {
@ -294,7 +293,7 @@ attach_frame_to_page(Page * p, Frame * f, int managed)
wmii_move_ixpfile(f->files[F_PREFIX], p->files[P_MANAGED_PREFIX]);
p->files[P_MANAGED_SELECTED]->content =
f->files[F_PREFIX]->content;
if (p == pages[sel_page])
if (p == page[sel_page])
for (i = 0; p->floating && p->floating[i]; i++)
XRaiseWindow(dpy, p->floating[i]->win);
} else {

View File

@ -115,37 +115,37 @@ static void draw_pager_page(Page * p, Draw * d)
unsigned int i, j;
XRectangle r = d->rect;
char name[4];
if (p == pages[sel]) {
d->bg = blitz_loadcolor(dpy, screen_num, defaults[WM_SEL_BG_COLOR]->content);
d->fg = blitz_loadcolor(dpy, screen_num, defaults[WM_SEL_FG_COLOR]->content);
d->border = blitz_loadcolor(dpy, screen_num, defaults[WM_SEL_BORDER_COLOR]->content);
if (p == page[sel]) {
d->bg = blitz_loadcolor(dpy, screen_num, def[WM_SEL_BG_COLOR]->content);
d->fg = blitz_loadcolor(dpy, screen_num, def[WM_SEL_FG_COLOR]->content);
d->border = blitz_loadcolor(dpy, screen_num, def[WM_SEL_BORDER_COLOR]->content);
d->font = font;
} else {
d->bg = blitz_loadcolor(dpy, screen_num, defaults[WM_NORM_BG_COLOR]->content);
d->fg = blitz_loadcolor(dpy, screen_num, defaults[WM_NORM_FG_COLOR]->content);
d->border = blitz_loadcolor(dpy, screen_num, defaults[WM_NORM_BORDER_COLOR]->content);
d->bg = blitz_loadcolor(dpy, screen_num, def[WM_NORM_BG_COLOR]->content);
d->fg = blitz_loadcolor(dpy, screen_num, def[WM_NORM_FG_COLOR]->content);
d->border = blitz_loadcolor(dpy, screen_num, def[WM_NORM_BORDER_COLOR]->content);
d->font = font;
}
snprintf(name, sizeof(name), "%d", index_item((void **) pages, p));
snprintf(name, sizeof(name), "%d", index_item((void **) page, p));
d->data = name;
blitz_drawlabel(dpy, d);
XSync(dpy, False);
for (i = 0; p->areas[i]; i++) {
for (j = 0; p->areas[i]->frames[j]; j++) {
if (i == p->sel && j == p->areas[i]->sel) {
d->bg = blitz_loadcolor(dpy, screen_num, defaults[WM_SEL_BG_COLOR]->content);
d->fg = blitz_loadcolor(dpy, screen_num, defaults[WM_SEL_FG_COLOR]->content);
d->border = blitz_loadcolor(dpy, screen_num, defaults[WM_SEL_BORDER_COLOR]->content);
for (i = 0; p->area[i]; i++) {
for (j = 0; p->area[i]->frame[j]; j++) {
if (i == p->sel && j == p->area[i]->sel) {
d->bg = blitz_loadcolor(dpy, screen_num, def[WM_SEL_BG_COLOR]->content);
d->fg = blitz_loadcolor(dpy, screen_num, def[WM_SEL_FG_COLOR]->content);
d->border = blitz_loadcolor(dpy, screen_num, def[WM_SEL_BORDER_COLOR]->content);
d->font = font;
} else {
d->bg = blitz_loadcolor(dpy, screen_num, defaults[WM_NORM_BG_COLOR]->content);
d->fg = blitz_loadcolor(dpy, screen_num, defaults[WM_NORM_FG_COLOR]->content);
d->border = blitz_loadcolor(dpy, screen_num, defaults[WM_NORM_BORDER_COLOR]->content);
d->bg = blitz_loadcolor(dpy, screen_num, def[WM_NORM_BG_COLOR]->content);
d->fg = blitz_loadcolor(dpy, screen_num, def[WM_NORM_FG_COLOR]->content);
d->border = blitz_loadcolor(dpy, screen_num, def[WM_NORM_BORDER_COLOR]->content);
d->font = font;
}
d->data = p->areas[i]->frames[j]->clients[p->areas[i]->frames[j]->sel]->files[C_NAME]->content;
scale_rect(&rect, &r, &p->areas[i]->rect, &d->rect);
d->data = p->area[i]->frame[j]->client[p->area[i]->frame[j]->sel]->files[C_NAME]->content;
scale_rect(&rect, &r, &p->area[i]->rect, &d->rect);
blitz_drawlabel(dpy, d);
XSync(dpy, False); /* do not clear upwards */
}
@ -159,7 +159,7 @@ static void draw_pager()
int dx;
Draw d = { 0 };
blitz_getbasegeometry((void **) pages, &size, &cols, &rows);
blitz_getbasegeometry((void **) page, &size, &cols, &rows);
dx = (cols - 1) * GAP; /* GAPpx space */
tw = (rect.width - dx) / cols;
th = ((double) tw / rect.width) * rect.height;
@ -174,9 +174,9 @@ static void draw_pager()
else
d.rect.y = ir * (rect.height - th) / (rows - 1);
d.rect.height = th;
if (!pages[i])
if (!page[i])
return;
draw_pager_page(pages[i], &d);
draw_pager_page(page[i], &d);
i++;
}
}
@ -189,9 +189,9 @@ static Page *xy_to_pager_page(int x, int y)
int dx;
XRectangle r;
if (!pages)
if (!page)
return 0;
blitz_getbasegeometry((void **) pages, &size, &cols, &rows);
blitz_getbasegeometry((void **) page, &size, &cols, &rows);
dx = (cols - 1) * GAP; /* GAPpx space */
tw = (rect.width - dx) / cols;
th = ((double) tw / rect.width) * rect.height;
@ -205,10 +205,10 @@ static Page *xy_to_pager_page(int x, int y)
else
r.y = ir * (rect.height - th) / (rows - 1);
r.height = th;
if (!pages[i])
if (!page[i])
return 0;
if (blitz_ispointinrect(x, y, &r))
return pages[i];
return page[i];
i++;
}
}
@ -234,7 +234,7 @@ static void pager(void *obj, char *cmd)
XEvent ev;
int i;
if (!pages)
if (!page)
return;
XClearWindow(dpy, transient);
@ -256,8 +256,8 @@ static void pager(void *obj, char *cmd)
case KeyPress:
XUnmapWindow(dpy, transient);
if ((i = handle_kpress(&ev.xkey)) != -1)
if (i < count_items((void **) pages))
focus_page(pages[i], 0, 1);
if (i < count_items((void **) page))
focus_page(page[i], 0, 1);
XUngrabKeyboard(dpy, CurrentTime);
return;
break;
@ -375,9 +375,9 @@ static void icons(void *obj, char *cmd)
static void _close_client(void *obj, char *cmd)
{
Frame *f = pages ? SELFRAME(pages[sel]) : 0;
if (f->clients[f->sel])
close_client(f->clients[f->sel]);
Frame *f = page ? SELFRAME(page[sel]) : 0;
if (f->client[f->sel])
close_client(f->client[f->sel]);
}
static void _attach_client(void *obj, char *cmd)
@ -394,38 +394,38 @@ static void _attach_client(void *obj, char *cmd)
static void _detach_client(void *obj, char *cmd)
{
Frame *f;
if (!pages)
if (!page)
return;
f = SELFRAME(pages[sel]);
f = SELFRAME(page[sel]);
if (!f)
return;
detach_client_from_frame(f->clients[f->sel], 0, 0);
detach_client_from_frame(f->client[f->sel], 0, 0);
}
static void _select_page(void *obj, char *cmd)
{
if (!pages || !cmd)
if (!page || !cmd)
return;
if (!strncmp(cmd, "prev", 5))
sel = index_prev_item((void **) pages, pages[sel]);
sel = index_prev_item((void **) page, page[sel]);
else if (!strncmp(cmd, "next", 5))
sel = index_next_item((void **) pages, pages[sel]);
sel = index_next_item((void **) page, page[sel]);
else
sel = _strtonum(cmd, 0, count_items((void **) pages));
focus_page(pages[sel], 0, 1);
sel = _strtonum(cmd, 0, count_items((void **) page));
focus_page(page[sel], 0, 1);
}
static void _destroy_page(void *obj, char *cmd)
{
if (!pages)
if (!page)
return;
destroy_page(pages[sel]);
destroy_page(page[sel]);
}
static void new_page(void *obj, char *cmd)
{
if (pages)
hide_page(pages[sel]);
if (page)
hide_page(page[sel]);
alloc_page("0");
}
@ -433,9 +433,9 @@ Client *win_to_client(Window w)
{
int i;
for (i = 0; clients && clients[i]; i++)
if (clients[i]->win == w)
return clients[i];
for (i = 0; client && client[i]; i++)
if (client[i]->win == w)
return client[i];
return 0;
}
@ -521,14 +521,14 @@ int win_state(Window w)
void handle_after_write(IXPServer * s, File * f)
{
if (f == defaults[WM_CTL])
if (f == def[WM_CTL])
run_action(f, 0, wm_acttbl);
else if (f == defaults[WM_TRANS_COLOR]) {
else if (f == def[WM_TRANS_COLOR]) {
unsigned long col[1];
col[0] = xorcolor.pixel;
XFreeColors(dpy, DefaultColormap(dpy, screen_num), col, 1, 0);
XAllocNamedColor(dpy, DefaultColormap(dpy, screen_num),
defaults[WM_TRANS_COLOR]->content,
def[WM_TRANS_COLOR]->content,
&xorcolor, &xorcolor);
XSetForeground(dpy, xorgc, xorcolor.pixel);
}
@ -561,35 +561,35 @@ static void init_cursors()
se_cursor = XCreateFontCursor(dpy, XC_bottom_right_corner);
}
static void init_defaults()
static void init_default()
{
defaults[WM_DETACHED_FRAME] = ixp_create(ixps, "/detached/frame");
defaults[WM_DETACHED_CLIENT] = ixp_create(ixps, "/detached/client");
defaults[WM_TRANS_COLOR] = wmii_create_ixpfile(ixps, "/default/transcolor", BLITZ_SEL_FG_COLOR);
defaults[WM_TRANS_COLOR]->after_write = handle_after_write;
defaults[WM_SEL_BG_COLOR] = wmii_create_ixpfile(ixps, "/default/selstyle/bgcolor", BLITZ_SEL_BG_COLOR);
defaults[WM_SEL_FG_COLOR] = wmii_create_ixpfile(ixps, "/default/selstyle/fgcolor", BLITZ_SEL_FG_COLOR);
defaults[WM_SEL_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/default/selstyle/fgcolor", BLITZ_SEL_BORDER_COLOR);
defaults[WM_NORM_BG_COLOR] = wmii_create_ixpfile(ixps, "/default/normstyle/bgcolor", BLITZ_NORM_BG_COLOR);
defaults[WM_NORM_FG_COLOR] = wmii_create_ixpfile(ixps, "/default/normstyle/fgcolor", BLITZ_NORM_FG_COLOR);
defaults[WM_NORM_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/default/normstyle/fgcolor", BLITZ_NORM_BORDER_COLOR);
defaults[WM_FONT] = wmii_create_ixpfile(ixps, "/default/font", BLITZ_FONT);
defaults[WM_FONT]->after_write = handle_after_write;
defaults[WM_PAGE_SIZE] = wmii_create_ixpfile(ixps, "/default/pagesize", "0,0,east,south-16");
defaults[WM_SNAP_VALUE] = wmii_create_ixpfile(ixps, "/default/snapvalue", "20"); /* 0..1000 */
defaults[WM_BORDER] = wmii_create_ixpfile(ixps, "/default/border", "1");
defaults[WM_TAB] = wmii_create_ixpfile(ixps, "/default/tab", "1");
defaults[WM_HANDLE_INC] = wmii_create_ixpfile(ixps, "/default/handleinc", "1");
defaults[WM_LOCKED] = wmii_create_ixpfile(ixps, "/default/locked", "1");
defaults[WM_LAYOUT] = wmii_create_ixpfile(ixps, "/default/layout", LAYOUT);
defaults[WM_SEL_PAGE] = ixp_create(ixps, "/page/sel");
defaults[WM_EVENT_PAGE_UPDATE] = ixp_create(ixps, "/default/event/pageupdate");
defaults[WM_EVENT_CLIENT_UPDATE] = ixp_create(ixps, "/default/event/clientupdate");
defaults[WM_EVENT_B1PRESS] = ixp_create(ixps, "/defaults/event/b1press");
defaults[WM_EVENT_B2PRESS] = ixp_create(ixps, "/defaults/event/b2press");
defaults[WM_EVENT_B3PRESS] = ixp_create(ixps, "/defaults/event/b3press");
defaults[WM_EVENT_B4PRESS] = ixp_create(ixps, "/defaults/event/b4press");
defaults[WM_EVENT_B5PRESS] = ixp_create(ixps, "/defaults/event/b5press");
def[WM_DETACHED_FRAME] = ixp_create(ixps, "/detached/frame");
def[WM_DETACHED_CLIENT] = ixp_create(ixps, "/detached/client");
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_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_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, "/page/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");
def[WM_EVENT_B2PRESS] = ixp_create(ixps, "/default/event/b2press");
def[WM_EVENT_B3PRESS] = ixp_create(ixps, "/default/event/b3press");
def[WM_EVENT_B4PRESS] = ixp_create(ixps, "/default/event/b4press");
def[WM_EVENT_B5PRESS] = ixp_create(ixps, "/default/event/b5press");
}
static void init_screen()
@ -598,7 +598,7 @@ static void init_screen()
XSetWindowAttributes wa;
XAllocNamedColor(dpy, DefaultColormap(dpy, screen_num),
defaults[WM_TRANS_COLOR]->content,
def[WM_TRANS_COLOR]->content,
&xorcolor, &xorcolor);
gcv.subwindow_mode = IncludeInferiors;
gcv.function = GXxor;
@ -665,8 +665,8 @@ static void cleanup()
int i;
XWindowChanges wc;
for (i = 0; clients && clients[i]; i++) {
Client *c = clients[i];
for (i = 0; client && client[i]; i++) {
Client *c = client[i];
Frame *f = c->frame;
if (f) {
gravitate(c, tab_height(f), border_width(f), 1);
@ -684,23 +684,23 @@ static void run()
/* init */
init_event_hander();
if (!(defaults[WM_CTL] = ixp_create(ixps, "/ctl"))) {
if (!(def[WM_CTL] = ixp_create(ixps, "/ctl"))) {
perror("wmiiwm: cannot connect IXP server");
exit(1);
}
defaults[WM_CTL]->after_write = handle_after_write;
def[WM_CTL]->after_write = handle_after_write;
clients = 0;
frames = 0;
client = 0;
frame = 0;
detached = 0;
pages = 0;
page = 0;
layouts = 0;
sel = 0;
init_atoms();
init_cursors();
init_defaults();
font = blitz_getfont(dpy, defaults[WM_FONT]->content);
init_default();
font = blitz_getfont(dpy, def[WM_FONT]->content);
init_lock_modifiers(dpy, &valid_mask, &num_lock_mask);
init_screen();
init_layouts();

View File

@ -113,7 +113,7 @@ typedef struct Client Client;
*/
struct Page {
Area **areas;
Area **area;
unsigned int sel;
File *files[P_LAST];
};
@ -131,7 +131,7 @@ struct Layout {
struct Area {
Layout *layout;
Page *page;
Frame **frames;
Frame **frame;
unsigned int sel;
XRectangle rect;
void *aux; /* free pointer */
@ -144,7 +144,7 @@ struct Frame {
GC gc;
XRectangle rect;
Cursor cursor;
Client **clients;
Client **client;
int sel;
void *aux; /* free pointer */
File *files[F_LAST];
@ -161,8 +161,8 @@ struct Client {
File *files[C_LAST];
};
#define SELFRAME(x) (x && x->areas[x->sel]->frames ? x->areas[x->sel]->frames[x->areas[x->sel]->sel] : 0)
#define ISSELFRAME(x) (pages && SELFRAME(pages[sel]) == x)
#define SELFRAME(x) (x && x->area[x->sel]->frame ? x->area[x->sel]->frame[x->area[x->sel]->sel] : 0)
#define ISSELFRAME(x) (page && SELFRAME(page[sel]) == x)
/* global variables */
Display *dpy;
@ -172,10 +172,10 @@ Window root;
Window transient;
XRectangle rect;
Client **detached;
Page **pages;
Page **page;
unsigned int sel;
Frame **frames;
Client **clients;
Frame **frame;
Client **client;
XFontStruct *font;
XColor xorcolor;
GC xorgc;
@ -203,7 +203,7 @@ Cursor sw_cursor;
Cursor se_cursor;
/* default file pointers */
File *defaults[WM_LAST];
File *def[WM_LAST];
unsigned int valid_mask, num_lock_mask;

View File

@ -17,7 +17,8 @@ LIBS = -L${LIBDIR} -L/usr/lib -lc -lm -L${X11LIB} -lX11
VERSION = 3-current
# flags
CFLAGS = -O0 -g -Wall -W ${INCLUDES} -DVERSION=\"${VERSION}\"
CFLAGS = -O0 -g -Wall ${INCLUDES} -DVERSION=\"${VERSION}\"
#CFLAGS = -O0 -g -Wall -W ${INCLUDES} -DVERSION=\"${VERSION}\"
LDFLAGS = -g ${LIBS}
# compiler