fixed a routing bug in qpath_decode

This commit is contained in:
Anselm R. Garbe 2006-02-16 11:53:10 +01:00
parent 25731066d2
commit 068caf1da1
7 changed files with 33 additions and 50 deletions

View File

@ -95,7 +95,7 @@ client_name_event(Client *c)
{
char buf[256];
snprintf(buf, sizeof(buf), "CN %s\n", c->name);
broadcast_event(buf);
write_event(buf);
}
static void
@ -104,7 +104,7 @@ 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);
broadcast_event(buf);
write_event(buf);
}
void
@ -237,7 +237,8 @@ handle_client_property(Client *c, XPropertyEvent *e)
}
if(c->area)
draw_client(c);
client_name_event(c);
if(c == sel_client())
client_name_event(c);
break;
case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(dpy, c->win, &c->trans);

View File

@ -69,7 +69,7 @@ handle_buttonpress(XEvent *e)
for(i = 0; i < nlabel; i++)
if(blitz_ispointinrect(ev->x, ev->y, &label[i]->rect)) {
snprintf(buf, sizeof(buf), "LB %d %d\n", i + 1, ev->button);
broadcast_event(buf);
write_event(buf);
}
}
else if((c = win_to_frame(ev->window))) {
@ -87,7 +87,7 @@ handle_buttonpress(XEvent *e)
if(c && c->area) {
snprintf(buf, sizeof(buf), "CB %d %d\n", client_to_index(c) + 1, ev->button);
broadcast_event(buf);
write_event(buf);
}
}
else if((c = win_to_client(ev->window))) {
@ -114,7 +114,7 @@ handle_buttonpress(XEvent *e)
if(c && c->area) {
snprintf(buf, sizeof(buf), "CB %d %d\n", client_to_index(c) + 1, ev->button);
broadcast_event(buf);
write_event(buf);
}
}

View File

