some more fixes of new interface

This commit is contained in:
garbeam 2005-12-06 23:14:35 +02:00
parent 4c25ff1ad5
commit 004b0da2cc
5 changed files with 31 additions and 16 deletions

View File

@ -98,28 +98,31 @@ Frame *alloc_frame(XRectangle * r)
XDefineCursor(dpy, f->win, f->cursor); XDefineCursor(dpy, f->win, f->cursor);
f->gc = XCreateGC(dpy, f->win, 0, 0); f->gc = XCreateGC(dpy, f->win, 0, 0);
XSync(dpy, False); XSync(dpy, False);
frame = (Frame **) attach_item_end((void **) frame, f, sizeof(Frame *)); cext_attach_item(&frames, f);
return f; return f;
} }
void sel_frame(Frame * f, int raise) void sel_frame(Frame * f, int raise)
{ {
Area *a = f->area; Area *a = f->area;
sel_client(f->client[f->sel]); sel_client(cext_get_top_item(&f->clients));
a->sel = index_item((void **) a->frame, f); cext_top_item(&a->frames, f);
a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content; a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content;
if (raise) if (raise)
XRaiseWindow(dpy, f->win); XRaiseWindow(dpy, f->win);
} }
static int comp_frame_win(void *pattern, void *frame)
{
Window w = *(Window *)pattern;
Frame *f = frame;
return w == f->win;
}
Frame *win_to_frame(Window w) Frame *win_to_frame(Window w)
{ {
int i; return cext_find_item(&frames, w, comp_frame_win);
for (i = 0; frame && frame[i]; i++)
if (frame[i]->win == w)
return frame[i];
return 0;
} }
void destroy_frame(Frame * f) void destroy_frame(Frame * f)

View File

@ -594,7 +594,7 @@ void mouse_resize(Frame * f, Align align)
void drop_move(Frame *f, XRectangle *new, XPoint *pt) void drop_move(Frame *f, XRectangle *new, XPoint *pt)
{ {
Frame *fp; Frame *f1, *f2;
Area *a = f->area; Area *a = f->area;
int cx, cy; int cx, cy;
unsigned int i, idx = cext_get_item_index(&a->frames, f); 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; return;
cx = (pt ? pt->x : new->x + new->width / 2); cx = (pt ? pt->x : new->x + new->width / 2);
cy = (pt ? pt->y : new->y + new->height / 2); cy = (pt ? pt->y : new->y + new->height / 2);
f1 = cext_get_item(&a->frames, idx);
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
fp = cext_get_item(&a->frames, idx); f2 = cext_get_item(&a->frames, i);
if ((i != idx) && blitz_ispointinrect(cx, cy, &fp->rect)) { if ((i != idx) && blitz_ispointinrect(cx, cy, &f1->rect)) {
/* XXXX: implement swap replacement */ /* XXXX: implement swap replacement */
swap((void **) &a->frame[i], (void **) &a->frame[idx]); cext_swap_items(&a->frames, f1, f2);
a->sel = i; cext_top_item(&a->frames, f2);
a->layout->arrange(a); a->layout->arrange(a);
return; return;
} }

View File

@ -428,7 +428,7 @@ static void new_page(void *obj, char *cmd)
alloc_page(); alloc_page();
} }
static int comp_win(void *pattern, void *client) static int comp_client_win(void *pattern, void *client)
{ {
Window w = *(Window *)pattern; Window w = *(Window *)pattern;
Client *c = client; Client *c = client;
@ -438,7 +438,7 @@ static int comp_win(void *pattern, void *client)
Client *win_to_client(Window w) 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() void scan_wins()

View File

@ -42,6 +42,7 @@ void *cext_get_up_item(Container *c, void *item);
void *cext_get_item(Container *c, size_t index); void *cext_get_item(Container *c, size_t index);
int cext_get_item_index(Container *c, void *item); int cext_get_item_index(Container *c, void *item);
size_t cext_sizeof(Container *c); 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_begin(void **old, void *item, size_t size_item);
void **attach_item_end(void **old, void *item, size_t size_item); void **attach_item_end(void **old, void *item, size_t size_item);

View File

@ -149,6 +149,16 @@ size_t cext_sizeof(Container *c)
return idx; 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 */ /* old obsolete stuff follows */
void **attach_item_begin(void **old, void *item, size_t size_item) void **attach_item_begin(void **old, void *item, size_t size_item)