commit ee53f73922686b03b0e740b404dba4e730077768
parent 1ea6fb3118eb77fef503585433cb0d7aad6c2355
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Mon, 6 Feb 2006 10:20:23 +0200
fixed handle_confreq issues, fixed fs-related issues, improved wmiir on dir reading
Diffstat:
| cmd/wm/event.c | | | 29 | +++++++++-------------------- |
| cmd/wm/fs.c | | | 86 | +++++++++++++++++++++++++++++++++++++++++++------------------------------------ |
| cmd/wmiir.c | | | 23 | +++++++++++++++++++++-- |
3 files changed, 77 insertions(+), 61 deletions(-)
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -62,7 +62,10 @@ handle_buttonpress(XEvent * e)
static char buf[32];
if((c = win_to_frame(ev->window))) {
if(ev->button == Button1) {
- focus_client(c);
+ if(sel_client() != c) {
+ focus_client(c);
+ return;
+ }
align = cursor_to_align(c->frame.cursor);
if(align == CENTER)
mouse_move(c);
@@ -99,7 +102,7 @@ handle_buttonpress(XEvent * e)
}
static void
-handle_configurerequest(XEvent * e)
+handle_configurerequest(XEvent *e)
{
XConfigureRequestEvent *ev = &e->xconfigurerequest;
XWindowChanges wc;
@@ -107,19 +110,14 @@ handle_configurerequest(XEvent * e)
unsigned int bw = 0, bh = 0;
c = win_to_client(ev->window);
- ev->value_mask &= ~CWSibling;
if(c) {
+
if(c->page) {
bw = c->frame.border;
bh = bar_height(c);
}
- if(ev->value_mask & CWStackMode) {
- if(wc.stack_mode == Above)
- XRaiseWindow(dpy, c->win);
- else
- ev->value_mask &= ~CWStackMode;
- }
+
gravitate(c, bh ? bh : bw, bw, 1);
if(ev->value_mask & CWX)
@@ -141,30 +139,21 @@ handle_configurerequest(XEvent * e)
c->frame.rect.width = wc.width = c->rect.width + 2 * bw;
c->frame.rect.height = wc.height = c->rect.height + bw + (bh ? bh : bw);
wc.border_width = 1;
- wc.sibling = None;
- wc.stack_mode = ev->detail;
XConfigureWindow(dpy, c->frame.win, ev->value_mask, &wc);
configure_client(c);
}
}
+
wc.x = ev->x;
wc.y = ev->y;
-
if(c && c->page) {
/* if so, then bw and tabh are already initialized */
wc.x = bw;
- wc.y = bh ? bh : bw;
+ wc.y = (bh ? bh : bw);
}
wc.width = ev->width;
- if(!wc.width)
- wc.width = 1; /* borken app fix */
wc.height = ev->height;
- if(!wc.height)
- wc.height = 1; /* borken app fix */
wc.border_width = 0;
- wc.sibling = None;
- wc.stack_mode = Above;
- ev->value_mask &= ~CWStackMode;
ev->value_mask |= CWBorderWidth;
XConfigureWindow(dpy, e->xconfigurerequest.window, ev->value_mask, &wc);
XSync(dpy, False);
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -125,9 +125,7 @@ qid_to_name(Qid *qid)
case Dpage:
if(pg == sel)
return "sel";
- if(pg == npage)
- return "new";
- snprintf(buf, sizeof(buf), "%u", pg);
+ snprintf(buf, sizeof(buf), "%u", pg + 1);
return buf;
break;
case Darea:
@@ -137,17 +135,15 @@ qid_to_name(Qid *qid)
else
return "sel";
}
- if(page[pg]->narea == area)
- return "new";
if(page[pg]->sel == area)
return "sel";
- snprintf(buf, sizeof(buf), "%u", area);
+ snprintf(buf, sizeof(buf), "%u", area + 1);
return buf;
break;
case Dclient:
if(page[pg]->area[area]->sel == cl)
return "sel";
- snprintf(buf, sizeof(buf), "%u", cl);
+ snprintf(buf, sizeof(buf), "%u", cl + 1);
return buf;
break;
case Fctl: return "ctl"; break;
@@ -203,7 +199,7 @@ name_to_type(char *name, unsigned char dtyp)
return Fgeom;
if(!strncmp(name, "sel", 4))
goto dyndir;
- i = (unsigned short) cext_strtonum(name, 0, 0xffff, &err);
+ i = (unsigned short) cext_strtonum(name, 1, 0xffff, &err);
if(err)
return -1;
dyndir:
@@ -217,7 +213,7 @@ dyndir:
}
static int
-mkqid(Qid *dir, char *wname, Qid *new)
+mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
{
unsigned char dtyp = qpath_type(dir->path);
unsigned short dpgid = qpath_pgid(dir->path);
@@ -248,18 +244,25 @@ mkqid(Qid *dir, char *wname, Qid *new)
break;
case Dpage:
new->type = IXP_QTDIR;
- if(!strncmp(wname, "new", 4))
- new->path = mkqpath(Dpage, NEW_OBJ, 0, 0);
+ if(!strncmp(wname, "new", 4)) {
+ if(iswalk) {
+ Page *p = alloc_page();
+ new->path = mkqpath(Dpage, p->id, 0, 0);
+ focus_page(p);
+ }
+ else
+ new->path = mkqpath(Dpage, 0, 0, 0);
+ }
else if(!strncmp(wname, "sel", 4)) {
if(!npage)
return -1;
new->path = mkqpath(Dpage, page[sel]->id, 0, 0);
}
else {
- i = cext_strtonum(wname, 0, 0xffff, &err);
- if(err || (i >= npage))
+ i = cext_strtonum(wname, 1, 0xffff, &err);
+ if(err || (i - 1 >= npage))
return -1;
- new->path = mkqpath(Dpage, page[i]->id, 0, 0);
+ new->path = mkqpath(Dpage, page[i - 1]->id, 0, 0);
}
break;
case Darea:
@@ -267,8 +270,17 @@ mkqid(Qid *dir, char *wname, Qid *new)
if(!npage || dpg >= npage)
return -1;
new->type = IXP_QTDIR;
- if(!strncmp(wname, "new", 4))
- new->path = mkqpath(Darea, dpgid, NEW_OBJ, 0);
+ if(!strncmp(wname, "new", 4)) {
+ if(iswalk) {
+ Area *a = alloc_area();
+ Page *p = page[dpg];
+ p->area = (Area **)cext_array_attach((void **)p->area, a, sizeof(Area *), &p->areasz);
+ p->narea++;
+ new->path = mkqpath(Darea, dpgid, a->id, 0);
+ }
+ else
+ new->path = mkqpath(Darea, dpgid, 0, 0);
+ }
else if(!strncmp(wname, "sel", 4)) {
Page *p = page[dpg];
if(!p->narea)
@@ -276,10 +288,10 @@ mkqid(Qid *dir, char *wname, Qid *new)
new->path = mkqpath(Darea, dpgid, p->area[p->sel]->id, 0);
}
else {
- i = cext_strtonum(wname, 0, 0xffff, &err);
- if(err || (i >= page[dpg]->narea))
+ i = cext_strtonum(wname, 1, 0xffff, &err);
+ if(err || (i - 1 >= page[dpg]->narea))
return -1;
- new->path = mkqpath(Darea, dpgid, page[dpg]->area[i]->id, 0);
+ new->path = mkqpath(Darea, dpgid, page[dpg]->area[i - 1]->id, 0);
}
break;
case Dclient:
@@ -294,10 +306,10 @@ mkqid(Qid *dir, char *wname, Qid *new)
}
else {
Area *a = page[dpg]->area[darea];
- i = cext_strtonum(wname, 0, 0xffff, &err);
- if(err || (i >= page[dpg]->area[darea]->nclient))
+ i = cext_strtonum(wname, 1, 0xffff, &err);
+ if(err || (i - 1 >= page[dpg]->area[darea]->nclient))
return -1;
- new->path = mkqpath(Dclient, dpgid, daid, a->client[i]->id);
+ new->path = mkqpath(Dclient, dpgid, daid, a->client[i - 1]->id);
}
break;
default:
@@ -348,7 +360,7 @@ xwalk(IXPConn *c, Fcall *fcall)
if(fcall->nwname) {
dir = m->qid;
for(nwqid = 0; (nwqid < fcall->nwname)
- && !mkqid(&dir, fcall->wname[nwqid], &fcall->wqid[nwqid]); nwqid++)
+ && !mkqid(&dir, fcall->wname[nwqid], &fcall->wqid[nwqid], True); nwqid++)
{
fprintf(stderr, "dir.dtype=%d\n", dir.dtype);
dir = fcall->wqid[nwqid];
@@ -403,7 +415,7 @@ mkstat(Stat *stat, Qid *dir, char *name, unsigned long long length, unsigned int
cext_strlcpy(stat->name, name, sizeof(stat->name));
stat->length = length;
- mkqid(dir, name, &stat->qid);
+ mkqid(dir, name, &stat->qid, False);
return ixp_sizeof_stat(stat);
}
@@ -530,7 +542,7 @@ xread(IXPConn *c, Fcall *fcall)
if(i == sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i + 1);
len += type_to_stat(&stat, buf, &m->qid);
if(len <= fcall->offset)
continue;
@@ -541,7 +553,7 @@ xread(IXPConn *c, Fcall *fcall)
if(i == sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
@@ -557,7 +569,7 @@ xread(IXPConn *c, Fcall *fcall)
if(i == page[pg]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i + 1);
len += type_to_stat(&stat, buf, &m->qid);
if(len <= fcall->offset)
continue;
@@ -568,7 +580,7 @@ xread(IXPConn *c, Fcall *fcall)
if(i == page[pg]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
@@ -583,7 +595,7 @@ xread(IXPConn *c, Fcall *fcall)
if(i == page[pg]->area[area]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i + 1);
len += type_to_stat(&stat, buf, &m->qid);
if(len <= fcall->offset)
continue;
@@ -594,7 +606,7 @@ xread(IXPConn *c, Fcall *fcall)
if(i == page[pg]->area[area]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
@@ -626,7 +638,7 @@ xread(IXPConn *c, Fcall *fcall)
if(i == sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
@@ -651,20 +663,16 @@ xread(IXPConn *c, Fcall *fcall)
p = ixp_enc_stat(p, &stat);
break;
case Dpage:
- if(pg == npage) {
- Page *page = alloc_page();
- m->qid.path = mkqpath(Dpage, page->id, 0, 0);
- focus_page(page);
- }
+ fprintf(stderr, "XXXXXXXXXX p->narea=%d\n", page[pg]->narea);
fcall->count = type_to_stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "new", &m->qid);
p = ixp_enc_stat(p, &stat);
for(i = 0; i < page[pg]->narea; i++) {
- if(i == page[pg]->area[area]->sel)
+ if(i == page[pg]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
@@ -679,7 +687,7 @@ xread(IXPConn *c, Fcall *fcall)
if(i == page[pg]->area[area]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
diff --git a/cmd/wmiir.c b/cmd/wmiir.c
@@ -124,6 +124,9 @@ xread(char *file)
unsigned int fid = c.root_fid << 2;
int count, is_directory = 0;
static unsigned char result[IXP_MAX_MSG];
+ void *dircontent = nil;
+ size_t dircontentsz = 0;
+ size_t ndircontent = 0;
unsigned long long offset = 0;
/* open */
@@ -135,8 +138,22 @@ xread(char *file)
/* read */
while((count = ixp_client_read(&c, fid, offset, result, IXP_MAX_MSG)) > 0) {
- if(is_directory)
- xls(result, count);
+ if(is_directory) {
+ if(ndircontent + count > dircontentsz) {
+ void *tmp = dircontent;
+ if(!dircontentsz)
+ dircontentsz = IXP_MAX_MSG;
+ else
+ dircontentsz *= 2;
+ dircontent = cext_emallocz(dircontentsz);
+ if(tmp) {
+ memcpy(dircontent, tmp, ndircontent);
+ free(tmp);
+ }
+ }
+ memcpy(dircontent + ndircontent, result, count);
+ ndircontent += count;
+ }
else {
unsigned int i;
for(i = 0; i < count; i++)
@@ -149,6 +166,8 @@ xread(char *file)
fprintf(stderr, "wmiir: cannot read file/directory '%s': %s\n", file, c.errstr);
return -1;
}
+ if(is_directory)
+ xls(dircontent, ndircontent);
return ixp_client_close(&c, fid);
}