@ -129,12 +129,11 @@ decode_qpath(Qid *qid, unsigned char *type, int *i1, int *i2, int *i3)
if(i1id) {
switch(*type) {
case Fctl:
case Dpage: *i1 = pid_to_index(i1id); break;
case Fkey: *i1 = kid_to_index(i1id); break;
case Fdata:
case Fcolors:
case Dlabel: *i1 = lid_to_index(i1id); break;
default: *i1 = pid_to_index(i1id); break;
}
if(i2id && (*i1 != -1)) {
*i2 = aid_to_index(page[*i1], i2id);
@ -349,14 +348,14 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
if(!strncmp(wname, "new", 4)) {
if(iswalk) {
Area *a = alloc_area(p);
fprintf(stderr, "p->id %d, a->id %d\n", p->id, a->id);
new->path = mkqpath(Darea, p->id, a->id, 0);
}
else
new->path = mkqpath(Darea, p->id, 0, 0); /* simple stat */
}
else if(!strncmp(wname, "sel", 4))
else if(!strncmp(wname, "sel", 4)) {
new->path = mkqpath(Darea, p->id, p->area[p->sel]->id, 0);
}
else {
i = cext_strtonum(wname, 1, 0xffff, &err);
if(err || (i - 1 >= p->narea))
@ -443,7 +442,6 @@ xwalk(IXPConn *c, Fcall *fcall)
/*fprintf(stderr, "wm: xwalk1: fid=%d\n", fcall->fid);*/
if(fcall->fid != fcall->newfid && (ixp_server_fid2map(c, fcall->newfid)))
return Enofid;
/*fprintf(stderr, "wm: xwalk2: fid=%d\n", fcall->fid);*/
if(fcall->nwname) {
dir = m->qid;
for(nwqid = 0; (nwqid < fcall->nwname)
@ -452,13 +450,13 @@ xwalk(IXPConn *c, Fcall *fcall)
dir = fcall->wqid[nwqid];
}
if(!nwqid) {
/*fprintf(stderr, "%s", "xwalk: no such file\n");*/
fprintf(stderr, "%s", "xwalk: no such file\n");
return Enofile;
}
}
/*fprintf(stderr, "wm: xwalk3: fid=%d\n", fcall->fid);*/
/* a fid will only be valid, if the walk was complete */
if(nwqid == fcall->nwname) {
/*fprintf(stderr, "wm: xwalk4: newfid=%d\n", fcall->newfid);*/
if(fcall->fid != fcall->newfid) {
m = cext_emallocz(sizeof(IXPMap));
c->map = (IXPMap **)cext_array_attach((void **)c->map, m,
@ -708,14 +706,12 @@ xread(IXPConn *c, Fcall *fcall)
len = 0;
for(i = 0; i < nkey; i++) {
len += type_to_stat(&stat, key[i]->name, &m->qid);
fprintf(stderr, "len=%d <= fcall->offset=%lld\n", len, fcall->offset);
if(len <= fcall->offset)
continue;
break;
}
/* offset found, proceeding */
for(; i < nkey; i++) {
fprintf(stderr, "offset xread %s\n", key[i]->name);
len = type_to_stat(&stat, key[i]->name, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
@ -809,7 +805,6 @@ xread(IXPConn *c, Fcall *fcall)
else {
switch (type) {
case Droot:
/*fprintf(stderr, "%s", "Droot dir creation\n");*/
fcall->count = type_to_stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "event", &m->qid);
@ -836,7 +831,6 @@ xread(IXPConn *c, Fcall *fcall)
break;
case Dkeys:
for(i = 0; i < nkey; i++) {
fprintf(stderr, "normal xread %s\n", key[i]->name);
len = type_to_stat(&stat, key[i]->name, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
@ -916,19 +910,14 @@ xread(IXPConn *c, Fcall *fcall)
break;
case Dclient:
fcall->count = type_to_stat(&stat, "border", &m->qid);
/*fprintf(stderr, "msgl=%d\n", fcall->count);*/
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "bar", &m->qid);
/*fprintf(stderr, "msgl=%d\n", fcall->count);*/
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "name", &m->qid);
/*fprintf(stderr, "msgl=%d\n", fcall->count);*/
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "geometry", &m->qid);
/*fprintf(stderr, "msgl=%d\n", fcall->count);*/
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "ctl", &m->qid);
/*fprintf(stderr, "msgl=%d\n", fcall->count);*/
p = ixp_enc_stat(p, &stat);
break;
case Fctl:
@ -1181,7 +1170,6 @@ xwrite(IXPConn *c, Fcall *fcall)
}
break;
case Fcolors:
fprintf(stderr, "Fcolors len=%d i1=%d nlabel=%d\n", fcall->count, i1, nlabel);
if((i1 >= nlabel) || (fcall->count != 23)
|| (fcall->data[0] != '#') || (fcall->data[8] != '#')
|| (fcall->data[16] != '#')
@ -1193,7 +1181,6 @@ xwrite(IXPConn *c, Fcall *fcall)
draw_bar();
break;
case Fselcolors:
fprintf(stderr, "Fselcolors len=%d\n", fcall->count);
if((fcall->count != 23)
|| (fcall->data[0] != '#') || (fcall->data[8] != '#')
|| (fcall->data[16] != '#')
@ -1207,7 +1194,6 @@ xwrite(IXPConn *c, Fcall *fcall)
draw_client(client[i]);
break;
case Fnormcolors:
fprintf(stderr, "Fnormcolors len=%d\n", fcall->count);
if((fcall->count != 23)
|| (fcall->data[0] != '#') || (fcall->data[8] != '#')
|| (fcall->data[16] != '#')
@ -1267,7 +1253,7 @@ do_fcall(IXPConn *c)
char *errstr;
if((msize = ixp_server_receive_fcall(c, &fcall))) {
/*fprintf(stderr, "do_fcall=%d\n", fcall.id);*/
/*fprintf(stderr, "do_fcall=%d\n", fcall.id);*/
switch(fcall.id) {
case TVERSION: errstr = xversion(c, &fcall); break;
case TATTACH: errstr = xattach(c, &fcall); break;
@ -1288,10 +1274,9 @@ do_fcall(IXPConn *c)
}
void
broadcast_event(char *event)
write_event(char *event)
{
size_t i;
fprintf(stderr, "broadcasting: %s", event);
for(i = 0; (i < srv.connsz) && srv.conn[i]; i++) {
IXPConn *c = srv.conn[i];
if(c->is_pending) {

View File

@ -208,7 +208,7 @@ handle_key_seq(Window w, Key **done, size_t ndone)
case 1:
if(!found[0]->next) {
snprintf(buf, sizeof(buf), "K %s\n", found[0]->name);
broadcast_event(buf);
write_event(buf);
break;
}
default:
@ -232,7 +232,7 @@ handle_key(Window w, unsigned long mod, KeyCode keycode)
case 1:
if(!found[0]->next) {
snprintf(buf, sizeof(buf), "K %s\n", found[0]->name);
broadcast_event(buf);
write_event(buf);
break;
}
default:

View File

@ -30,13 +30,11 @@ void
destroy_page(Page *p)
{
unsigned int i;
Page *new = p->revert;
for(i = 0; i < p->narea; i++)
destroy_area(p->area[i]);
free(p->area);
if((sel + 1 == npage) && (sel - 1 >= 0))
sel--;
cext_array_detach((void **)page, p, &pagesz);
npage--;
@ -48,10 +46,10 @@ destroy_page(Page *p)
}
free(p);
if(npage)
focus_page(page[sel]);
else
broadcast_event("PN -\n");
if(npage && new)
focus_page(new);
else
write_event("PN -\n");
}
int
@ -72,14 +70,11 @@ focus_page(Page *p)
Client *c;
int i = page_to_index(p);
if(!npage || (i == -1)) {
fprintf(stderr, "returning from focus_page %d %d\n", npage, i);
if(!npage || (i == -1))
return;
return;
}
if(sel == i)
return;
page[i]->revert = page[sel];
if(old && old != p)
p->revert = old;
sel = i;
for(i = 0; i < nclient; i++) {
c = client[i];
@ -93,7 +88,7 @@ focus_page(Page *p)
if((c = sel_client_of_page(p)))
focus_client(c, False);
snprintf(buf, sizeof(buf), "PN %d\n", sel + 1);
broadcast_event(buf);
write_event(buf);
XChangeProperty(dpy, root, net_atoms[NET_CURRENT_DESKTOP], XA_CARDINAL,
32, PropModeReplace, (unsigned char *) &sel, 1);
XSync(dpy, False);

View File

@ -235,7 +235,7 @@ void check_x_event(IXPConn *c);
/* fs.c */
unsigned long long mkqpath(unsigned char type, unsigned short pg,
unsigned short area, unsigned short cl);
void broadcast_event(char *event);
void write_event(char *event);
void new_ixp_conn(IXPConn *c);
/* kb.c */

View File

@ -109,11 +109,13 @@ while(event=`{read}) {
if(~ $event(1) PN)
xwrite /bar/1/data $event(2)
if(~ $event(1) CN) {
text=`{echo $"event | sed 's/^CN //g'}
xwrite /bar/2/data $"text
buf=`{echo $"event | sed 's/^CN //g'}
xwrite /bar/2/data $"buf
}
if(~ $event(1) CF) {
buf=`{echo $event(2) $event(3) | awk '{printf("warp %d %d", $1+4, $2+4)}'}
xwrite /ctl $"buf
}
if(~ $event(1) CF)
xwrite /ctl 'warp '^$event(2)^' '^$event(3)
if(~ $event(1) LB) { # label button press
switch($event(3)) { # button
case 1