wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 004b0da2cc59b92d4062f5df0f43d9c3e4d08a11
parent 4c25ff1ad5d7d76554ec7bb632b520cf76a59d19
Author: garbeam <garbeam@localhost.localdomain>
Date:   Tue,  6 Dec 2005 23:14:35 +0200

some more fixes of new interface


Diffstat:
cmd/wm/frame.c | 21++++++++++++---------
cmd/wm/mouse.c | 11++++++-----
cmd/wm/wm.c | 4++--
libcext/cext.h | 1+
libcext/container.c | 10++++++++++
5 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c @@ -98,28 +98,31 @@ Frame *alloc_frame(XRectangle * r) XDefineCursor(dpy, f->win, f->cursor); f->gc = XCreateGC(dpy, f->win, 0, 0); XSync(dpy, False); - frame = (Frame **) attach_item_end((void **) frame, f, sizeof(Frame *)); + cext_attach_item(&frames, f); return f; } void sel_frame(Frame * f, int raise) { Area *a = f->area; - sel_client(f->client[f->sel]); - a->sel = index_item((void **) a->frame, f); + sel_client(cext_get_top_item(&f->clients)); + cext_top_item(&a->frames, f); a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content; if (raise) XRaiseWindow(dpy, f->win); } -Frame *win_to_frame(Window w) +static int comp_frame_win(void *pattern, void *frame) { - int i; + Window w = *(Window *)pattern; + Frame *f = frame; - for (i = 0; frame && frame[i]; i++) - if (frame[i]->win == w) - return frame[i]; - return 0; + return w == f->win; +} + +Frame *win_to_frame(Window w) +{ + return cext_find_item(&frames, w, comp_frame_win); } void destroy_frame(Frame * f) diff --git a/cmd/wm/mouse.c b/cmd/wm/mouse.c @@ -594,7 +594,7 @@ void mouse_resize(Frame * f, Align align) void drop_move(Frame *f, XRectangle *new, XPoint *pt) { - Frame *fp; + Frame *f1, *f2; Area *a = f->area; int cx, cy; unsigned int i, idx = cext_get_item_index(&a->frames, f); @@ -604,12 +604,13 @@ void drop_move(Frame *f, XRectangle *new, XPoint *pt) return; cx = (pt ? pt->x : new->x + new->width / 2); cy = (pt ? pt->y : new->y + new->height / 2); + f1 = cext_get_item(&a->frames, idx); for (i = 0; i < size; i++) { - fp = cext_get_item(&a->frames, idx); - if ((i != idx) && blitz_ispointinrect(cx, cy, &fp->rect)) { + f2 = cext_get_item(&a->frames, i); + if ((i != idx) && blitz_ispointinrect(cx, cy, &f1->rect)) { /* XXXX: implement swap replacement */ - swap((void **) &a->frame[i], (void **) &a->frame[idx]); - a->sel = i; + cext_swap_items(&a->frames, f1, f2); + cext_top_item(&a->frames, f2); a->layout->arrange(a); return; } diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -428,7 +428,7 @@ static void new_page(void *obj, char *cmd) alloc_page(); } -static int comp_win(void *pattern, void *client) +static int comp_client_win(void *pattern, void *client) { Window w = *(Window *)pattern; Client *c = client; @@ -438,7 +438,7 @@ static int comp_win(void *pattern, void *client) Client *win_to_client(Window w) { - return cext_find_item(&clients, &w, comp_win); + return cext_find_item(&clients, &w, comp_client_win); } void scan_wins() diff --git a/libcext/cext.h b/libcext/cext.h @@ -42,6 +42,7 @@ void *cext_get_up_item(Container *c, void *item); void *cext_get_item(Container *c, size_t index); int cext_get_item_index(Container *c, void *item); size_t cext_sizeof(Container *c); +void cext_swap_items(Container *c, void *item1, void *item2); void **attach_item_begin(void **old, void *item, size_t size_item); void **attach_item_end(void **old, void *item, size_t size_item); diff --git a/libcext/container.c b/libcext/container.c @@ -149,6 +149,16 @@ size_t cext_sizeof(Container *c) return idx; } +void cext_swap_items(Container *c, void *item1, void *item2) +{ + CItem *i1 = cext_find_item(c, item1, comp_ptr); + CItem *i2 = cext_find_item(c, item2, comp_ptr); + + i1->item = item2; + i2->item = item1; +} + + /* old obsolete stuff follows */ void **attach_item_begin(void **old, void *item, size_t size_item)