some more polishing

This commit is contained in:
Anselm R. Garbe 2006-04-13 15:35:10 +02:00
parent 11906f13b2
commit fe500a8cd2
10 changed files with 54 additions and 49 deletions

View File

@ -9,7 +9,7 @@
#include "wm.h"
static Vector *
area2vector(AreaVector *av)
vector_of_areas(AreaVector *av)
{
return (Vector *) av;
}
@ -25,7 +25,7 @@ create_area(View *v)
a->rect.height = rect.height - brect.height;
if(v->area.size > 1)
a->rect.width = rect.width / (v->area.size - 1);
cext_vattach(area2vector(&v->area), a);
cext_vattach(vector_of_areas(&v->area), a);
v->sel = v->area.size -1;
return a;
}
@ -44,7 +44,7 @@ destroy_area(Area *a)
for(i = 0; i < client.size; i++)
if(client.data[i]->revert == a)
client.data[i]->revert = 0;
cext_vdetach(area2vector(&v->area), a);
cext_vdetach(vector_of_areas(&v->area), a);
if(v->sel > 1)
v->sel--;
free(a);

View File

@ -29,7 +29,7 @@ comp_label_name(const void *l1, const void *l2)
}
static Vector *
label2vector(BarVector *lv)
vector_of_bars(BarVector *lv)
{
return (Vector *) lv;
}
@ -48,7 +48,7 @@ create_bar(char *name, Bool intern)
cext_strlcpy(l->name, name, sizeof(l->name));
cext_strlcpy(l->colstr, def.selcolor, sizeof(l->colstr));
l->color = def.sel;
cext_vattach(label2vector(&label), l);
cext_vattach(vector_of_bars(&label), l);
qsort(label.data, label.size, sizeof(Bar *), comp_label_name);
qsort(label.data, label.size, sizeof(Bar *), comp_label_intern);
@ -58,7 +58,7 @@ create_bar(char *name, Bool intern)
void
destroy_bar(Bar *l)
{
cext_vdetach(label2vector(&label), l);
cext_vdetach(vector_of_bars(&label), l);
}
unsigned int

View File

@ -13,7 +13,7 @@
#define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask)
static Vector *
client2vector(ClientVector *cv)
vector_of_clients(ClientVector *cv)
{
return (Vector *) cv;
}
@ -65,7 +65,7 @@ create_client(Window w, XWindowAttributes *wa)
CWOverrideRedirect | CWBackPixmap | CWEventMask, &fwa);
c->gc = XCreateGC(dpy, c->framewin, 0, 0);
XSync(dpy, False);
cext_vattach(client2vector(&client), c);
cext_vattach(vector_of_clients(&client), c);
return c;
}
@ -349,7 +349,7 @@ manage_client(Client *c)
apply_rules(c);
reparent_client(c, c->framewin, c->rect.x, c->rect.y);
update_views(c);
update_views();
}
static int
@ -379,8 +379,8 @@ destroy_client(Client *c)
reparent_client(c, root, c->rect.x, c->rect.y);
XFreeGC(dpy, c->gc);
XDestroyWindow(dpy, c->framewin);
cext_vdetach(client2vector(&client), c);
update_views(nil);
cext_vdetach(vector_of_clients(&client), c);
update_views();
free(c);
XSync(dpy, False);
@ -654,3 +654,14 @@ client_of_win(Window w)
return client.data[i];
return nil;
}
void
draw_clients()
{
unsigned int i, j;
for(i = 0; i < client.size; i++)
for(j = 0; j < client.data[i]->frame.size; j++)
if(client.data[i]->frame.data[j]->area->view == view.data[sel])
draw_client(client.data[i]);
}

View File

@ -8,7 +8,7 @@
#include "wm.h"
static Vector *
frame2vector(FrameVector *fv)
vector_of_frames(FrameVector *fv)
{
return (Vector *) fv;
}
@ -25,9 +25,9 @@ create_frame(Area *a, Client *c)
f->rect = c->rect;
f->rect.width += 2 * def.border;
f->rect.height += def.border + height_of_bar();
cext_vattach(frame2vector(&c->frame), f);
cext_vattach(vector_of_frames(&c->frame), f);
c->sel = c->frame.size - 1;
cext_vattach(frame2vector(&a->frame),f);
cext_vattach(vector_of_frames(&a->frame),f);
a->sel = a->frame.size - 1;
return f;
@ -39,8 +39,8 @@ destroy_frame(Frame *f)
Client *c = f->client;
Area *a = f->area;
cext_vdetach(frame2vector(&c->frame), f);
cext_vdetach(frame2vector(&a->frame), f);
cext_vdetach(vector_of_frames(&c->frame), f);
cext_vdetach(vector_of_frames(&a->frame), f);
free(f);
if(c->sel > 0)
c->sel--;

View File

