mirror of
https://github.com/0intro/wmii
synced 2024-12-17 17:12:57 +03:00
added better color handling to bar2
This commit is contained in:
parent
a18421ee0b
commit
6eb2f9a250
@ -122,6 +122,9 @@ new_item()
|
|||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
item[nitem++] = cext_emallocz(sizeof(Item));
|
item[nitem++] = cext_emallocz(sizeof(Item));
|
||||||
|
if(nitem > 1)
|
||||||
|
cext_strlcpy(item[nitem - 1]->color, item[0]->color,
|
||||||
|
sizeof(item[nitem - 1]->color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -410,7 +413,7 @@ xread(IXPReq *r)
|
|||||||
if(i > nitem)
|
if(i > nitem)
|
||||||
goto error_xread;
|
goto error_xread;
|
||||||
if(!i) {
|
if(!i) {
|
||||||
r->fcall->count = mkstat(&stat, &root_qid, "color", 24, DMREAD | DMWRITE);
|
r->fcall->count = mkstat(&stat, &root_qid, "color", strlen(item[0]->color), DMREAD | DMWRITE);
|
||||||
p = ixp_enc_stat(p, &stat);
|
p = ixp_enc_stat(p, &stat);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -418,7 +421,7 @@ xread(IXPReq *r)
|
|||||||
if(i == nitem)
|
if(i == nitem)
|
||||||
new_item();
|
new_item();
|
||||||
Qid dir = {IXP_QTDIR, 0, mkqpath(Ditem, i)};
|
Qid dir = {IXP_QTDIR, 0, mkqpath(Ditem, i)};
|
||||||
r->fcall->count = mkstat(&stat, &dir, "color", 24, DMREAD | DMWRITE);
|
r->fcall->count = mkstat(&stat, &dir, "color", strlen(item[i]->color), DMREAD | DMWRITE);
|
||||||
p = ixp_enc_stat(p, &stat);
|
p = ixp_enc_stat(p, &stat);
|
||||||
r->fcall->count += mkstat(&stat, &dir, "data", strlen(item[i]->data), DMREAD | DMWRITE);
|
r->fcall->count += mkstat(&stat, &dir, "data", strlen(item[i]->data), DMREAD | DMWRITE);
|
||||||
p = ixp_enc_stat(p, &stat);
|
p = ixp_enc_stat(p, &stat);
|
||||||
@ -486,6 +489,7 @@ xstat(IXPReq *r)
|
|||||||
errstr = "invalid fid";
|
errstr = "invalid fid";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
i = qpath_item(m->qid.path);
|
||||||
dir.version = 0;
|
dir.version = 0;
|
||||||
dir.type = IXP_QTDIR;
|
dir.type = IXP_QTDIR;
|
||||||
dir.path = mkqpath(Ditem, i);
|
dir.path = mkqpath(Ditem, i);
|
||||||
@ -508,10 +512,14 @@ xstat(IXPReq *r)
|
|||||||
mkstat(&r->fcall->stat, &root_qid, qid_to_name(&m->qid), strlen(font), DMREAD | DMWRITE);
|
mkstat(&r->fcall->stat, &root_qid, qid_to_name(&m->qid), strlen(font), DMREAD | DMWRITE);
|
||||||
break;
|
break;
|
||||||
case Fdata:
|
case Fdata:
|
||||||
|
if(i == nitem)
|
||||||
|
i = 0;
|
||||||
mkstat(&r->fcall->stat, &dir, qid_to_name(&m->qid), strlen(item[i]->data), DMREAD | DMWRITE);
|
mkstat(&r->fcall->stat, &dir, qid_to_name(&m->qid), strlen(item[i]->data), DMREAD | DMWRITE);
|
||||||
break;
|
break;
|
||||||
case Fcolor:
|
case Fcolor:
|
||||||
mkstat(&r->fcall->stat, &dir, qid_to_name(&m->qid), 24, DMREAD | DMWRITE);
|
if(i == nitem)
|
||||||
|
i = 0;
|
||||||
|
mkstat(&r->fcall->stat, &dir, qid_to_name(&m->qid), strlen(item[i]->color), DMREAD | DMWRITE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
errstr = "invalid stat request";
|
errstr = "invalid stat request";
|
||||||
@ -569,7 +577,9 @@ xwrite(IXPReq *r)
|
|||||||
case Fcolor:
|
case Fcolor:
|
||||||
if(i == nitem)
|
if(i == nitem)
|
||||||
new_item();
|
new_item();
|
||||||
if((i >= nitem) || (r->fcall->count >= 24))
|
if((i >= nitem) || (r->fcall->count != 24))
|
||||||
|
goto error_xwrite;
|
||||||
|
if(r->fcall->data[0] != '#' || r->fcall->data[8] != '#' || r->fcall->data[16] != '#')
|
||||||
goto error_xwrite;
|
goto error_xwrite;
|
||||||
memcpy(item[i]->color, r->fcall->data, r->fcall->count);
|
memcpy(item[i]->color, r->fcall->data, r->fcall->count);
|
||||||
item[i]->color[r->fcall->count] = 0;
|
item[i]->color[r->fcall->count] = 0;
|
||||||
@ -717,6 +727,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* default item settings */
|
/* default item settings */
|
||||||
new_item();
|
new_item();
|
||||||
|
cext_strlcpy(item[0]->color, "#000000 #ffffff #ffffff", sizeof(item[0]->color));
|
||||||
|
|
||||||
font = strdup("fixed");
|
font = strdup("fixed");
|
||||||
|
|
||||||
|
@ -300,7 +300,5 @@ int ixp_accept_sock(int fd);
|
|||||||
int ixp_create_sock(char *address, char **errstr);
|
int ixp_create_sock(char *address, char **errstr);
|
||||||
|
|
||||||
/* transport.c */
|
/* transport.c */
|
||||||
unsigned int ixp_send_message(int fd, void *msg, unsigned int msize,
|
unsigned int ixp_send_message(int fd, void *msg, unsigned int msize, char **errstr);
|
||||||
char **errstr);
|
unsigned int ixp_recv_message(int fd, void *msg, unsigned int msglen, char **errstr);
|
||||||
unsigned int ixp_recv_message(int fd, void *msg, unsigned int msglen,
|
|
||||||
char **errstr);
|
|
||||||
|
Loading…
Reference in New Issue
Block a user