commit 5d13828aa0ce6c1e1848ecae7908a64ad28a984e
parent c332804b5b1eea5290346ab8a4cb1fcc2c3f0496
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Thu, 2 Feb 2006 14:20:07 +0200
made wm to compile, now the polishing begins
Diffstat:
10 files changed, 241 insertions(+), 283 deletions(-)
diff --git a/cmd/wm/Makefile b/cmd/wm/Makefile
@@ -5,8 +5,8 @@ include ../../config.mk
CFLAGS += -I../../liblitz -I../../libixp -I../../libwmii \
-I../../libcext
-LDFLAGS += -L../../liblitz -llitz -L../../libixp -lixp \
- -L../../libwmii -lwmii -L../../libcext -lcext
+LDFLAGS += -L../../liblitz -llitz -L../../libwmii -lwmii \
+ -L../../libixp -lixp -L../../libcext -lcext
# Solaris
# LDFLAGS += -lsocket
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -24,7 +24,7 @@ alloc_client(Window w, XWindowAttributes *wa)
XTextProperty name;
Client *c = (Client *) cext_emallocz(sizeof(Client));
XSetWindowAttributes fwa;
- int bw, th;
+ int bw = def.border, th;
long msize;
/* client itself */
@@ -51,7 +51,7 @@ alloc_client(Window w, XWindowAttributes *wa)
fwa.background_pixmap = ParentRelative;
fwa.event_mask = SubstructureRedirectMask | ExposureMask | ButtonPressMask | PointerMotionMask;
- bw = border_width(c);
+ c->frame.border = bw;
th = tab_height(c);
c->frame.rect = c->rect;
c->frame.rect.width += 2 * bw;
@@ -248,7 +248,7 @@ draw_client(Client *c)
{
Draw d = { 0 };
unsigned int tabh = tab_height(c);
- int bw = border_width(c);
+ unsigned int bw = c->frame.border;
XRectangle notch;
d.drawable = c->frame.win;
@@ -383,14 +383,17 @@ attach_client(Client *c)
void
detach_client(Client *c, Bool unmap)
{
- if(c->area)
+ if(index_of_area(c->page, c->area) > 0)
detach_column(c);
else {
- cext_array_detach((void **)c->page->floating, c, &c->page->floatingsz);
+ Area *a = c->page->area[0];
+ cext_array_detach((void **)a->client, c, &a->clientsz);
+ a->nclient--;
if(!c->destroyed) {
if(!unmap) {
- detached = (Client **)cext_array_attach((void **)detached, c,
- sizeof(Client *), &detachedsz);
+ det = (Client **)cext_array_attach((void **)det, c,
+ sizeof(Client *), &detsz);
+ ndet++;
unmap_client(c);
}
c->rect.x = c->frame.rect.x;
@@ -401,19 +404,15 @@ detach_client(Client *c, Bool unmap)
c->page = nil;
if(c->destroyed)
destroy_client(c);
- focus_page(page[sel_page]);
+ focus_page(page[sel]);
}
Client *
sel_client_of_page(Page *p)
{
if(p) {
- if(p->is_area) {
- Area *col = p->area[p->sel_area];
- return (col && col->client) ? col->client[col->sel] : nil;
- }
- else
- return p->floating ? p->floating[p->sel_float] : nil;
+ Area *a = p->narea ? p->area[p->sel] : nil;
+ return (a && a->nclient) ? a->client[a->sel] : nil;
}
return nil;
}
@@ -421,7 +420,7 @@ sel_client_of_page(Page *p)
Client *
sel_client()
{
- return page ? sel_client_of_page(page[sel_page]) : nil;
+ return npage ? sel_client_of_page(page[sel]) : nil;
}
Client *
@@ -437,19 +436,11 @@ win_to_frame(Window w)
unsigned int
tab_height(Client * c)
{
- if(blitz_strtonum(c->file[C_TAB]->content, 0, 1))
+ if(c->frame.title)
return xfont->ascent + xfont->descent + 4;
return 0;
}
-unsigned int
-border_width(Client * c)
-{
- if(blitz_strtonum(c->file[C_BORDER]->content, 0, 1))
- return BORDER_WIDTH;
- return 0;
-}
-
static void
check_dimensions(Client *c, unsigned int tabh, unsigned int bw)
{
@@ -494,17 +485,16 @@ void
resize_client(Client *c, XRectangle *r, XPoint *pt)
{
unsigned int tabh = tab_height(c);
- unsigned int bw = border_width(c);
+ unsigned int bw = c->frame.border;
- if(c->area)
- resize_area(c, r, pt);
+ if(index_of_area(c->page, c->area) > 0)
+ resize_column(c, r, pt);
/* resize if client requests special size */
check_dimensions(c, tabh, bw);
- if(c->file[C_HANDLE_INC]->content
- && ((char *) c->file[C_HANDLE_INC]->content)[0] == '1')
- resize_incremental(c, tabh, bw);
+ if(c->inc)
+ resize_incremental(c, tabh, bw);
XMoveResizeWindow(dpy, c->frame.win, c->frame.rect.x, c->frame.rect.y,
c->frame.rect.width, c->frame.rect.height);
@@ -518,62 +508,6 @@ resize_client(Client *c, XRectangle *r, XPoint *pt)
}
static void
-handle_before_read_client(IXPServer * s, File *file)
-{
- size_t i;
- char buf[32];
-
- for(i = 0; (i < clientsz) && client[i]; i++) {
- Client *c = client[i];
- if(file == c->file[C_GEOMETRY]) {
- snprintf(buf, sizeof(buf), "%d %d %d %d", c->frame.rect.x, c->frame.rect.y,
- c->frame.rect.width, c->frame.rect.height);
- if(file->content)
- free(file->content);
- file->content = cext_estrdup(buf);
- file->size = strlen(buf);
- return;
- }
- else if(file == c->file[C_NAME]) {
- if(file->content)
- free(file->content);
- file->content = cext_estrdup(c->name);
- file->size = strlen(c->name);
- return ;
- }
- }
-}
-
-static void
-handle_after_write_client(IXPServer *s, File *file)
-{
- size_t i;
-
- for(i = 0; (i < clientsz) && client[i]; i++) {
- Client *c = client[i];
- if(file == c->file[C_CTL]) {
- run_action(file, c, client_acttbl);
- return;
- }
- else if(file == c->file[C_TAB] || file == c->file[C_BORDER]
- || file == c->file[C_HANDLE_INC])
- {
- resize_client(c, &c->frame.rect, nil);
- return;
- }
- else if(file == c->file[C_GEOMETRY]) {
- char *geom = c->file[C_GEOMETRY]->content;
- if(geom && strrchr(geom, ' ')) {
- XRectangle frect = c->frame.rect;
- blitz_strtorect(&rect, &frect, geom);
- resize_client(c, &frect, 0);
- }
- return;
- }
- }
-}
-
-static void
max_client(void *obj, char *arg)
{
Client *c = obj;
@@ -584,7 +518,7 @@ max_client(void *obj, char *arg)
}
else {
c->frame.revert = c->frame.rect;
- c->frame.rect = c->area ? c->area->rect : rect;
+ c->frame.rect = c->area->rect;
XRaiseWindow(dpy, c->frame.win);
resize_client(c, &c->frame.rect, nil);
}
diff --git a/cmd/wm/column.c b/cmd/wm/column.c
@@ -9,7 +9,7 @@
#include "wm.h"
void
-arrange_column(Page *p, Column *col)
+arrange_column(Page *p, Area *col)
{
size_t i;
unsigned int h;
@@ -21,12 +21,12 @@ arrange_column(Page *p, Column *col)
for(i = 0; (i < col->clientsz) && col->client[i]; i++) {
Client *c = col->client[i];
c->frame.rect = col->rect;
- c->frame.rect.y = p->rect_column.y + i * h;
+ c->frame.rect.y += i * h;
if((i + 1 < col->clientsz) && col->client[i + 1])
c->frame.rect.height = h;
else
c->frame.rect.height =
- p->rect_column.height - c->frame.rect.y + p->rect_column.y;
+ col->rect.height - c->frame.rect.y + col->rect.y;
resize_client(c, &c->frame.rect, 0);
}
}
@@ -35,25 +35,26 @@ void
arrange_page(Page *p)
{
size_t i;
- for(i = 0; (i < p->columnsz) && p->column[i]; i++)
- arrange_column(p, p->column[i]);
+ for(i = 1; i < p->narea; i++)
+ arrange_column(p, p->area[i]);
}
void
attach_column(Client *c)
{
- Page *p = page[sel_page];
- Column *col = p->columnsz ? p->column[p->sel_column] : nil;
+ Page *p = page[sel];
+ Area *col = p->narea && (p->sel > 0) ? p->area[p->sel] : nil;
if(!col) {
- col = cext_emallocz(sizeof(Column));
- col->rect = p->rect_column;
- p->column = (Column **)cext_array_attach((void **)p->column, col,
- sizeof(Column *), &p->columnsz);
- p->sel_column = 0;
+ col = cext_emallocz(sizeof(Area));
+ col->rect = rect;
+ p->area = (Area **)cext_array_attach((void **)p->area, col,
+ sizeof(Area *), &p->areasz);
+ p->sel = p->narea;
+ p->narea++;
}
- c->column = col;
+ c->area = col;
col->client = (Client **)cext_array_attach((void **)col->client, c,
sizeof(Client *), &col->clientsz);
arrange_column(p, col);
@@ -65,15 +66,14 @@ update_column_width(Page *p)
size_t i;
unsigned int width;
- for(i = 0; (i < p->columnsz) && p->column[i]; i++);
- if(!i)
+ if(p->narea == 1)
return;
- width = p->rect_column.width / i;
- for(i = 0; (i < p->columnsz) && p->column[i]; i++) {
- p->column[i]->rect = p->rect_column;
- p->column[i]->rect.x = i * width;
- p->column[i]->rect.width = width;
+ width = rect.width / (p->narea - 1);
+ for(i = 1; i < p->narea; i++) {
+ p->area[i]->rect = rect;
+ p->area[i]->rect.x = i * width;
+ p->area[i]->rect.width = width;
}
arrange_page(p);
}
@@ -82,11 +82,12 @@ void
detach_column(Client *c)
{
Page *p = c->page;
- Column *col = c->column;
+ Area *col = c->area;
cext_array_detach((void **)col->client, c, &col->clientsz);
if(!col->client[0]) {
- cext_array_detach((void **)p->column, col, &p->columnsz);
+ cext_array_detach((void **)p->area, col, &p->areasz);
+ p->narea--;
free(col);
update_column_width(p);
}
@@ -95,7 +96,7 @@ detach_column(Client *c)
}
static void
-match_horiz(Column *col, XRectangle *r)
+match_horiz(Area *col, XRectangle *r)
{
size_t i;
@@ -111,13 +112,13 @@ static void
drop_resize(Client *c, XRectangle *new)
{
Page *p = c->page;
- Column *west = nil, *east = nil, *col = c->column;
+ Area *west = nil, *east = nil, *col = c->area;
Client *north = nil, *south = nil;
size_t i;
- for(i = 0; (i < p->columnsz) && p->column[i] && (p->column[i] != col); i++);
- west = i ? p->column[i - 1] : nil;
- east = (i < p->columnsz) && p->column[i + 1] ? p->column[i + 1] : nil;
+ for(i = 0; (i < p->narea) && (p->area[i] != col); i++);
+ west = i ? p->area[i - 1] : nil;
+ east = (i < p->areasz) && p->area[i + 1] ? p->area[i + 1] : nil;
for(i = 0; (i < col->clientsz) && col->client[i] && (col->client[i] != c); i++);
north = i ? col->client[i - 1] : nil;
@@ -162,15 +163,15 @@ static void
drop_moving(Client *c, XRectangle *new, XPoint * pt)
{
Page *p = c->page;
- Column *tgt = nil, *src = c->column;
+ Area *tgt = nil, *src = c->area;
size_t i;
if(!pt)
return;
- for(i = 0; (i < p->columnsz) && p->column[i] &&
- !blitz_ispointinrect(pt->x, pt->y, &p->column[i]->rect); i++);
- tgt = (i < p->columnsz) ? p->column[i] : nil;
+ for(i = 0; (i < p->areasz) && p->area[i] &&
+ !blitz_ispointinrect(pt->x, pt->y, &p->area[i]->rect); i++);
+ tgt = (i < p->areasz) ? p->area[i] : nil;
if(tgt) {
if(tgt != src) {
if(src->clientsz <= 1 || !src->client[1])
@@ -209,7 +210,7 @@ void
select_column(Client *c, char *arg)
{
Page *p = c->page;
- Column *col = c->column;
+ Area *col = c->area;
size_t i;
for(i = 0; (i < col->clientsz) && col->client[i] && (col->client[i] != c); i++);
@@ -226,23 +227,23 @@ select_column(Client *c, char *arg)
return;
}
- for(i = 0; (i < p->columnsz) && p->column[i] && (p->column[i] != col); i++);
+ for(i = 0; (i < p->areasz) && p->area[i] && (p->area[i] != col); i++);
if(!strncmp(arg, "west", 5)) {
if(!i)
- for(i = 0; (i < p->columnsz) && p->column[i]; i++);
- col = p->column[i - 1];
+ for(i = 0; (i < p->areasz) && p->area[i]; i++);
+ col = p->area[i - 1];
} else if(!strncmp(arg, "east", 5)) {
- if(p->column[i + 1])
- col = p->column[i + 1];
+ if(p->area[i + 1])
+ col = p->area[i + 1];
else
- col = p->column[0];
+ col = p->area[0];
} else {
const char *errstr;
- for(i = 0; (i < p->columnsz) && p->column[i]; i++);
+ for(i = 0; (i < p->areasz) && p->area[i]; i++);
i = cext_strtonum(arg, 0, i - 1, &errstr);
if(errstr)
return;
- col = p->column[i];
+ col = p->area[i];
}
focus_client(col->client[col->sel]);
}
@@ -251,26 +252,21 @@ void
new_column(Page *p)
{
Client *c = sel_client_of_page(p);
- Column *col, *old = c ? c->column : nil;
- size_t i;
-
- if(!old)
- return;
-
- for(i = 0; (i < old->clientsz) && old->client[i]; i++);
+ Area *col, *old = c ? c->area : nil;
- if(i < 2)
+ if(!old || old->nclient < 2)
return;
- col = cext_emallocz(sizeof(Column));
- col->rect = p->rect_column;
- p->column = (Column **)cext_array_attach((void **)p->column, col,
- sizeof(Column *), &p->columnsz);
- p->sel_column = i;
+ col = cext_emallocz(sizeof(Area));
+ col->rect = rect;
+ p->area = (Area **)cext_array_attach((void **)p->area, col,
+ sizeof(Area *), &p->areasz);
+ p->sel = p->narea;
+ p->narea++;
cext_array_detach((void **)old->client, c, &old->clientsz);
col->client = (Client **)cext_array_attach((void **)col->client, c,
sizeof(Client *), &col->clientsz);
- c->column = col;
+ c->area = col;
update_column_width(p);
focus_client(c);
}
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -43,7 +43,7 @@ init_event_hander()
}
void
-check_event(Connection * c)
+check_x_event(IXPServer *s, IXPConn *c)
{
XEvent ev;
while(XPending(dpy)) { /* main evet loop */
@@ -59,7 +59,7 @@ handle_buttonpress(XEvent * e)
Client *c;
XButtonPressedEvent *ev = &e->xbutton;
Align align;
- int bindex;
+ static char buf[32];
if((c = win_to_frame(ev->window))) {
focus_client(c);
@@ -71,10 +71,8 @@ handle_buttonpress(XEvent * e)
mouse_resize(c, align);
return;
}
- bindex = WM_EVENT_B2PRESS - 2 + ev->button;
- /* frame mouse handling */
- if(def[bindex]->content)
- wmii_spawn(dpy, def[bindex]->content);
+ snprintf(buf, sizeof(buf), "Button%dPress\n", ev->button);
+ do_pend_fcall(buf);
}
else if((c = win_to_client(ev->window))) {
focus_client(c);
@@ -113,7 +111,7 @@ handle_configurerequest(XEvent * e)
if(c) {
if(c->attached) {
- bw = border_width(c);
+ bw = c->frame.border;
tabh = tab_height(c);
}
if(ev->value_mask & CWStackMode) {
@@ -210,9 +208,9 @@ handle_maprequest(XEvent * e)
}
/* attach heuristic support */
- if(aqueuesz && aqueue[0]) {
+ if(aqsz && aq[0]) {
focus_page(0);
- cext_array_detach((void **)aqueue, aqueue[0], &aqueuesz);
+ cext_array_detach((void **)aq, aq[0], &aqsz);
}
/* there're client which send map requests twice */
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -28,8 +28,9 @@
* /default/selcolor Fselcolor <#RRGGBB> <#RRGGBB> <#RRGGBB>
* /default/normcolor Fnormcolor <#RRGGBB> <#RRGGBB> <#RRGGBB>
* /default/border Fborder 0..n
- * /default/title Fbool 0, 1
+ * /default/title Ftitle 0, 1
* /default/snap Fsnap 0..n
+ * /default/inc Finc 0..n
* /event Fevent
* /ctl Fctl command interface (root)
* /new/ Dpage returns new page
@@ -44,7 +45,9 @@
* /1/float/1/ Dclient
* /1/float/1/border Fborder 0..n
* /1/float/1/title Ftitle 0, 1
+ * /1/float/1/inc Finc 0, 1
* /1/float/1/name Fname name of client
+ * /1/float/1/geom Fgeom geometry of client
* /1/float/1/ctl Fctl command interface (client)
* /1/1/ Darea
* /1/1/ctl Fctl command interface (area)
@@ -52,7 +55,9 @@
* /1/1/1/1/ Dclient
* /1/1/1/border Fborder 0..n
* /1/1/1/title Ftitle 0, 1
+ * /1/1/1/inc Finc 0, 1
* /1/1/1/name Fname name of client
+ * /1/1/1/geom Fgeom geometry of client
* /1/1/1/ctl Fctl command interface (client)
*/
@@ -69,6 +74,8 @@ enum {
Fborder,
Fsnap,
Ftitle,
+ Finc,
+ Fgeom,
Fevent,
Fctl,
Fname
@@ -163,6 +170,8 @@ qid_to_name(Qid *qid)
case Fborder: return "border"; break;
case Fsnap: return "border"; break;
case Ftitle: return "title"; break;
+ case Finc: return "inc"; break;
+ case Fgeom: return "geometry"; break;
case Fname: return "name"; break;
case Fevent: return "event"; break;
default: return nil; break;
@@ -187,9 +196,9 @@ name_to_type(char *name, unsigned char dtyp)
return Ffont;
if(!strncmp(name, "event", 6))
return Fevent;
- if(!strncmp(name, "selcolor", 6))
+ if(!strncmp(name, "selcolor", 9))
return Fselcolor;
- if(!strncmp(name, "normcolor", 6))
+ if(!strncmp(name, "normcolor", 10))
return Fnormcolor;
if(!strncmp(name, "snap", 5))
return Fsnap;
@@ -199,7 +208,11 @@ name_to_type(char *name, unsigned char dtyp)
return Fborder;
if(!strncmp(name, "title", 6))
return Ftitle;
- if(!strncmp(name, "sel", 6))
+ if(!strncmp(name, "inc", 4))
+ return Finc;
+ if(!strncmp(name, "geometry", 9))
+ return Fgeom;
+ if(!strncmp(name, "sel", 4))
goto dyndir;
i = (unsigned short) cext_strtonum(name, 1, 0xffff, &err);
if(err)
@@ -391,7 +404,8 @@ type_to_stat(Stat *stat, char *name, Qid *dir)
unsigned short darea = qpath_area(dir->path);
unsigned int idx;
int type = name_to_type(name, dtyp);
- char buf[16];
+ char buf[32];
+ Client *c;
switch (type) {
case Droot:
@@ -438,6 +452,26 @@ type_to_stat(Stat *stat, char *name, Qid *dir)
}
return mkstat(stat, dir, name, strlen(buf), DMREAD | DMWRITE);
break;
+ case Finc:
+ if(dtyp == Ddefault)
+ snprintf(buf, sizeof(buf), "%d", def.inc);
+ else {
+ idx = cext_strtonum(name, 1, 0xffff, &err);
+ if(err)
+ return 0;
+ snprintf(buf, sizeof(buf), "%d", page[dpg]->area[darea]->client[idx]->inc);
+ }
+ return mkstat(stat, dir, name, strlen(buf), DMREAD | DMWRITE);
+ break;
+ case Fgeom:
+ idx = cext_strtonum(name, 1, 0xffff, &err);
+ if(err)
+ return 0;
+ c = page[dpg]->area[darea]->client[idx];
+ snprintf(buf, sizeof(buf), "%d %d %d %d", c->frame.rect.x, c->frame.rect.y,
+ c->frame.rect.width, c->frame.rect.height);
+ return mkstat(stat, dir, name, strlen(buf), DMREAD | DMWRITE);
+ break;
case Fsnap:
snprintf(buf, sizeof(buf), "%d", def.snap);
return mkstat(stat, dir, name, strlen(buf), DMREAD | DMWRITE);
@@ -461,6 +495,7 @@ xread(IXPConn *c)
unsigned short pg, area, cl;
unsigned int i, len;
char buf[32];
+ Client *client;
if(!m) {
errstr = Enofid;
@@ -584,6 +619,8 @@ xread(IXPConn *c)
p = ixp_enc_stat(p, &stat);
c->fcall->count += type_to_stat(&stat, "title", &m->qid);
p = ixp_enc_stat(p, &stat);
+ c->fcall->count += type_to_stat(&stat, "inc", &m->qid);
+ p = ixp_enc_stat(p, &stat);
c->fcall->count += type_to_stat(&stat, "snap", &m->qid);
p = ixp_enc_stat(p, &stat);
break;
@@ -626,8 +663,12 @@ xread(IXPConn *c)
p = ixp_enc_stat(p, &stat);
c->fcall->count += type_to_stat(&stat, "title", &m->qid);
p = ixp_enc_stat(p, &stat);
+ c->fcall->count += type_to_stat(&stat, "inc", &m->qid);
+ p = ixp_enc_stat(p, &stat);
c->fcall->count += type_to_stat(&stat, "name", &m->qid);
p = ixp_enc_stat(p, &stat);
+ c->fcall->count += type_to_stat(&stat, "geometry", &m->qid);
+ p = ixp_enc_stat(p, &stat);
c->fcall->count += type_to_stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
break;
@@ -666,6 +707,21 @@ xread(IXPConn *c)
c->fcall->count = strlen(buf);
memcpy(p, buf, c->fcall->count);
break;
+ case Finc:
+ if(qpath_type(m->qid.dir->path) == Ddefault)
+ snprintf(buf, sizeof(buf), "%u", def.inc);
+ else
+ snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->inc);
+ c->fcall->count = strlen(buf);
+ memcpy(p, buf, c->fcall->count);
+ break;
+ case Fgeom:
+ client = page[pg]->area[area]->client[cl];
+ snprintf(buf, sizeof(buf), "%d %d %d %d", client->frame.rect.x, client->frame.rect.y,
+ client->frame.rect.width, client->frame.rect.height);
+ c->fcall->count = strlen(buf);
+ memcpy(p, buf, c->fcall->count);
+ break;
case Fsnap:
snprintf(buf, sizeof(buf), "%u", def.snap);
c->fcall->count = strlen(buf);
@@ -823,6 +879,31 @@ xwrite(IXPConn *c)
/* TODO: resize client */
}
break;
+ case Finc:
+ 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 = "increment value out of range 0, 1";
+ return -1;
+ }
+ if(qpath_type(m->qid.dir->path) == Ddefault)
+ def.inc = i;
+ else {
+ page[pg]->area[area]->client[cl]->inc = i;
+ /* TODO: resize client */
+ }
+ break;
+ case Fgeom:
+ if(c->fcall->count > sizeof(buf))
+ goto error_xwrite;
+ memcpy(buf, c->fcall->data, c->fcall->count);
+ buf[c->fcall->count] = 0;
+ blitz_strtorect(&rect, &page[pg]->area[area]->client[cl]->frame.rect, buf);
+ /* TODO: resize client */
+ break;
default:
error_xwrite:
if(!errstr)
diff --git a/cmd/wm/mouse.c b/cmd/wm/mouse.c
@@ -4,6 +4,7 @@
*/
#include <stdlib.h>
+#include <unistd.h>
#include "wm.h"
@@ -13,7 +14,7 @@ cursor_for_motion(Client *c, int x, int y)
int n, e, w, s, tn, te, tw, ts;
int tabh, bw;
- bw = border_width(c);
+ bw = c->frame.border;
tabh = tab_height(c);
if(!bw)
@@ -302,12 +303,8 @@ mouse_move(Client *c)
Window dummy;
XEvent ev;
/* borders */
- int snapw =
- rect.width * blitz_strtonum(def[WM_SNAP_VALUE]->content, 0,
- 1000) / 1000;
- int snaph =
- rect.height * blitz_strtonum(def[WM_SNAP_VALUE]->content, 0,
- 1000) / 1000;
+ int snapw = rect.width * def.snap / 1000;
+ int snaph = rect.height * def.snap / 1000;
unsigned int num;
unsigned int dmask;
XRectangle *rects = rectangles(&num);
@@ -551,12 +548,8 @@ mouse_resize(Client *c, Align align)
Window dummy;
XEvent ev;
/* borders */
- int snapw =
- rect.width * blitz_strtonum(def[WM_SNAP_VALUE]->content, 0,
- 1000) / 1000;
- int snaph =
- rect.height * blitz_strtonum(def[WM_SNAP_VALUE]->content, 0,
- 1000) / 1000;
+ int snapw = rect.width * def.snap / 1000;
+ int snaph = rect.height * def.snap / 1000;
unsigned int dmask;
unsigned int num;
XRectangle *rects = rectangles(&num);
diff --git a/cmd/wm/page.c b/cmd/wm/page.c
@@ -10,20 +10,16 @@
#include "wm.h"
-static void handle_after_write_page(IXPServer * s, File * file);
-
static void select_client(void *obj, char *arg);
-static void toggle_layout(void *obj, char *arg);
static void xexec(void *obj, char *arg);
static void swap_client(void *obj, char *arg);
-static void xnew_area(void *obj, char *arg);
+static void xnew_column(void *obj, char *arg);
/* action table for /?/ namespace */
Action page_acttbl[] = {
- {"toggle", toggle_layout},
{"exec", xexec},
{"swap", swap_client},
- {"newcol", xnew_area},
+ {"newcol", xnew_column},
{"select", select_client},
{0, 0}
};
@@ -32,33 +28,16 @@ Page *
alloc_page()
{
Page *p = cext_emallocz(sizeof(Page));
- char buf[MAX_BUF], buf2[16];
- static int id = 1;
- size_t np;
+ Area *a = cext_emallocz(sizeof(Area));
- snprintf(buf2, sizeof(buf2), "%d", id);
- snprintf(buf, sizeof(buf), "/%d", id);
- p->file[P_PREFIX] = ixp_create(ixps, buf);
- snprintf(buf, sizeof(buf), "/%d/name", id);
- p->file[P_NAME] = wmii_create_ixpfile(ixps, buf, buf2);
- snprintf(buf, sizeof(buf), "/%d/client", id);
- p->file[P_CLIENT_PREFIX] = ixp_create(ixps, buf);
- snprintf(buf, sizeof(buf), "/%d/client/sel", id);
- p->file[P_SEL_PREFIX] = ixp_create(ixps, buf);
- p->file[P_SEL_PREFIX]->bind = 1; /* mount point */
- snprintf(buf, sizeof(buf), "/%d/ctl", id);
- p->file[P_CTL] = ixp_create(ixps, buf);
- p->file[P_CTL]->after_write = handle_after_write_page;
- def[WM_SEL_PAGE]->content = p->file[P_PREFIX]->content;
- invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
- id++;
- p->rect_area = rect;
+ p->area = (Area **)cext_array_attach((void **)p->area, a, sizeof(Area *), &p->areasz);
+ p->narea++;
+ do_pend_fcall("NewPage\n");
page = (Page **)cext_array_attach((void **)page, p, sizeof(Page *), &pagesz);
- for(np = 0; (np < pagesz) && page[np]; np++);
+ npage++;
focus_page(p);
XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
- 32, PropModeReplace, (unsigned char *) &np, 1);
- p->is_area = True;
+ 32, PropModeReplace, (unsigned char *) &npage, 1);
return p;
}
@@ -68,34 +47,31 @@ destroy_page(Page *p)
unsigned int i;
size_t naqueue = 0;
- for(i = 0; (i < aqueuesz) && aqueue[i]; i++)
- if(aqueue[i] == p)
+ for(i = 0; (i < aqsz) && aq[i]; i++)
+ if(aq[i] == p)
naqueue++;
for(i = 0; i < naqueue; i++)
- cext_array_detach((void **)aqueue, p, &aqueuesz);
+ cext_array_detach((void **)aq, p, &aqsz);
- for(i = 0; (i < clientsz) && client[i]; i++)
+ for(i = 0; i < nclient; i++)
if(client[i]->page == p)
detach_client(client[i], False);
- for(i = 0; (i < pagesz) && page[i] && (p != page[i]); i++);
- if(sel_page && (sel_page == i))
- sel_page--;
-
- def[WM_SEL_PAGE]->content = 0;
- ixp_remove_file(ixps, p->file[P_PREFIX]);
+ for(i = 0; (i < npage) && (p != page[i]); i++);
+ if(sel && (sel == i))
+ sel--;
free(p);
+ npage--;
- for(i = 0; (i < pagesz) && page[i]; i++);
+ for(i = 0; i < npage; i++);
XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
32, PropModeReplace, (unsigned char *) &i, 1);
/* determine what to focus and do that */
- if(page[sel_page])
- focus_page(page[sel_page]);
+ if(page[sel])
+ focus_page(page[sel]);
else {
- invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]);
- invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
+ do_pend_fcall("NoPage\n");
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
}
}
@@ -104,27 +80,26 @@ void
focus_page(Page *p)
{
size_t i;
- Page *old = page ? page[sel_page] : nil;
+ Page *old = page ? page[sel] : nil;
if(!page)
return;
- for(i = 0; (i < pagesz) && page[i] && (page[i] != p); i++);
- if(i == sel_page)
+ for(i = 0; (i < npage) && (page[i] != p); i++);
+ if(i == sel)
return;
- sel_page = i;
- for(i = 0; (i < clientsz) && client[i]; i++) {
+ sel = i;
+ for(i = 0; i < nclient; i++) {
Client *c = client[i];
if(old && (c->page == old))
XMoveWindow(dpy, c->frame.win, 2 * rect.width, 2 * rect.height);
else if(c->page == p)
XMoveWindow(dpy, c->frame.win, c->frame.rect.x, c->frame.rect.y);
}
- def[WM_SEL_PAGE]->content = p->file[P_PREFIX]->content;
- invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
+ do_pend_fcall("SelPage\n");
XChangeProperty(dpy, root, net_atoms[NET_CURRENT_DESKTOP], XA_CARDINAL,
- 32, PropModeReplace, (unsigned char *) &sel_page, 1);
+ 32, PropModeReplace, (unsigned char *) &sel, 1);
}
XRectangle *
@@ -159,42 +134,14 @@ rectangles(unsigned int *num)
}
static void
-handle_after_write_page(IXPServer *s, File *file)
-{
- size_t i;
-
- for(i = 0; (i < pagesz) && page[i]; i++) {
- if(file == page[i]->file[P_CTL]) {
- run_action(file, page[i], page_acttbl);
- return;
- }
- }
-}
-
-static void
xexec(void *obj, char *arg)
{
- aqueue = (Page **)cext_array_attach((void **)aqueue, obj,
- sizeof(Page *), &aqueuesz);
+ aq = (Page **)cext_array_attach((void **)aq, obj,
+ sizeof(Page *), &aqsz);
wmii_spawn(dpy, arg);
}
static void
-toggle_layout(void *obj, char *arg)
-{
- Page *p = obj;
-
- p->is_area = !p->is_area;
- if(p->is_area) {
- Area *col = p->area[p->sel_area];
- if(col && col->clientsz && col->client[col->sel])
- focus_client(col->client[col->sel]);
- }
- else if(p->floating && p->floatingsz && p->floating[p->sel_float])
- focus_client(p->floating[p->sel_float]);
-}
-
-static void
swap_client(void *obj, char *arg)
{
Page *p = obj;
@@ -206,45 +153,45 @@ swap_client(void *obj, char *arg)
if(!col || !arg)
return;
- for(i = 0; (i < p->areasz) && p->area[i] && (p->area[i] != col); i++);
+ for(i = 1; i < p->narea && (p->area[i] != col); i++);
west = i ? p->area[i - 1] : nil;
east = (i < p->areasz) && p->area[i + 1] ? p->area[i + 1] : nil;
- for(i = 0; (i < col->clientsz) && col->client[i] && (col->client[i] != c); i++);
+ for(i = 0; (i < col->nclient) && (col->client[i] != c); i++);
north = i ? col->client[i - 1] : nil;
- south = (i < col->clientsz) && col->client[i + 1] ? col->client[i + 1] : nil;
+ south = (i + 1 < col->nclient) ? col->client[i + 1] : nil;
if(!strncmp(arg, "north", 6) && north) {
col->client[i] = col->client[i - 1];
col->client[i - 1] = c;
- arrange_area(p, col);
+ arrange_column(p, col);
} else if(!strncmp(arg, "south", 6) && south) {
col->client[i] = col->client[i + 1];
col->client[i + 1] = c;
- arrange_area(p, col);
+ arrange_column(p, col);
}
else if(!strncmp(arg, "west", 5) && west) {
col->client[i] = west->client[west->sel];
- col->client[i]->area = col;
west->client[west->sel] = c;
west->client[west->sel]->area = west;
- arrange_area(p, col);
- arrange_area(p, west);
+ col->client[i]->area = col;
+ arrange_column(p, col);
+ arrange_column(p, west);
} else if(!strncmp(arg, "east", 5) && east) {
col->client[i] = west->client[west->sel];
col->client[i]->area = col;
east->client[east->sel] = c;
east->client[east->sel]->area = east;
- arrange_area(p, col);
- arrange_area(p, east);
+ arrange_column(p, col);
+ arrange_column(p, east);
}
focus_client(c);
}
static void
-xnew_area(void *obj, char *arg)
+xnew_column(void *obj, char *arg)
{
- new_area(obj);
+ new_column(obj);
}
static void
@@ -257,28 +204,37 @@ select_client(void *obj, char *arg)
if(!c || !arg)
return;
- if(c->area)
- select_area(c, arg);
+ if(index_of_area(c->page, c->area) > 0)
+ select_column(c, arg);
else {
- for(i = 0; (i < p->floatingsz) && p->floating[i] && (p->floating[i] != c); i++);
+ Area *a = c->area;
+ for(i = 0; (i < a->nclient) && (a->client[i] != c); i++);
if(!strncmp(arg, "prev", 5)) {
if(!i)
- for(i = 0; (i < p->floatingsz) && p->floating[i]; i++);
- focus_client(p->floating[i - 1]);
+ i = a->nclient - 1;
+ focus_client(a->client[i]);
} else if(!strncmp(arg, "next", 5)) {
- if(p->floating[i + 1])
- focus_client(p->floating[i + 1]);
+ if(i + 1 < a->nclient)
+ focus_client(a->client[i + 1]);
else
- focus_client(p->floating[0]);
+ focus_client(a->client[0]);
}
else {
const char *errstr;
- for(i = 0; (i < p->floatingsz) && p->floating[i]; i++);
- i = cext_strtonum(arg, 0, i - 1, &errstr);
+ i = cext_strtonum(arg, 0, a->nclient - 1, &errstr);
if(errstr)
return;
- focus_client(p->floating[i]);
+ focus_client(a->client[i]);
}
}
}
+int
+index_of_area(Page *p, Area *a)
+{
+ int i;
+ for(i = 0; i < p->narea; i++)
+ if(p->area[i] == a)
+ return i;
+ return -1;
+}
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -50,17 +50,17 @@ struct Client {
int proto;
unsigned int border;
unsigned int ignore_unmap;
- Bool handle_inc;
+ Bool inc;
Bool destroyed;
Bool maximized;
Bool attached;
Bool managed;
+ Page *page;
Area *area;
Window win;
Window trans;
XRectangle rect;
XSizeHints size;
- Page *page;
struct Frame {
Window win;
XRectangle rect;
@@ -103,8 +103,9 @@ typedef struct {
char selcolor[24];
char normcolor[24];
char *font;
+ Bool title;
+ Bool inc;
unsigned int border;
- unsigned int title;
unsigned int snap;
unsigned int selfg;
unsigned int selbg;
@@ -160,11 +161,10 @@ void focus_client(Client *c);
Client *win_to_frame(Window w);
void resize_client(Client *c, XRectangle * r, XPoint * pt);
unsigned int tab_height(Client *c);
-unsigned int border_width(Client *c);
/* event.c */
void init_event_hander();
-void check_event(IXPConn *c);
+void check_x_event(IXPServer *s, IXPConn *c);
/* fs.c */
void do_pend_fcall(char *event);
@@ -184,6 +184,7 @@ Page *alloc_page();
void destroy_page(Page *p);
void focus_page(Page *p);
XRectangle *rectangles(unsigned int *num);
+int index_of_area(Page *p, Area *a);
/* column.c */
void arrange_page(Page *p);
diff --git a/cmd/wmiir.c b/cmd/wmiir.c
@@ -9,8 +9,7 @@
#include <unistd.h>
#include <dirent.h>
-#include "ixp.h"
-
+#include <ixp.h>
#include <cext.h>
static IXPClient c = { 0 };
diff --git a/libixp/Makefile b/libixp/Makefile
@@ -10,7 +10,7 @@ SRC = client.c convert.c message.c server.c socket.c transport.c
OBJ = ${SRC:.c=.o}
all: libixp
- @echo built libixp2
+ @echo built libixp
.c.o:
@echo CC $<