@ -571,7 +571,7 @@ xattach(IXPConn *c, Fcall *fcall)
IXPMap *new = cext_emallocz(sizeof(IXPMap));
new->qid = root_qid;
new->fid = fcall->fid;
cext_vattach(ixp_map2vector(&c->map), new);
cext_vattach(ixp_vector_of_maps(&c->map), new);
fcall->id = RATTACH;
fcall->qid = root_qid;
ixp_server_respond_fcall(c, fcall);
@ -603,7 +603,7 @@ xwalk(IXPConn *c, Fcall *fcall)
if(nwqid == fcall->nwname) {
if(fcall->fid != fcall->newfid) {
m = cext_emallocz(sizeof(IXPMap));
cext_vattach(ixp_map2vector(&c->map), m);
cext_vattach(ixp_vector_of_maps(&c->map), m);
}
m->qid = dir;
m->fid = fcall->newfid;
@ -674,7 +674,7 @@ xremove(IXPConn *c, Fcall *fcall)
if(type != FsDbar)
return Enoperm;
/* clunk */
cext_vdetach(ixp_map2vector(&c->map), m);
cext_vdetach(ixp_vector_of_maps(&c->map), m);
free(m);
switch(type) {
case FsDbar:
@ -1131,16 +1131,6 @@ xstat(IXPConn *c, Fcall *fcall)
return nil;
}
static void
draw_clients()
{
unsigned int i, j;
for(i = 0; i < client.size; i++)
for(j = 0; j < client.data[i]->frame.size; j++)
if(client.data[i]->frame.data[j]->area->view == view.data[sel])
draw_client(client.data[i]);
}
static char *
xwrite(IXPConn *c, Fcall *fcall)
{
@ -1377,7 +1367,7 @@ xclunk(IXPConn *c, Fcall *fcall)
update_keys();
else if(type == FsFrules)
update_rules();
cext_vdetach(ixp_map2vector(&c->map), m);
cext_vdetach(ixp_vector_of_maps(&c->map), m);
free(m);
fcall->id = RCLUNK;
ixp_server_respond_fcall(c, fcall);

View File

@ -33,7 +33,7 @@ VECTOR(RuleVector, Rule *);
static RuleVector rule;
static Vector *
rule2vector(RuleVector *rv)
vector_of_rules(RuleVector *rv)
{
return (Vector *) rv;
}
@ -72,7 +72,7 @@ update_rules()
Rule *r = rule.data[0];
if(r->is_valid)
regfree(&r->regex);
cext_vdetach(rule2vector(&rule), r);
cext_vdetach(vector_of_rules(&rule), r);
free(r);
}
@ -106,7 +106,7 @@ update_rules()
Rule *rul = cext_emallocz(sizeof(Rule));
rul->is_valid = !regcomp(&rul->regex, regex, 0);
cext_strlcpy(rul->tags, tags, sizeof(rul->tags));
cext_vattach(rule2vector(&rule), rul);
cext_vattach(vector_of_rules(&rule), rul);
}
else
fprintf(stderr, "wmiiwm: ignoring rule with tags '%s', restricted tag name\n",

View File

@ -9,7 +9,7 @@
#include "wm.h"
static Vector *
view2vector(ViewVector *vv)
vector_of_views(ViewVector *vv)
{
return (Vector *) vv;
}
@ -25,7 +25,7 @@ create_view(char *name)
create_area(v);
create_area(v);
sel = view.size;
cext_vattach(view2vector(&view), v);
cext_vattach(vector_of_views(&view), v);
return v;
}
@ -36,7 +36,7 @@ destroy_view(View *v)
while(v->area.size)
destroy_area(v->area.data[0]);
cext_vdetach(view2vector(&view), v);
cext_vdetach(vector_of_views(&view), v);
if(sel >= view.size)
sel = 0;
@ -304,12 +304,12 @@ update_client_views(Client *c)
n = cext_tokenize(toks, 16, buf, '+');
while(c->view.size)
cext_vdetach(view2vector(&c->view), c->view.data[0]);
cext_vdetach(vector_of_views(&c->view), c->view.data[0]);
for(i = 0; i < n; i++) {
if(!strncmp(toks[i], "*", 2))
continue;
cext_vattach(view2vector(&c->view), get_view(toks[i]));
cext_vattach(vector_of_views(&c->view), get_view(toks[i]));
}
}
@ -364,10 +364,13 @@ update_views()
destroy_view(v);
}
if(old)
focus_view(old);
else if(view.size)
if(view.size && view.data[sel] != old) {
focus_view(view.data[sel]);
else
update_view_bars();
return;
}
else if(old) {
focus_client(sel_client_of_view(old));
draw_clients();
}
update_view_bars();
}

View File

@ -227,6 +227,7 @@ void swap_client(Client *c, char *arg);
Client *sel_client();
int idx_of_client_id(unsigned short id);
Client *client_of_win(Window w);
void draw_clients();
/* column.c */
void arrange_column(Area *a, Bool dirty);

View File

@ -245,7 +245,7 @@ unsigned int ixp_server_receive_fcall(IXPConn *c, Fcall *fcall);
int ixp_server_respond_fcall(IXPConn *c, Fcall *fcall);
int ixp_server_respond_error(IXPConn *c, Fcall *fcall, char *errstr);
void ixp_server_close(IXPServer *s);
Vector *ixp_map2vector(MapVector *mv);
Vector *ixp_vector_of_maps(MapVector *mv);
/* socket.c */
int ixp_connect_sock(char *address);

View File

@ -19,13 +19,13 @@
static unsigned char *msg[IXP_MAX_MSG];
static Vector *
conn2vector(ConnVector *cv)
vector_of_conns(ConnVector *cv)
{
return (Vector *) cv;
}
Vector *
ixp_map2vector(MapVector *mv)
ixp_vector_of_maps(MapVector *mv)
{
return (Vector *) mv;
}
@ -38,7 +38,7 @@ IXPConn *ixp_server_open_conn(IXPServer *s, int fd, void (*read)(IXPConn *c),
c->srv = s;
c->read = read;
c->close = close;
cext_vattach(conn2vector(&s->conn), c);
cext_vattach(vector_of_conns(&s->conn), c);
return c;
}
@ -46,10 +46,10 @@ void
ixp_server_close_conn(IXPConn *c)
{
IXPServer *s = c->srv;
cext_vdetach(conn2vector(&s->conn), c);
cext_vdetach(vector_of_conns(&s->conn), c);
while(c->map.size) {
IXPMap *m = c->map.data[0];
cext_vdetach(ixp_map2vector(&c->map), m);
cext_vdetach(ixp_vector_of_maps(&c->map), m);
free(m);
}
shutdown(c->fd, SHUT_RDWR);