wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 341aebaed4a8446d9e6d79212ccdeefaa66324f0
parent 3215520af376f89458472f28b1bfe514c1aad7f1
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Wed,  1 Feb 2006 23:24:07 +0200

finished wm/fs.c to compile, proceeded with wm/wm.c, now staying in wm/client.c


Diffstat:
cmd/wm/client.c | 96++++++++++++++++++++++++-------------------------------------------------------
cmd/wm/fs.c | 156+++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
cmd/wm/wm.c | 224++++++++++++++++++++++---------------------------------------------------------
cmd/wm/wm.h | 23+++++++++++++----------
cmd/wmiibar.c | 4+++-
5 files changed, 205 insertions(+), 298 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -10,9 +10,6 @@ #include "wm.h" -static void handle_before_read_client(IXPServer * s, File * file); -static void handle_after_write_client(IXPServer * s, File * file); - static void max_client(void *obj, char *arg); /* action table for /?/ namespace */ @@ -27,8 +24,6 @@ alloc_client(Window w, XWindowAttributes *wa) XTextProperty name; Client *c = (Client *) cext_emallocz(sizeof(Client)); XSetWindowAttributes fwa; - static int id = 1; - char buf[MAX_BUF]; int bw, th; long msize; @@ -51,31 +46,6 @@ alloc_client(Window w, XWindowAttributes *wa) free(name.value); } - snprintf(buf, MAX_BUF, "/detached/%d", id); - c->file[C_PREFIX] = ixp_create(ixps, buf); - snprintf(buf, MAX_BUF, "/detached/%d/name", id); - c->file[C_NAME] = ixp_create(ixps, buf); - c->file[C_NAME]->before_read = handle_before_read_client; - snprintf(buf, MAX_BUF, "/detached/%d/border", id); - c->file[C_BORDER] = - wmii_create_ixpfile(ixps, buf, def[WM_BORDER]->content); - c->file[C_BORDER]->after_write = handle_after_write_client; - snprintf(buf, MAX_BUF, "/detached/%d/tab", id); - c->file[C_TAB] = wmii_create_ixpfile(ixps, buf, def[WM_TAB]->content); - c->file[C_TAB]->after_write = handle_after_write_client; - snprintf(buf, MAX_BUF, "/detached/%d/handleinc", id); - c->file[C_HANDLE_INC] = - wmii_create_ixpfile(ixps, buf, def[WM_HANDLE_INC]->content); - c->file[C_HANDLE_INC]->after_write = handle_after_write_client; - snprintf(buf, MAX_BUF, "/detached/%d/geometry", id); - c->file[C_GEOMETRY] = ixp_create(ixps, buf); - c->file[C_GEOMETRY]->before_read = handle_before_read_client; - c->file[C_GEOMETRY]->after_write = handle_after_write_client; - snprintf(buf, MAX_BUF, "/detached/%d/ctl", id); - c->file[C_CTL] = ixp_create(ixps, buf); - c->file[C_CTL]->after_write = handle_after_write_client; - id++; - /* client.frame */ fwa.override_redirect = 1; fwa.background_pixmap = ParentRelative; @@ -114,7 +84,7 @@ set_client_state(Client * c, int state) void focus_client(Client *c) { - Page *p = page ? page[sel_page] : nil; + Page *p = page ? page[sel] : nil; size_t i, j; Client *old = sel_client(); @@ -123,24 +93,15 @@ focus_client(Client *c) focus_page(c->page); p = c->page; } - p->is_area = c->area != nil; - p->file[P_SEL_PREFIX]->content = c->file[P_PREFIX]->content; - if(p->is_area) { - for(i = 0; (i < p->areasz) && p->area[i]; i++) { - Area *col = p->area[i]; - for(j = 0; (j < col->clientsz) && col->client[j] && (c != col->client[j]); j++); - if((j < col->clientsz) && col->client[j]) { - p->sel_area = i; - col->sel = j; - break; - } + for(i = 0; i < p->narea; i++) { + Area *a = p->area[i]; + for(j = 0; j < a->nclient && (c != a->client[j]); j++); + if(j < a->nclient) { + p->sel = i; + a->sel = j; + break; } } - else { - for(i = 0; (i < p->floatingsz) && p->floating[i] && (p->floating[i] != c); i++); - if((i < p->floatingsz) && p->floating[i]) - p->sel_float = i; - } if(old && (old != c)) { ungrab_client(old, AnyModifier, AnyButton); @@ -155,7 +116,7 @@ focus_client(Client *c) XDefineCursor(dpy, c->win, normal_cursor); draw_client(c); XSync(dpy, False); - invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]); + /* TODO: client update */ } void @@ -257,7 +218,7 @@ handle_client_property(Client *c, XPropertyEvent *e) } if(c->attached) draw_client(c); - invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]); + /* TODO: client update */ break; case XA_WM_TRANSIENT_FOR: XGetTransientForHint(dpy, c->win, &c->trans); @@ -276,8 +237,8 @@ destroy_client(Client * c) { XFreeGC(dpy, c->frame.gc); XDestroyWindow(dpy, c->frame.win); - ixp_remove_file(ixps, c->file[C_PREFIX]); - cext_array_detach((void **)detached, c, &detachedsz); + cext_array_detach((void **)det, c, &detsz); + ndet--; free(c); } @@ -291,17 +252,17 @@ draw_client(Client *c) XRectangle notch; d.drawable = c->frame.win; - d.xfont = xfont; + d.font = xfont; d.gc = c->frame.gc; if(c == sel_client()) { - d.bg = blitz_loadcolor(dpy, screen, def[WM_SEL_BG_COLOR]->content); - d.fg = blitz_loadcolor(dpy, screen, def[WM_SEL_FG_COLOR]->content); - d.border = blitz_loadcolor(dpy, screen, def[WM_SEL_BORDER_COLOR]->content); + d.bg = def.selbg; + d.fg = def.selfg; + d.border = def.selborder; } else { - d.bg = blitz_loadcolor(dpy, screen, def[WM_NORM_BG_COLOR]->content); - d.fg = blitz_loadcolor(dpy, screen, def[WM_NORM_FG_COLOR]->content); - d.border = blitz_loadcolor(dpy, screen, def[WM_NORM_BORDER_COLOR]->content); + d.bg = def.normbg; + d.fg = def.normfg; + d.border = def.normborder; } /* draw border */ @@ -399,28 +360,29 @@ attach_client(Client *c) if(!page) p = alloc_page(); else - p = page[sel_page]; + p = page[sel]; reparent_client(c, c->frame.win, c->rect.x, c->rect.y); c->page = p; - wmii_move_ixpfile(c->file[C_PREFIX], p->file[P_CLIENT_PREFIX]); - if(p->is_area) - attach_area(c); - else - p->floating = (Client **)cext_array_attach((void **)p->floating, c, - sizeof(Client *), &p->floatingsz); + if(p->sel) + attach_column(c); + else { + Area *a = p->area[0]; + a->client = (Client **)cext_array_attach((void **)a->client, c, + sizeof(Client *), &a->clientsz); + a->nclient++; + } map_client(c); XMapWindow(dpy, c->frame.win); focus_client(c); - invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]); + /* TODO: page update event */ } void detach_client(Client *c, Bool unmap) { - wmii_move_ixpfile(c->file[C_PREFIX], def[WM_DETACHED_PREFIX]); if(c->area) detach_area(c); else { diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -80,7 +80,9 @@ static char Enofid[] = "fid not assigned"; static char Enofile[] = "file not found"; static char Enomode[] = "mode not supported"; static char Enofunc[] = "function not supported"; +/*static char Enocommand[] = "command not supported";*/ +const char *err; static unsigned char *msg[IXP_MAX_MSG]; char *errstr = 0; static Qid root_qid; @@ -170,7 +172,6 @@ qid_to_name(Qid *qid) static int name_to_type(char *name, unsigned char dtyp) { - const char *err; unsigned int i; if(!name || !name[0] || !strncmp(name, "/", 2) || !strncmp(name, "..", 3)) return Droot; @@ -215,7 +216,6 @@ dyndir: static int mkqid(Qid *dir, char *wname, Qid *new) { - const char *err; unsigned char dtyp = qpath_type(dir->path); unsigned short dpg = qpath_page(dir->path); unsigned short darea = qpath_area(dir->path); @@ -364,7 +364,7 @@ xopen(IXPConn *c) } c->fcall->id = ROPEN; c->fcall->qid = m->qid; - c->fcall->iounit = 256; + c->fcall->iounit = 2048; return 0; } @@ -390,7 +390,6 @@ type_to_stat(Stat *stat, char *name, Qid *dir) unsigned short dpg = qpath_page(dir->path); unsigned short darea = qpath_area(dir->path); unsigned int idx; - const char *err; int type = name_to_type(name, dtyp); char buf[16]; @@ -710,80 +709,119 @@ xwrite(IXPConn *c) { char buf[256]; IXPMap *m = ixp_server_fid2map(c, c->fcall->fid); + unsigned char typ; + unsigned short pg, area, cl; unsigned short i; if(!m) { errstr = Enofid; return -1; } + typ = qpath_type(m->qid.path); + pg = qpath_page(m->qid.path); + area = qpath_area(m->qid.path); + cl = qpath_client(m->qid.path); + if(cl) + cl--; - i = qpath_item(m->qid.path); switch (qpath_type(m->qid.path)) { case Fctl: - if(c->fcall->count == 4) { - memcpy(buf, c->fcall->data, 4); - buf[4] = 0; - if(!strncmp(buf, "quit", 5)) { - srv.running = 0; - break; - } + switch(qpath_type(m->qid.dir->path)) { + case Droot: + /* TODO: /ctl commands */ + break; + case Dpage: + /* /TODO: /n/ctl commands */ + break; + case Darea: + /* /TODO: /n/{float,n}/ctl commands */ + break; + case Dclient: + /* /TODO: /n/{float,n}/n/ctl commands */ + break; + default: + errstr = "command not supported"; + return -1; } - errstr = "command not supported"; - return -1; break; case Ffont: - if(font) - free(font); - font = cext_emallocz(c->fcall->count + 1); - memcpy(font, c->fcall->data, c->fcall->count); - xfont = blitz_getfont(dpy, font); - update_geometry(); + if(def.font) + free(def.font); + def.font = cext_emallocz(c->fcall->count + 1); + memcpy(def.font, c->fcall->data, c->fcall->count); + XFreeFont(dpy, xfont); + xfont = blitz_getfont(dpy, def.font); + /* TODO: update geometry */ break; - case Fexpand: - { - const char *err; - if(c->fcall->count && c->fcall->count < 16) { - memcpy(buf, c->fcall->data, c->fcall->count); - buf[c->fcall->count] = 0; - i = (unsigned short) cext_strtonum(buf, 1, 0xffff, &err); - if(i < nitem) { - iexpand = i; - draw(); - break; - } - } - } - errstr = "item not found"; - return -1; - break; - case Fdata: + case Fselcolor: + if((c->fcall->count != 24) + || (c->fcall->data[0] != '#') || (c->fcall->data[8] != '#') + || (c->fcall->data[16] != '#')) { - unsigned int len = c->fcall->count; - if(i == nitem) - new_item(); - if(!i || (i >= nitem)) - goto error_xwrite; - if(len >= sizeof(item[i]->data)) - len = sizeof(item[i]->data) - 1; - memcpy(item[i]->data, c->fcall->data, len); - item[i]->data[len] = 0; - draw(); + errstr = "wrong color format"; + goto error_xwrite; } + memcpy(def.selcolor, c->fcall->data, c->fcall->count); + def.selcolor[c->fcall->count] = 0; + /* TODO: update color */ break; - case Fcolor: - if(i == nitem) - new_item(); - if((i >= nitem) || (c->fcall->count != 24) + case Fnormcolor: + if((c->fcall->count != 24) || (c->fcall->data[0] != '#') || (c->fcall->data[8] != '#') || (c->fcall->data[16] != '#')) { errstr = "wrong color format"; goto error_xwrite; } - memcpy(item[i]->color, c->fcall->data, c->fcall->count); - item[i]->color[c->fcall->count] = 0; - update_color(item[i]); - draw(); + memcpy(def.normcolor, c->fcall->data, c->fcall->count); + def.normcolor[c->fcall->count] = 0; + /* TODO: update color */ + break; + case Fsnap: + if(c->fcall->count > sizeof(buf)) + goto error_xwrite; + memcpy(buf, c->fcall->data, c->fcall->count); + buf[c->fcall->count] = 0; + i = cext_strtonum(buf, 1, 0xffff, &err); + if(err) { + errstr = "snap value out of range 0..0xffff"; + return -1; + } + def.snap = i; + break; + case Fborder: + if(c->fcall->count > sizeof(buf)) + goto error_xwrite; + memcpy(buf, c->fcall->data, c->fcall->count); + buf[c->fcall->count] = 0; + i = cext_strtonum(buf, 0, 0xffff, &err); + if(err) { + errstr = "border value out of range 0..0xffff"; + return -1; + } + if(qpath_type(m->qid.dir->path) == Ddefault) + def.border = i; + else { + page[pg]->area[area]->client[cl]->frame.border = i; + /* TODO: resize client */ + } + break; + case Ftitle: + if(c->fcall->count > sizeof(buf)) + goto error_xwrite; + memcpy(buf, c->fcall->data, c->fcall->count); + buf[c->fcall->count] = 0; + i = cext_strtonum(buf, 0, 1, &err); + if(err) { + errstr = "title value out of range 0, 1"; + return -1; + } + if(qpath_type(m->qid.dir->path) == Ddefault) + def.border = i; + else { + page[pg]->area[area]->client[cl]->frame.border = i; + /* TODO: resize client */ + } break; default: error_xwrite: @@ -811,7 +849,7 @@ xclunk(IXPConn *c) return 0; } -static void +void close_ixp_conn(IXPServer *s, IXPConn *c) { size_t i; @@ -883,7 +921,7 @@ pending(IXPConn *c, unsigned char id) return nil; } -static void +void do_pend_fcall(char *event) { size_t i; @@ -917,7 +955,7 @@ do_pend_fcall(char *event) } } -static void +void new_ixp_conn(IXPServer *s, IXPConn *c) { IXPConn *new; diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -8,7 +8,8 @@ #include <string.h> #include <sys/stat.h> #include <sys/wait.h> -#include <X11/cursorxfont.h> +#include <unistd.h> +#include <X11/cursorfont.h> #include <X11/Xproto.h> #include <X11/keysym.h> #include <X11/Xatom.h> @@ -23,7 +24,6 @@ static int (*x_error_handler) (Display *, XErrorEvent *); static void new_page(void *obj, char *arg); static void xselect_page(void *obj, char *arg); static void xdestroy_page(void *obj, char *arg); -static void quit(void *obj, char *arg); static void xattach_client(void *obj, char *arg); static void xdetach_client(void *obj, char *arg); static void xclose_client(void *obj, char *arg); @@ -38,7 +38,6 @@ Action wm_acttbl[] = { {"attach", xattach_client}, {"detach", xdetach_client}, {"close", xclose_client}, - {"quit", quit}, {"pager", pager}, {"detclient", detached_client}, {0, 0} @@ -53,50 +52,13 @@ static void usage() { fprintf(stderr, "%s", - "usage: wmiiwm -s <socket file> [-c] [-v]\n" - " -s socket file\n" + "usage: wmiiwm -a <address> [-c] [-v]\n" + " -a address\n" " -c checks if another WM is already running\n" " -v version info\n"); exit(1); } -void -run_action(File * f, void *obj, Action * acttbl) -{ - int i; - size_t len; - - if(!f->content) - return; - for(i = 0; acttbl[i].name; i++) { - len = strlen(acttbl[i].name); - if(!strncmp(acttbl[i].name, (char *) f->content, len)) { - if(f->size > len) - acttbl[i].func(obj, &((char *) f->content)[len + 1]); - else - acttbl[i].func(obj, 0); - return; - break; - } - } - fprintf(stderr, "wmiiwm: unknown action '%s'\n" - " or invalid ctl device\n", (char *) f->content); -} - -static void -quit(void *obj, char *arg) -{ - ixps->runlevel = SHUTDOWN; -} - -void -invoke_wm_event(File * f) -{ - if(!f->content) - return; - wmii_spawn(dpy, f->content); -} - static void scale_rect(XRectangle * from_dim, XRectangle * to_dim, XRectangle * src, XRectangle * tgt) @@ -119,13 +81,13 @@ static void draw_pager_client(Client *c, Draw *d) { if(c == sel_client()) { - d->bg = blitz_loadcolor(dpy, screen, def[WM_SEL_BG_COLOR]->content); - d->fg = blitz_loadcolor(dpy, screen, def[WM_SEL_FG_COLOR]->content); - d->border = blitz_loadcolor(dpy, screen, def[WM_SEL_BORDER_COLOR]->content); + d->bg = def.selbg; + d->fg = def.selfg; + d->border = def.selborder; } else { - d->bg = blitz_loadcolor(dpy, screen, def[WM_NORM_BG_COLOR]->content); - d->fg = blitz_loadcolor(dpy, screen, def[WM_NORM_FG_COLOR]->content); - d->border = blitz_loadcolor(dpy, screen, def[WM_NORM_BORDER_COLOR]->content); + d->bg = def.normbg; + d->fg = def.normfg; + d->border = def.normborder; } d->data = c->name; scale_rect(&rect, &initial_rect, &c->frame.rect, &d->rect); @@ -140,27 +102,25 @@ draw_pager_page(size_t idx, Draw *d) char name[4]; initial_rect = d->rect; - if(idx == sel_page) { - d->bg = blitz_loadcolor(dpy, screen, def[WM_SEL_BG_COLOR]->content); - d->fg = blitz_loadcolor(dpy, screen, def[WM_SEL_FG_COLOR]->content); - d->border = blitz_loadcolor(dpy, screen, def[WM_SEL_BORDER_COLOR]->content); + if(idx == sel) { + d->bg = def.selbg; + d->fg = def.selfg; + d->border = def.selborder; } else { - d->bg = blitz_loadcolor(dpy, screen, def[WM_NORM_BG_COLOR]->content); - d->fg = blitz_loadcolor(dpy, screen, def[WM_NORM_FG_COLOR]->content); - d->border = blitz_loadcolor(dpy, screen, def[WM_NORM_BORDER_COLOR]->content); + d->bg = def.normbg; + d->fg = def.normfg; + d->border = def.normborder; } snprintf(name, sizeof(name), "%d", idx + 1); d->data = name; blitz_drawlabel(dpy, d); XSync(dpy, False); - for(i = 0; (i < page[idx]->areasz) && page[idx]->area[i]; i++) { - Area *col = page[idx]->area[i]; - for(j = 0; (i < col->clientsz) && col->client[j]; j++) - draw_pager_client(col->client[j], d); + for(i = 0; i < page[idx]->narea && page[idx]->area[i]; i++) { + Area *a = page[idx]->area[i]; + for(j = a->nclient - 1; j >= 0; j--) + draw_pager_client(a->client[j], d); } - for(i = 0; (i < page[idx]->floatingsz) && page[idx]->floating[i]; i++) - draw_pager_client(page[idx]->floating[i], d); } static void @@ -177,7 +137,7 @@ draw_pager() th = ((double) tw / rect.width) * rect.height; d.drawable = transient; d.gc = gc_transient; - d.xfont = xfont; + d.font = xfont; i = 0; for(ir = 0; ir < rows; ir++) { for(ic = 0; ic < cols; ic++) { @@ -305,7 +265,7 @@ map_detached_client() int dx, dy; XRectangle cr; - for(i = 0; detached && detached[i]; i++); + for(i = 0; i < ndet; i++); blitz_getbasegeometry(i, &cols, &rows); if(!cols) cols = 1; @@ -319,17 +279,17 @@ map_detached_client() i = 0; for(ir = 0; ir < rows; ir++) { for(ic = 0; ic < cols; ic++) { - if(!detached[i++]) + if(!det[i++]) return; cr.x = ic * tw + (ic * GAP); cr.y = ir * th + (ir * GAP); cr.width = tw; cr.height = th; - XMoveResizeWindow(dpy, detached[i]->win, cr.x, cr.y, cr.width, cr.height); - configure_client(detached[i]); - map_client(detached[i]); - grab_client(detached[i], AnyModifier, Button1); - XRaiseWindow(dpy, detached[i]->win); + XMoveResizeWindow(dpy, det[i]->win, cr.x, cr.y, cr.width, cr.height); + configure_client(det[i]); + map_client(det[i]); + grab_client(det[i], AnyModifier, Button1); + XRaiseWindow(dpy, det[i]->win); XSync(dpy, False); } } @@ -340,11 +300,10 @@ detached_client(void *obj, char *arg) { XEvent ev; int n; - size_t i, nc; + size_t i; Client *c; - for(nc = 0; detached && detached[nc]; nc++); - if(!nc) + if(!ndet) return; XClearWindow(dpy, transient); XMapRaised(dpy, transient); @@ -362,12 +321,13 @@ detached_client(void *obj, char *arg) switch (ev.type) { case KeyPress: XUnmapWindow(dpy, transient); - for(i = 0; detached[i]; i++) - unmap_client(detached[i]); + for(i = 0; i < ndet; i++) + unmap_client(det[i]); if((n = handle_kpress(&ev.xkey)) != -1) { - if(n < nc) { - c = detached[n]; - cext_array_detach((void **)detached, c, &detachedsz); + if(n < ndet) { + c = det[n]; + cext_array_detach((void **)det, c, &detsz); + ndet--; attach_client(c); } } @@ -376,11 +336,12 @@ detached_client(void *obj, char *arg) break; case ButtonPress: XUnmapWindow(dpy, transient); - for(i = 0; detached[i]; i++) - unmap_client(detached[i]); + for(i = 0; i < ndet; i++) + unmap_client(det[i]); if((ev.xbutton.button == Button1) && (c = win_to_client(ev.xbutton.window))) { - cext_array_detach((void **)detached, c, &detachedsz); + cext_array_detach((void **)det, c, &detsz); + ndet--; attach_client(c); } XUngrabKeyboard(dpy, CurrentTime); @@ -401,9 +362,10 @@ xclose_client(void *obj, char *arg) static void xattach_client(void *obj, char *arg) { - Client *c = detached ? detached[0] : nil; + Client *c = ndet ? det[0] : nil; if(c) { - cext_array_detach((void **)detached, c, &detachedsz); + cext_array_detach((void **)det, c, &detsz); + ndet--; attach_client(c); } } @@ -419,10 +381,9 @@ xdetach_client(void *obj, char *arg) static void xselect_page(void *obj, char *arg) { - size_t np, new = sel_page; + size_t new = sel; - for(np = 0; (np < pagesz) && page[np]; np++); - if(!np || !arg) + if(!npage || !arg) return; if(!strncmp(arg, "prev", 5)) { if(new > 0) @@ -434,8 +395,8 @@ xselect_page(void *obj, char *arg) else new = 0; } else { - int idx = blitz_strtonum(arg, 0, np); - if(idx < np) + int idx = blitz_strtonum(arg, 0, npage); + if(idx < npage) new = idx; } focus_page(page[new]); @@ -444,7 +405,7 @@ xselect_page(void *obj, char *arg) static void xdestroy_page(void *obj, char *arg) { - destroy_page(page[sel_page]); + destroy_page(page[sel]); } static void @@ -549,12 +510,8 @@ win_state(Window w) return res; } -void -handle_after_write(IXPServer * s, File * f) -{ - if(f == def[WM_CTL]) - run_action(f, 0, wm_acttbl); - else if(f == def[WM_TRANS_COLOR]) { +/* load color stuff */ +/* unsigned long col[1]; col[0] = color_xor.pixel; XFreeColors(dpy, DefaultColormap(dpy, screen), col, 1, 0); @@ -562,12 +519,7 @@ handle_after_write(IXPServer * s, File * f) def[WM_TRANS_COLOR]->content, &color_xor, &color_xor); XSetForeground(dpy, gc_xor, color_xor.pixel); - } else if(f == def[WM_FONT]) { - XFreeFont(dpy, xfont); - xfont = blitz_getxfont(dpy, def[WM_FONT]->content); - } - check_event(0); -} + */ static void init_atoms() @@ -601,55 +553,15 @@ init_cursors() } static void -init_default() -{ - def[WM_TRANS_COLOR] = - wmii_create_ixpfile(ixps, "/default/transcolor", - BLITZ_SEL_FG_COLOR); - def[WM_TRANS_COLOR]->after_write = handle_after_write; - def[WM_COLUMN_GEOMETRY] = wmii_create_ixpfile(ixps, "/default/geometry", BLITZ_SEL_FG_COLOR); - def[WM_SEL_BG_COLOR] = - wmii_create_ixpfile(ixps, "/default/sstyle/bgcolor", - BLITZ_SEL_BG_COLOR); - def[WM_SEL_FG_COLOR] = - wmii_create_ixpfile(ixps, "/default/sstyle/fgcolor", - BLITZ_SEL_FG_COLOR); - def[WM_SEL_BORDER_COLOR] = - wmii_create_ixpfile(ixps, "/default/sstyle/bordercolor", - BLITZ_SEL_BORDER_COLOR); - def[WM_NORM_BG_COLOR] = - wmii_create_ixpfile(ixps, "/default/nstyle/bgcolor", - BLITZ_NORM_BG_COLOR); - def[WM_NORM_FG_COLOR] = - wmii_create_ixpfile(ixps, "/default/nstyle/fgcolor", - BLITZ_NORM_FG_COLOR); - def[WM_NORM_BORDER_COLOR] = wmii_create_ixpfile(ixps, "/default/nstyle/bordercolor", - BLITZ_NORM_BORDER_COLOR); - def[WM_FONT] = wmii_create_ixpfile(ixps, "/default/xfont", BLITZ_FONT); - def[WM_FONT]->after_write = handle_after_write; - def[WM_SNAP_VALUE] = wmii_create_ixpfile(ixps, "/default/snapvalue", "20"); /* 0..1000 */ - def[WM_BORDER] = wmii_create_ixpfile(ixps, "/default/border", "1"); - def[WM_TAB] = wmii_create_ixpfile(ixps, "/default/tab", "1"); - def[WM_HANDLE_INC] = wmii_create_ixpfile(ixps, "/default/handleinc", "1"); - def[WM_SEL_PAGE] = ixp_create(ixps, "/sel"); - def[WM_EVENT_PAGE_UPDATE] = ixp_create(ixps, "/event/pageupdate"); - def[WM_EVENT_CLIENT_UPDATE] = ixp_create(ixps, "/event/clientupdate"); - def[WM_EVENT_B1PRESS] = ixp_create(ixps, "/default/event/b1press"); - def[WM_EVENT_B2PRESS] = ixp_create(ixps, "/default/event/b2press"); - def[WM_EVENT_B3PRESS] = ixp_create(ixps, "/default/event/b3press"); - def[WM_EVENT_B4PRESS] = ixp_create(ixps, "/default/event/b4press"); - def[WM_EVENT_B5PRESS] = ixp_create(ixps, "/default/event/b5press"); - def[WM_DETACHED_PREFIX] = ixp_create(ixps, "/detached"); -} - -static void init_screen() { XGCValues gcv; XSetWindowAttributes wa; + def.selcolor[7] = 0; XAllocNamedColor(dpy, DefaultColormap(dpy, screen), - def[WM_TRANS_COLOR]->content, &color_xor, &color_xor); + def.selcolor, &color_xor, &color_xor); + def.selcolor[7] = ' '; gcv.subwindow_mode = IncludeInferiors; gcv.function = GXxor; gcv.foreground = color_xor.pixel; @@ -733,7 +645,7 @@ main(int argc, char *argv[]) { int i; int checkwm = 0; - char *sockfile = 0; + char *address= 0; /* command line args */ if(argc > 1) { @@ -748,7 +660,7 @@ main(int argc, char *argv[]) break; case 's': if(i + 1 < argc) - sockfile = argv[++i]; + address = argv[++i]; else usage(); break; @@ -785,34 +697,24 @@ main(int argc, char *argv[]) XSetErrorHandler(0); x_error_handler = XSetErrorHandler(wmii_error_handler); - ixps = wmii_setup_server(sockfile); - init_event_hander(); - if(!(def[WM_CTL] = ixp_create(ixps, "/ctl"))) { - perror("wmiiwm: cannot connect IXP server"); - exit(1); - } - def[WM_CTL]->after_write = handle_after_write; - - aqueuesz = detachedsz = pagesz = clientsz = sel_page = 0; + ndet = npage = nclient = aqsz = detsz = pagesz = clientsz = sel = 0; page = nil; - client = detached = nil; - aqueue = nil; + client = det = nil; + aq = nil; + + def.font = strdup("fixed"); init_atoms(); init_cursors(); - init_default(); - xfont = blitz_getxfont(dpy, def[WM_FONT]->content); + xfont = blitz_getfont(dpy, def.font); wmii_init_lock_modifiers(dpy, &valid_mask, &num_lock_mask); init_screen(); scan_wins(); /* main event loop */ - run_server_with_fd_support(ixps, ConnectionNumber(dpy), check_event, - 0); cleanup(); -/* deinit_server(ixps);*/ XCloseDisplay(dpy); return 0; diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -75,12 +75,14 @@ struct Client { Page **page; size_t npage; size_t pagesz; -size_t sel_page; -Page **aqueue; -size_t aqueuesz; -Client **detached; -size_t detachedsz; +size_t sel; +Page **aq; +size_t aqsz; +Client **det; +size_t ndet; +size_t detsz; Client **client; +size_t nclient; size_t clientsz; Display *dpy; @@ -93,7 +95,7 @@ XFontStruct *xfont; XColor color_xor; GC gc_xor; GC gc_transient; -IXPServer *srv; +IXPServer srv; /* default values */ typedef struct { @@ -163,6 +165,11 @@ unsigned int border_width(Client *c); void init_event_hander(); void check_event(IXPConn *c); +/* fs.c */ +void do_pend_fcall(char *event); +void new_ixp_conn(IXPServer *s, IXPConn *c); +void close_ixp_conn(IXPServer *s, IXPConn *c); + /* mouse.c */ void mouse_resize(Client *c, Align align); void mouse_move(Client *c); @@ -187,10 +194,6 @@ void select_column(Client *c, char *arg); void new_column(Page *p); /* wm.c */ -/* -void invoke_wm_event(File * f); -void run_action(File * f, void *obj, Action * acttbl); -*/ void scan_wins(); Client *win_to_client(Window w); int win_proto(Window w); diff --git a/cmd/wmiibar.c b/cmd/wmiibar.c @@ -62,6 +62,7 @@ static char Enofid[] = "fid not assigned"; static char Enofile[] = "file not found"; static char Enomode[] = "mode not supported"; static char Enofunc[] = "function not supported"; +static char Enocommand[] = "command not supported"; static unsigned char *msg[IXP_MAX_MSG]; char *errstr = 0; @@ -698,7 +699,7 @@ xwrite(IXPConn *c) break; } } - errstr = "command not supported"; + errstr = Enocommand; return -1; break; case Ffont: @@ -706,6 +707,7 @@ xwrite(IXPConn *c) free(font); font = cext_emallocz(c->fcall->count + 1); memcpy(font, c->fcall->data, c->fcall->count); + XFreeFont(dpy, xfont); xfont = blitz_getfont(dpy, font); update_geometry(); break;