mirror of https://github.com/0intro/wmii
removed the insert_* insanity, added cext_vattachat instead
This commit is contained in:
parent
df70479dc8
commit
a9e9456f42
|
@ -389,9 +389,9 @@ drop_move(Frame *f, XRectangle *new, XPoint *pt)
|
||||||
cext_vdetach(vector_of_frames(&tgt->frame), f);
|
cext_vdetach(vector_of_frames(&tgt->frame), f);
|
||||||
|
|
||||||
if(before)
|
if(before)
|
||||||
insert_before_idx(&tgt->frame, f, fidx);
|
cext_vattachat(vector_of_frames(&tgt->frame), f, fidx);
|
||||||
else
|
else
|
||||||
insert_after_idx(&tgt->frame, f, fidx);
|
cext_vattachat(vector_of_frames(&tgt->frame), f, fidx + 1);
|
||||||
|
|
||||||
tgt->sel = idx_of_frame(f);
|
tgt->sel = idx_of_frame(f);
|
||||||
arrange_column(tgt, False);
|
arrange_column(tgt, False);
|
||||||
|
@ -403,9 +403,9 @@ drop_move(Frame *f, XRectangle *new, XPoint *pt)
|
||||||
fidx = idx_of_frame(ft);
|
fidx = idx_of_frame(ft);
|
||||||
|
|
||||||
if(pt->y < (ft->rect.y + ft->rect.height / 2))
|
if(pt->y < (ft->rect.y + ft->rect.height / 2))
|
||||||
insert_before_idx(&tgt->frame, f, fidx);
|
cext_vattachat(vector_of_frames(&tgt->frame), f, fidx);
|
||||||
else
|
else
|
||||||
insert_after_idx(&tgt->frame, f, fidx);
|
cext_vattachat(vector_of_frames(&tgt->frame), f, fidx + 1);
|
||||||
|
|
||||||
tgt->sel = idx_of_frame(f);
|
tgt->sel = idx_of_frame(f);
|
||||||
arrange_column(tgt, False);
|
arrange_column(tgt, False);
|
||||||
|
|
|
@ -26,16 +26,9 @@ create_frame(Area *a, Client *c)
|
||||||
f->rect.width += 2 * def.border;
|
f->rect.width += 2 * def.border;
|
||||||
f->rect.height += def.border + height_of_bar();
|
f->rect.height += def.border + height_of_bar();
|
||||||
cext_vattach(vector_of_frames(&c->frame), f);
|
cext_vattach(vector_of_frames(&c->frame), f);
|
||||||
|
a->sel = a->frame.size ? a->sel + 1 : 0;
|
||||||
|
cext_vattachat(vector_of_frames(&a->frame), f, a->sel);
|
||||||
c->sel = c->frame.size - 1;
|
c->sel = c->frame.size - 1;
|
||||||
if(a->frame.size) {
|
|
||||||
insert_after_idx(&a->frame, f, a->sel);
|
|
||||||
a->sel++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cext_vattach(vector_of_frames(&a->frame), f);
|
|
||||||
a->sel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,37 +77,3 @@ frame_of_win(Window w)
|
||||||
return client.data[i];
|
return client.data[i];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
xinsert(FrameVector *fv, Frame *f, unsigned int idx, Bool before)
|
|
||||||
{
|
|
||||||
FrameVector tmp = {0};
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
for(i = 0; i < fv->size; i++) {
|
|
||||||
if(before && (i == idx))
|
|
||||||
cext_vattach(vector_of_frames(&tmp), f);
|
|
||||||
cext_vattach(vector_of_frames(&tmp), fv->data[i]);
|
|
||||||
if(!before && (i == idx))
|
|
||||||
cext_vattach(vector_of_frames(&tmp), f);
|
|
||||||
}
|
|
||||||
|
|
||||||
while(fv->size)
|
|
||||||
cext_vdetach(vector_of_frames(fv), fv->data[0]);
|
|
||||||
for(i = 0; i < tmp.size; i++)
|
|
||||||
cext_vattach(vector_of_frames(fv), tmp.data[i]);
|
|
||||||
while(tmp.size)
|
|
||||||
cext_vdetach(vector_of_frames(&tmp), tmp.data[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
insert_before_idx(FrameVector *fv, Frame *f, unsigned int idx)
|
|
||||||
{
|
|
||||||
xinsert(fv, f, idx, True);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
insert_after_idx(FrameVector *fv, Frame *f, unsigned int idx)
|
|
||||||
{
|
|
||||||
xinsert(fv, f, idx, False);
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,5 +40,5 @@ typedef struct { \
|
||||||
VECTOR(Vector, void *);
|
VECTOR(Vector, void *);
|
||||||
|
|
||||||
void cext_vattach(Vector *v, void *p);
|
void cext_vattach(Vector *v, void *p);
|
||||||
|
void cext_vattachat(Vector *v, void *p, unsigned int pos);
|
||||||
void cext_vdetach(Vector *v, void *p);
|
void cext_vdetach(Vector *v, void *p);
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,23 @@ cext_vattach(Vector *v, void *p)
|
||||||
{
|
{
|
||||||
++v->size;
|
++v->size;
|
||||||
if (!(v->data = realloc(v->data, v->size * sizeof(void *)))) {
|
if (!(v->data = realloc(v->data, v->size * sizeof(void *)))) {
|
||||||
fprintf(stderr, "%s\n", "Out of memory in cext_evector_attach\n");
|
fprintf(stderr, "%s\n", "Out of memory in cext_vattach\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
v->data[v->size - 1] = p;
|
v->data[v->size - 1] = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cext_vattachat(Vector *v, void *p, unsigned int pos)
|
||||||
|
{
|
||||||
|
cext_vattach(v, p);
|
||||||
|
if(pos >= v->size)
|
||||||
|
return;
|
||||||
|
memmove(v->data + pos + 1, v->data + pos,
|
||||||
|
(v->size - pos - 1) * sizeof(void *));
|
||||||
|
v->data[pos] = p;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cext_vdetach(Vector *v, void *data)
|
cext_vdetach(Vector *v, void *data)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue