mirror of
https://github.com/0intro/wmii
synced 2025-03-19 13:13:57 +03:00
proceeded with frames backref in Client struct
This commit is contained in:
parent
d56bb672f8
commit
f195ff6bdf
@ -125,7 +125,10 @@ attach_toarea(Area *a, Client *c)
|
||||
f->rect = c->rect;
|
||||
f->rect.width += 2 * def.border;
|
||||
f->rect.height += def.border + bar_height();
|
||||
c->frame = f;
|
||||
c->frame = (Frame **)cext_array_attach(
|
||||
(void **)c->frame, f, sizeof(Frame *), &c->framesz);
|
||||
c->nframe++;
|
||||
c->sel = c->nframe - 1;
|
||||
a->frame = (Frame **)cext_array_attach(
|
||||
(void **)a->frame, f, sizeof(Frame *), &a->framesz);
|
||||
a->nframe++;
|
||||
@ -138,13 +141,23 @@ attach_toarea(Area *a, Client *c)
|
||||
void
|
||||
detach_fromarea(Area *a, Client *c)
|
||||
{
|
||||
Frame *f = c->frame;
|
||||
Frame *f;
|
||||
Tag *t = a->tag;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < c->nframe; i++)
|
||||
if(c->frame[i]->area == a) {
|
||||
f = c->frame[i];
|
||||
break;
|
||||
}
|
||||
|
||||
cext_array_detach((void **)c->frame, f, &c->framesz);
|
||||
cext_array_detach((void **)a->frame, f, &a->framesz);
|
||||
free(f);
|
||||
c->nframe--;
|
||||
a->nframe--;
|
||||
c->frame = nil;
|
||||
if(c->sel >= c->nframe)
|
||||
c->sel = 0;
|
||||
if(a->sel >= a->nframe)
|
||||
a->sel = 0;
|
||||
if(a->nframe)
|
||||
@ -400,7 +413,7 @@ drop_moving(Frame *f, XRectangle *new, XPoint * pt)
|
||||
void
|
||||
resize_area(Client *c, XRectangle *r, XPoint *pt)
|
||||
{
|
||||
Frame *f = c->frame;
|
||||
Frame *f = c->frame[c->sel];
|
||||
if((f->rect.width == r->width)
|
||||
&& (f->rect.height == r->height))
|
||||
drop_moving(f, r, pt);
|
||||
|
@ -71,8 +71,8 @@ static void
|
||||
client_focus_event(Client *c)
|
||||
{
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "CF %d %d %d %d\n", c->frame->rect.x, c->frame->rect.y,
|
||||
c->frame->rect.width, c->frame->rect.height);
|
||||
snprintf(buf, sizeof(buf), "CF %d %d %d %d\n", c->frame[c->sel]->rect.x, c->frame[c->sel]->rect.y,
|
||||
c->frame[c->sel]->rect.width, c->frame[c->sel]->rect.height);
|
||||
write_event(buf);
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ void
|
||||
focus_client(Client *c)
|
||||
{
|
||||
Client *old = sel_client();
|
||||
Frame *f = c->frame;
|
||||
Frame *f = c->frame[c->sel];
|
||||
int i = area2index(f->area);
|
||||
|
||||
f->area->tag->sel = i;
|
||||
@ -132,7 +132,7 @@ void
|
||||
configure_client(Client *c)
|
||||
{
|
||||
XConfigureEvent e;
|
||||
Frame *f = c->frame;
|
||||
Frame *f = c->frame[c->sel];
|
||||
e.type = ConfigureNotify;
|
||||
e.event = c->win;
|
||||
e.window = c->win;
|
||||
@ -240,14 +240,14 @@ draw_client(Client *c)
|
||||
|
||||
/* draw border */
|
||||
if(def.border) {
|
||||
d.rect = c->frame->rect;
|
||||
d.rect = c->frame[c->sel]->rect;
|
||||
d.rect.x = d.rect.y = 0;
|
||||
d.notch = &c->rect;
|
||||
blitz_drawlabel(dpy, &d);
|
||||
}
|
||||
d.rect.x = 0;
|
||||
d.rect.y = 0;
|
||||
d.rect.width = c->frame->rect.width;
|
||||
d.rect.width = c->frame[c->sel]->rect.width;
|
||||
d.rect.height = bar_height();
|
||||
d.notch = nil;
|
||||
snprintf(buf, sizeof(buf), "%s | %s", c->tags, c->name);
|
||||
@ -339,9 +339,9 @@ detach_client(Client *c, Bool unmap)
|
||||
detach_fromtag(tag[i], c, unmap);
|
||||
if(!unmap)
|
||||
unmap_client(c);
|
||||
if(c->frame) {
|
||||
c->rect.x = c->frame->rect.x;
|
||||
c->rect.y = c->frame->rect.y;
|
||||
if(c->nframe) {
|
||||
c->rect.x = c->frame[c->sel]->rect.x;
|
||||
c->rect.y = c->frame[c->sel]->rect.y;
|
||||
reparent_client(c, root, c->rect.x, c->rect.y);
|
||||
XUnmapWindow(dpy, c->framewin);
|
||||
}
|
||||
@ -403,20 +403,20 @@ match_sizehints(Client *c)
|
||||
h = c->size.min_height;
|
||||
}
|
||||
/* client_width = base_width + i * c->size.width_inc for an integer i */
|
||||
w = c->frame->rect.width - 2 * def.border - w;
|
||||
w = c->frame[c->sel]->rect.width - 2 * def.border - w;
|
||||
if(s->width_inc > 0)
|
||||
c->frame->rect.width -= w % s->width_inc;
|
||||
c->frame[c->sel]->rect.width -= w % s->width_inc;
|
||||
|
||||
h = c->frame->rect.height - def.border - bar_height() - h;
|
||||
h = c->frame[c->sel]->rect.height - def.border - bar_height() - h;
|
||||
if(s->height_inc > 0)
|
||||
c->frame->rect.height -= h % s->height_inc;
|
||||
c->frame[c->sel]->rect.height -= h % s->height_inc;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall)
|
||||
{
|
||||
Frame *f = c->frame;
|
||||
Frame *f = c->frame[c->sel];
|
||||
int pi = tag2index(f->area->tag);
|
||||
int px = sel * rect.width;
|
||||
|
||||
@ -467,7 +467,7 @@ frame2index(Frame *f)
|
||||
void
|
||||
select_client(Client *c, char *arg)
|
||||
{
|
||||
Frame *f = c->frame;
|
||||
Frame *f = c->frame[c->sel];
|
||||
Area *a = f->area;
|
||||
int i = frame2index(f);
|
||||
if(i == -1)
|
||||
@ -496,7 +496,7 @@ void
|
||||
sendtoarea_client(Client *c, char *arg)
|
||||
{
|
||||
const char *errstr;
|
||||
Frame *f = c->frame;
|
||||
Frame *f = c->frame[c->sel];
|
||||
Area *to, *a = f->area;
|
||||
Tag *t = a->tag;
|
||||
int i = area2index(a);
|
||||
@ -533,15 +533,15 @@ resize_all_clients()
|
||||
{
|
||||
unsigned int i;
|
||||
for(i = 0; i < nclient; i++)
|
||||
if(client[i]->frame->area)
|
||||
resize_client(client[i], &client[i]->frame->rect, 0, False);
|
||||
if(client[i]->frame[client[i]->sel]->area)
|
||||
resize_client(client[i], &client[i]->frame[client[i]->sel]->rect, 0, False);
|
||||
}
|
||||
|
||||
/* convenience function */
|
||||
void
|
||||
focus(Client *c)
|
||||
{
|
||||
Frame *f = c->frame;
|
||||
Frame *f = c->frame[c->sel];
|
||||
Tag *t = f->area->tag;
|
||||
if(tag[sel] != t)
|
||||
focus_tag(t);
|
||||
|
@ -83,8 +83,8 @@ handle_buttonpress(XEvent *e)
|
||||
mouse_resize(c, align);
|
||||
}
|
||||
|
||||
if(c->frame) {
|
||||
snprintf(buf, sizeof(buf), "CB %d %d\n", frame2index(c->frame) + 1, ev->button);
|
||||
if(c->nframe) {
|
||||
snprintf(buf, sizeof(buf), "CB %d %d\n", frame2index(c->frame[c->sel]) + 1, ev->button);
|
||||
write_event(buf);
|
||||
}
|
||||
}
|
||||
@ -110,8 +110,8 @@ handle_buttonpress(XEvent *e)
|
||||
else if(ev->button == Button1)
|
||||
focus(c);
|
||||
|
||||
if(c->frame) {
|
||||
snprintf(buf, sizeof(buf), "CB %d %d\n", frame2index(c->frame) + 1, ev->button);
|
||||
if(c->nframe) {
|
||||
snprintf(buf, sizeof(buf), "CB %d %d\n", frame2index(c->frame[c->sel]) + 1, ev->button);
|
||||
write_event(buf);
|
||||
}
|
||||
}
|
||||
@ -144,8 +144,8 @@ handle_configurerequest(XEvent *e)
|
||||
|
||||
gravitate(c, False);
|
||||
|
||||
if(c->frame) {
|
||||
Frame *f = c->frame;
|
||||
if(c->nframe) {
|
||||
Frame *f = c->frame[c->sel];
|
||||
f->rect.x = wc.x = c->rect.x - def.border;
|
||||
f->rect.y = wc.y = c->rect.y - bar_height();
|
||||
f->rect.width = wc.width = c->rect.width + 2 * def.border;
|
||||
|
12
cmd/wm/fs.c
12
cmd/wm/fs.c
@ -1024,7 +1024,7 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
char buf[256];
|
||||
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
|
||||
unsigned char type;
|
||||
int i, i1 = 0, i2 = 0, i3 = 0;
|
||||
int i, j, i1 = 0, i2 = 0, i3 = 0;
|
||||
Frame *f;
|
||||
|
||||
if(!m)
|
||||
@ -1164,8 +1164,9 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
def.selcolor[fcall->count] = 0;
|
||||
blitz_loadcolor(dpy, screen, def.selcolor, &def.sel);
|
||||
for(i = 0; i < nclient; i++)
|
||||
if(client[i]->frame->area->tag == tag[sel])
|
||||
draw_client(client[i]);
|
||||
for(j = 0; j < client[i]->nframe; j++)
|
||||
if(client[i]->frame[j]->area->tag == tag[sel])
|
||||
draw_client(client[i]);
|
||||
break;
|
||||
case FsFnormcolors:
|
||||
if((fcall->count != 23)
|
||||
@ -1177,8 +1178,9 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
def.normcolor[fcall->count] = 0;
|
||||
blitz_loadcolor(dpy, screen, def.normcolor, &def.norm);
|
||||
for(i = 0; i < nclient; i++)
|
||||
if(client[i]->frame->area->tag == tag[sel])
|
||||
draw_client(client[i]);
|
||||
for(j = 0; j < client[i]->nframe; j++)
|
||||
if(client[i]->frame[j]->area->tag == tag[sel])
|
||||
draw_client(client[i]);
|
||||
break;
|
||||
case FsFfont:
|
||||
if(def.font)
|
||||
|
@ -12,7 +12,7 @@
|
||||
Cursor
|
||||
cursor_for_motion(Client *c, int x, int y)
|
||||
{
|
||||
Frame *f = c->frame;
|
||||
Frame *f = c->frame[c->sel];
|
||||
int n, e, w, s, tn, te, tw, ts;
|
||||
|
||||
if(!def.border)
|
||||
@ -306,7 +306,7 @@ mouse_move(Client *c)
|
||||
unsigned int num;
|
||||
unsigned int dmask;
|
||||
XRectangle *rects = rectangles(&num);
|
||||
XRectangle frect = c->frame->rect;
|
||||
XRectangle frect = c->frame[c->sel]->rect;
|
||||
XPoint pt;
|
||||
|
||||
XQueryPointer(dpy, c->framewin, &dummy, &dummy, &i, &i, &wex, &wey, &dmask);
|
||||
@ -551,7 +551,7 @@ mouse_resize(Client *c, Align align)
|
||||
unsigned int dmask;
|
||||
unsigned int num;
|
||||
XRectangle *rects = rectangles(&num);
|
||||
XRectangle frect = c->frame->rect;
|
||||
XRectangle frect = c->frame[c->sel]->rect;
|
||||
XRectangle origin = frect;
|
||||
|
||||
XQueryPointer(dpy, c->framewin, &dummy, &dummy, &i, &i, &ox, &oy, &dmask);
|
||||
|
13
cmd/wm/tag.c
13
cmd/wm/tag.c
@ -61,7 +61,7 @@ void
|
||||
focus_tag(Tag *t)
|
||||
{
|
||||
char buf[16];
|
||||
int i, pi = tag2index(t);
|
||||
int i, j, pi = tag2index(t);
|
||||
int px;
|
||||
|
||||
if(!ntag || (pi == -1))
|
||||
@ -69,10 +69,17 @@ focus_tag(Tag *t)
|
||||
|
||||
sel = pi;
|
||||
px = sel * rect.width;
|
||||
|
||||
/* select correct frames of clients */
|
||||
for(i = 0; i < nclient; i++)
|
||||
for(j = 0; j < client[i]->nframe; j++)
|
||||
if(client[i]->frame[j]->area->tag == t)
|
||||
client[i]->sel = j;
|
||||
|
||||
/* gives all(!) clients proper geometry (for use of different tags) */
|
||||
for(i = 0; i < nclient; i++)
|
||||
if(client[i]->frame) {
|
||||
Frame *f = client[i]->frame;
|
||||
if(client[i]->nframe) {
|
||||
Frame *f = client[i]->frame[client[i]->sel];
|
||||
pi = tag2index(f->area->tag);
|
||||
XMoveWindow(dpy, client[i]->framewin, px - (pi * rect.width) + f->rect.x, f->rect.y);
|
||||
if(f->area->tag == t)
|
||||
|
@ -220,7 +220,7 @@ cleanup()
|
||||
Client *c;
|
||||
for(i = 0; client && client[i]; i++) {
|
||||
c = client[i];
|
||||
reparent_client(c, root, c->frame->rect.x, c->frame->rect.y);
|
||||
reparent_client(c, root, c->frame[c->sel]->rect.x, c->frame[c->sel]->rect.y);
|
||||
}
|
||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||
XSync(dpy, False);
|
||||
|
@ -123,7 +123,10 @@ struct Client {
|
||||
Window framewin;
|
||||
GC gc;
|
||||
Cursor cursor;
|
||||
Frame *frame;
|
||||
Frame **frame;
|
||||
unsigned int framesz;
|
||||
unsigned int sel;
|
||||
unsigned int nframe;
|
||||
};
|
||||
|
||||
typedef struct Key Key;
|
||||
|
Loading…
x
Reference in New Issue
Block a user