commit 9c61ccf97e8e96cfd98860320f060f119f3b2274
parent d465cdf19c5c7fff4a31c6bc24b1034893d04d31
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Sat, 4 Mar 2006 09:23:17 +0100
several changes toward the stuff announced at wmii@wmii.de (don't use yet)
Diffstat:
| cmd/wm/Makefile | | | 2 | +- |
| cmd/wm/area.c | | | 106 | +++++++++++++++++++++++++++++++++++++++++-------------------------------------- |
| cmd/wm/bar.c | | | 8 | ++++---- |
| cmd/wm/client.c | | | 85 | +++++++++++++++++++++++++++++++++---------------------------------------------- |
| cmd/wm/event.c | | | 8 | ++++---- |
| cmd/wm/fs.c | | | 153 | +++++++++++++++++++++++++++++++++++-------------------------------------------- |
| cmd/wm/page.c | | | 174 | ------------------------------------------------------------------------------- |
| cmd/wm/tag.c | | | 174 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| cmd/wm/wm.c | | | 223 | ++----------------------------------------------------------------------------- |
| cmd/wm/wm.h | | | 47 | +++++++++++++++++++++-------------------------- |
| rc/wmiirc | | | 18 | ++---------------- |
11 files changed, 367 insertions(+), 631 deletions(-)
diff --git a/cmd/wm/Makefile b/cmd/wm/Makefile
@@ -9,7 +9,7 @@ LDFLAGS += -L../../liblitz -llitz -L../../libixp -lixp -L../../libcext -lcext
# Solaris
# LDFLAGS += -lsocket
-SRC = area.c bar.c fs.c wm.c kb.c client.c event.c mouse.c page.c
+SRC = area.c bar.c fs.c wm.c kb.c client.c event.c mouse.c tag.c
OBJ = ${SRC:.c=.o}
all: wmiiwm
diff --git a/cmd/wm/area.c b/cmd/wm/area.c
@@ -9,17 +9,17 @@
#include "wm.h"
Area *
-alloc_area(Page *p)
+alloc_area(Tag *t)
{
static unsigned short id = 1;
Area *a = cext_emallocz(sizeof(Area));
- a->page = p;
+ a->tag = t;
a->id = id++;
update_area_geometry(a);
- p->area = (Area **)cext_array_attach((void **)p->area, a, sizeof(Area *), &p->areasz);
- p->sel = p->narea;
- fprintf(stderr, "alloc_area: p->sel == %d\n", p->sel);
- p->narea++;
+ t->area = (Area **)cext_array_attach((void **)t->area, a, sizeof(Area *), &t->areasz);
+ t->sel = t->narea;
+ fprintf(stderr, "alloc_area: t->sel == %d\n", t->sel);
+ t->narea++;
return a;
}
@@ -33,18 +33,18 @@ update_area_geometry(Area *a)
void
destroy_area(Area *a)
{
- Page *p = a->page;
+ Tag *t = a->tag;
if(a->nclient)
return;
if(a->client)
free(a->client);
- cext_array_detach((void **)p->area, a, &p->areasz);
- p->narea--;
- if(p->sel == p->narea) {
- if(p->narea)
- p->sel = p->narea - 1;
+ cext_array_detach((void **)t->area, a, &t->areasz);
+ t->narea--;
+ if(t->sel == t->narea) {
+ if(t->narea)
+ t->sel = t->narea - 1;
else
- p->sel = 0;
+ t->sel = 0;
}
free(a);
}
@@ -53,19 +53,19 @@ int
area2index(Area *a)
{
int i;
- Page *p = a->page;
- for(i = 0; i < p->narea; i++)
- if(p->area[i] == a)
+ Tag *t = a->tag;
+ for(i = 0; i < t->narea; i++)
+ if(t->area[i] == a)
return i;
return -1;
}
int
-aid2index(Page *p, unsigned short id)
+aid2index(Tag *t, unsigned short id)
{
int i;
- for(i = 0; i < p->narea; i++)
- if(p->area[i]->id == id)
+ for(i = 0; i < t->narea; i++)
+ if(t->area[i]->id == id)
return i;
return -1;
}
@@ -74,32 +74,32 @@ void
select_area(Area *a, char *arg)
{
Area *new;
- Page *p = a->page;
+ Tag *t = a->tag;
int i = area2index(a);
if(i == -1)
return;
if(!strncmp(arg, "prev", 5)) {
if(i == 1)
- i = p->narea - 1;
+ i = t->narea - 1;
else
i--;
} else if(!strncmp(arg, "next", 5)) {
- if(i + 1 < p->narea)
+ if(i + 1 < t->narea)
i++;
else
i = 1;
}
else {
const char *errstr;
- i = cext_strtonum(arg, 0, p->narea - 1, &errstr);
+ i = cext_strtonum(arg, 0, t->narea - 1, &errstr);
if(errstr)
return;
}
- new = p->area[i];
+ new = t->area[i];
if(new->nclient)
focus_client(new->client[new->sel]);
- p->sel = i;
- fprintf(stderr, "select_area: p->sel == %d\n", p->sel);
+ t->sel = i;
+ fprintf(stderr, "select_area: t->sel == %d\n", t->sel);
}
void
@@ -129,9 +129,16 @@ detach_fromarea(Client *c)
Area *a = c->area;
cext_array_detach((void **)a->client, c, &a->clientsz);
a->nclient--;
- if(a->sel >= a->nclient)
- a->sel = 0;
- arrange_area(a);
+ if(a->nclient) {
+ if(a->sel >= a->nclient)
+ a->sel = 0;
+ arrange_area(a);
+ }
+ else {
+ Tag *t = a->tag;
+ destroy_area(a);
+ arrange_tag(t, True);
+ }
}
char *
@@ -161,13 +168,13 @@ str2colmode(char *arg)
static void
relax_area(Area *a)
{
- unsigned int i, yoff, h, w, hdiff, wdiff;
+ unsigned int i, yoff, h, hdiff;
if(!a->nclient)
return;
/* some relaxing from potential increment gaps */
- h = w = 0;
+ h = 0;
for(i = 0; i < a->nclient; i++) {
Client *c = a->client[i];
if(a->mode == COL_MAX) {
@@ -176,10 +183,7 @@ relax_area(Area *a)
}
else
h += c->frame.rect.height;
- if(w < c->frame.rect.width)
- w = c->frame.rect.width;
}
- wdiff = (a->rect.width - w) / 2;
/* try to add rest space to all clients if not COL_STACK mode */
if(a->mode != COL_STACK) {
@@ -196,7 +200,7 @@ relax_area(Area *a)
yoff = a->rect.y + hdiff / 2;
for(i = 0; i < a->nclient; i++) {
Client *c = a->client[i];
- c->frame.rect.x = a->rect.x + wdiff;
+ c->frame.rect.x = a->rect.x + (a->rect.width - c->frame.rect.width) / 2;
c->frame.rect.y = yoff;
if(a->mode != COL_MAX)
yoff = c->frame.rect.y + c->frame.rect.height + hdiff;
@@ -258,17 +262,17 @@ arrange_area(Area *a)
}
void
-arrange_page(Page *p, Bool updategeometry)
+arrange_tag(Tag *t, Bool updategeometry)
{
unsigned int i;
unsigned int width;
- if(p->narea == 1)
+ if(t->narea == 1)
return;
- width = rect.width / (p->narea - 1);
- for(i = 1; i < p->narea; i++) {
- Area *a = p->area[i];
+ width = rect.width / (t->narea - 1);
+ for(i = 1; i < t->narea; i++) {
+ Area *a = t->area[i];
if(updategeometry) {
update_area_geometry(a);
a->rect.x = (i - 1) * width;
@@ -295,14 +299,14 @@ static void
drop_resize(Client *c, XRectangle *new)
{
Area *west = nil, *east = nil, *a = c->area;
- Page *p = a->page;
+ Tag *t = a->tag;
Client *north = nil, *south = nil;
unsigned int i;
- for(i = 1; (i < p->narea) && (p->area[i] != a); i++);
+ for(i = 1; (i < t->narea) && (t->area[i] != a); i++);
/* first managed area is indexed 1, thus (i > 1) ? ... */
- west = (i > 1) ? p->area[i - 1] : nil;
- east = i + 1 < p->narea ? p->area[i + 1] : nil;
+ west = (i > 1) ? t->area[i - 1] : nil;
+ east = i + 1 < t->narea ? t->area[i + 1] : nil;
for(i = 1; (i < a->nclient) && (a->client[i] != c); i++);
north = i ? a->client[i - 1] : nil;
@@ -350,15 +354,15 @@ static void
drop_moving(Client *c, XRectangle *new, XPoint * pt)
{
Area *tgt = nil, *src = c->area;
- Page *p = src->page;
+ Tag *t = src->tag;
unsigned int i;
if(!pt || src->nclient < 2)
return;
- for(i = 1; (i < p->narea) &&
- !blitz_ispointinrect(pt->x, pt->y, &p->area[i]->rect); i++);
- if((tgt = ((i < p->narea) ? p->area[i] : nil))) {
+ for(i = 1; (i < t->narea) &&
+ !blitz_ispointinrect(pt->x, pt->y, &t->area[i]->rect); i++);
+ if((tgt = ((i < t->narea) ? t->area[i] : nil))) {
if(tgt != src) {
send_toarea(tgt, c);
arrange_area(tgt);
@@ -389,10 +393,10 @@ resize_area(Client *c, XRectangle *r, XPoint *pt)
}
Area *
-new_area(Page *p)
+new_area(Tag *t)
{
- Area *a = alloc_area(p);
- arrange_page(p, True);
+ Area *a = alloc_area(t);
+ arrange_tag(t, True);
return a;
}
diff --git a/cmd/wm/bar.c b/cmd/wm/bar.c
@@ -46,10 +46,10 @@ update_bar_geometry()
pmapbar = XCreatePixmap(dpy, winbar, brect.width, brect.height, DefaultDepth(dpy, screen));
XSync(dpy, False);
draw_bar();
- for(i = 0; i < npage; i++)
- for(j = 1; j < page[i]->narea; j++) {
- update_area_geometry(page[i]->area[j]);
- arrange_area(page[i]->area[j]);
+ for(i = 0; i < ntag; i++)
+ for(j = 1; j < tag[i]->narea; j++) {
+ update_area_geometry(tag[i]->area[j]);
+ arrange_area(tag[i]->area[j]);
}
}
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -75,14 +75,6 @@ set_client_state(Client * c, int state)
}
static void
-area_name_event(int aidx)
-{
- char buf[256];
- snprintf(buf, sizeof(buf), "AN %d\n", aidx);
- write_event(buf);
-}
-
-static void
client_name_event(Client *c)
{
char buf[256];
@@ -105,8 +97,7 @@ focus_client(Client *c)
Client *old = sel_client();
int i = area2index(c->area);
- c->area->page->sel = i;
- area_name_event(i);
+ c->area->tag->sel = i;
c->area->sel = client2index(c);
if(old && (old != c)) {
if(old->area == c->area)
@@ -356,9 +347,9 @@ gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert)
}
void
-attach_topage(Page *p, Client *c)
+attach_totag(Tag *t, Client *c)
{
- Area *a = p->area[p->sel];
+ Area *a = t->area[t->sel];
reparent_client(c, c->frame.win, c->rect.x, c->rect.y);
attach_toarea(a, c);
@@ -369,13 +360,13 @@ attach_topage(Page *p, Client *c)
void
attach_client(Client *c)
{
- Page *p;
- if(!npage)
- p = alloc_page();
+ Tag *t;
+ if(!ntag)
+ t = alloc_tag();
else
- p = page[sel];
+ t = tag[sel];
- attach_topage(p, c);
+ attach_totag(t, c);
focus_client(c);
}
@@ -407,10 +398,10 @@ detach_client(Client *c, Bool unmap)
}
Client *
-sel_client_of_page(Page *p)
+sel_client_of_tag(Tag *t)
{
- if(p) {
- Area *a = p->narea ? p->area[p->sel] : nil;
+ if(t) {
+ Area *a = t->narea ? t->area[t->sel] : nil;
return (a && a->nclient) ? a->client[a->sel] : nil;
}
return nil;
@@ -419,7 +410,7 @@ sel_client_of_page(Page *p)
Client *
sel_client()
{
- return npage ? sel_client_of_page(page[sel]) : nil;
+ return ntag ? sel_client_of_tag(tag[sel]) : nil;
}
Client *
@@ -477,7 +468,7 @@ resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall)
{
unsigned int bh = bar_height();
unsigned int bw = def.border;
- int pi = page2index(c->area->page);
+ int pi = tag2index(c->area->tag);
int px = sel * rect.width;
@@ -552,27 +543,27 @@ select_client(Client *c, char *arg)
}
void
-sendtopage_client(Client *c, char *arg)
+sendtotag_client(Client *c, char *arg)
{
- Page *p;
+ Tag *t;
Client *to;
if(!strncmp(arg, "new", 4))
- p = alloc_page();
+ t = alloc_tag();
else if(!strncmp(arg, "sel", 4))
- p = page[sel];
+ t = tag[sel];
else {
const char *errstr;
- int i = cext_strtonum(arg, 0, npage - 1, &errstr);
+ int i = cext_strtonum(arg, 0, ntag - 1, &errstr);
if(errstr)
return;
- p = page[i];
+ t = tag[i];
}
detach_client(c, False);
- attach_topage(p, c);
- if(p == page[sel])
+ attach_totag(t, c);
+ if(t == tag[sel])
focus_client(c);
- else if((to = sel_client_of_page(page[sel])))
+ else if((to = sel_client_of_tag(tag[sel])))
focus_client(to);
}
@@ -581,38 +572,32 @@ sendtoarea_client(Client *c, char *arg)
{
const char *errstr;
Area *to, *a = c->area;
- Page *p = a->page;
+ Tag *t = a->tag;
int i = area2index(a);
if(i == -1)
return;
if(!strncmp(arg, "prev", 5)) {
if(i == 1)
- to = p->area[p->narea - 1];
+ to = t->area[t->narea - 1];
else
- to = p->area[i - 1];
+ to = t->area[i - 1];
}
else if(!strncmp(arg, "next", 5)) {
- if(i < p->narea - 1)
- to = p->area[i + 1];
+ if(i < t->narea - 1)
+ to = t->area[i + 1];
else
- to = p->area[1];
+ to = t->area[1];
}
else {
- i = cext_strtonum(arg, 0, p->narea - 1, &errstr);
+ i = cext_strtonum(arg, 0, t->narea - 1, &errstr);
if(errstr)
return;
- to = p->area[i];
+ to = t->area[i];
}
send_toarea(to, c);
- if(!a->nclient) {
- destroy_area(a);
- arrange_page(p, True);
- }
- else {
- arrange_area(a);
- arrange_area(to);
- }
+ arrange_area(a);
+ arrange_area(to);
}
void
@@ -628,8 +613,8 @@ resize_all_clients()
void
focus(Client *c)
{
- Page *p = c->area->page;
- if(page[sel] != p)
- focus_page(p);
+ Tag *t = c->area->tag;
+ if(tag[sel] != t)
+ focus_tag(t);
focus_client(c);
}
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -296,10 +296,10 @@ static void handle_clientmessage(XEvent *e)
return; /* ignore */
else if (ev->message_type == net_atoms[NET_CURRENT_DESKTOP] && ev->format == 32) {
int i = ev->data.l[0];
- if(i < npage) {
- Page *p = page[i];
- focus_page(p);
- if((c = sel_client_of_page(p)))
+ if(i < ntag) {
+ Tag *p = tag[i];
+ focus_tag(p);
+ if((c = sel_client_of_tag(p)))
focus_client(c);
}
}
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -48,12 +48,11 @@ static char Enocommand[] = "command not supported";
* /bar/1/colors Fcolors <#RRGGBB> <#RRGGBB> <#RRGGBB>
* /event Fevent
* /ctl Fctl command interface (root)
- * /new/ Dpage returns new page
- * /sel/ Dpage sel page
- * /1/ Dpage page
- * /1/ctl Fctl command interface (page)
+ * /new/ Dtag returns new tag
+ * /sel/ Dtag sel tag
+ * /1/ Dtag tag
+ * /1/ctl Fctl command interface (tag)
* /1/sel/ Darea
- * /1/new/ Darea
* /1/float/ Darea floating clients in area 0
* /1/float/ctl Fctl command interface (area)
* /1/float/mode Fmode col mode
@@ -79,10 +78,10 @@ const char *err;
/**
* Qid->path is calculated related to the index of the associated structure.
- * i1 is associated to page, key or label
+ * i1 is associated to tag, key or label
* i2 is associated to area
* i3 is associated to client
- * ie /sel/sel/ctl is i1id = sel page id, i2id = sel area id , i3id = 0 (no id)
+ * ie /sel/sel/ctl is i1id = sel tag id, i2id = sel area id , i3id = 0 (no id)
*/
unsigned long long
mkqpath(unsigned char type, unsigned short i1id, unsigned short i2id, unsigned short i3id)
@@ -132,9 +131,9 @@ decode_qpath(Qid *qid, unsigned char *type, int *i1, int *i2, int *i3)
default: *i1 = pid2index(i1id); break;
}
if(i2id && (*i1 != -1)) {
- *i2 = aid2index(page[*i1], i2id);
+ *i2 = aid2index(tag[*i1], i2id);
if(i3id && (*i2 != -1))
- *i3 = cid2index(page[*i1]->area[*i2], i3id);
+ *i3 = cid2index(tag[*i1]->area[*i2], i3id);
}
}
}
@@ -155,7 +154,7 @@ qid2name(Qid *qid)
case Ddef: return "def"; break;
case Dkeys: return "keys"; break;
case Dbar: return "bar"; break;
- case Dpage:
+ case Dtag:
if(i1 == sel)
return "sel";
snprintf(buf, sizeof(buf), "%u", i1);
@@ -167,18 +166,18 @@ qid2name(Qid *qid)
break;
case Darea:
if(!i2) {
- if(i2 == page[i1]->sel)
+ if(i2 == tag[i1]->sel)
return "sel";
else
return "float";
}
- if(page[i1]->sel == i2)
+ if(tag[i1]->sel == i2)
return "sel";
snprintf(buf, sizeof(buf), "%u", i2);
return buf;
break;
case Dclient:
- if(page[i1]->area[i2]->sel == i3)
+ if(tag[i1]->area[i2]->sel == i3)
return "sel";
snprintf(buf, sizeof(buf), "%u", i3);
return buf;
@@ -209,9 +208,8 @@ name2type(char *name, unsigned char dir_type)
return Droot;
if(!strncmp(name, "new", 4)) {
switch(dir_type) {
- case Droot: return Dpage; break;
+ case Droot: return Dtag; break;
case Dbar: return Dlabel; break;
- case Dpage: return Darea; break;
}
}
if(!strncmp(name, "bar", 4))
@@ -256,9 +254,9 @@ name2type(char *name, unsigned char dir_type)
dyndir:
/*fprintf(stderr, "nametotype: dir_type = %d\n", dir_type);*/
switch(dir_type) {
- case Droot: return Dpage; break;
+ case Droot: return Dtag; break;
case Dbar: return Dlabel; break;
- case Dpage: return Darea; break;
+ case Dtag: return Darea; break;
case Darea: return Dclient; break;
}
return -1;
@@ -309,43 +307,33 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
new->path = mkqpath(Dlabel, label[i]->id, 0, 0);
}
break;
- case Dpage:
+ case Dtag:
new->type = IXP_QTDIR;
if(!strncmp(wname, "new", 4)) {
if(iswalk) {
- Page *p = alloc_page();
- new->path = mkqpath(Dpage, p->id, 0, 0);
+ Tag *p = alloc_tag();
+ new->path = mkqpath(Dtag, p->id, 0, 0);
}
else
- new->path = mkqpath(Dpage, 0, 0, 0);
+ new->path = mkqpath(Dtag, 0, 0, 0);
}
else if(!strncmp(wname, "sel", 4)) {
- if(!npage)
+ if(!ntag)
return -1;
- new->path = mkqpath(Dpage, page[sel]->id, 0, 0);
+ new->path = mkqpath(Dtag, tag[sel]->id, 0, 0);
}
else {
i = cext_strtonum(wname, 0, 0xffff, &err);
- if(err || (i >= npage))
+ if(err || (i >= ntag))
return -1;
- new->path = mkqpath(Dpage, page[i]->id, 0, 0);
+ new->path = mkqpath(Dtag, tag[i]->id, 0, 0);
}
break;
case Darea:
{
- Page *p = page[dir_i1];
+ Tag *p = tag[dir_i1];
new->type = IXP_QTDIR;
- if(!strncmp(wname, "new", 4)) {
- if(iswalk) {
- Area *a = new_area(p);
- if(!a)
- return -1;
- 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)) {
+ if(!strncmp(wname, "sel", 4)) {
new->path = mkqpath(Darea, p->id, p->area[p->sel]->id, 0);
}
else {
@@ -358,7 +346,7 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
break;
case Dclient:
{
- Page *p = page[dir_i1];
+ Tag *p = tag[dir_i1];
Area *a = p->area[dir_i2];
new->type = IXP_QTDIR;
if(!strncmp(wname, "sel", 4)) {
@@ -533,7 +521,7 @@ type2stat(Stat *stat, char *wname, Qid *dir)
switch (type) {
case Dclient:
case Darea:
- case Dpage:
+ case Dtag:
case Ddef:
case Dkeys:
case Dbar:
@@ -550,7 +538,7 @@ type2stat(Stat *stat, char *wname, Qid *dir)
return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE);
break;
case Fgeom:
- c = page[dir_i1]->area[dir_i2]->client[dir_i3];
+ c = tag[dir_i1]->area[dir_i2]->client[dir_i3];
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, wname, strlen(buf), DMREAD | DMWRITE);
@@ -560,7 +548,7 @@ type2stat(Stat *stat, char *wname, Qid *dir)
return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE);
break;
case Fname:
- c = page[dir_i1]->area[dir_i2]->client[dir_i3];
+ c = tag[dir_i1]->area[dir_i2]->client[dir_i3];
return mkstat(stat, dir, wname, strlen(c->name), DMREAD);
break;
case Fkey:
@@ -574,7 +562,7 @@ type2stat(Stat *stat, char *wname, Qid *dir)
return mkstat(stat, dir, wname, (dir_i1 == nlabel) ? 0 : strlen(label[dir_i1]->data), DMREAD | DMWRITE);
break;
case Fmode:
- return mkstat(stat, dir, wname, strlen(colmode2str(page[dir_i1]->area[dir_i2]->mode)), DMREAD | DMWRITE);
+ return mkstat(stat, dir, wname, strlen(colmode2str(tag[dir_i1]->area[dir_i2]->mode)), DMREAD | DMWRITE);
break;
case Fcolors:
case Fselcolors:
@@ -592,6 +580,7 @@ xremove(IXPConn *c, Fcall *fcall)
{
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
unsigned char type;
+ char *ret;
int i1 = 0, i2 = 0, i3 = 0;
if(!m)
@@ -600,12 +589,9 @@ xremove(IXPConn *c, Fcall *fcall)
if((i1 == -1) || (i2 == -1) || (i3 == -1))
return Enofile;
switch(type) {
- case Dpage:
- {
- char *ret = destroy_page(page[i1]);
- if(ret)
- return ret;
- }
+ case Dtag:
+ if((ret = destroy_tag(tag[i1])))
+ return ret;
break;
case Dlabel:
{
@@ -666,7 +652,7 @@ xread(IXPConn *c, Fcall *fcall)
len += type2stat(&stat, "keys", &m->qid);
len += type2stat(&stat, "bar", &m->qid);
len += type2stat(&stat, "new", &m->qid);
- for(i = 0; i < npage; i++) {
+ for(i = 0; i < ntag; i++) {
if(i == sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
@@ -677,7 +663,7 @@ xread(IXPConn *c, Fcall *fcall)
break;
}
/* offset found, proceeding */
- for(; i < npage; i++) {
+ for(; i < ntag; i++) {
if(i == sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
@@ -728,12 +714,11 @@ xread(IXPConn *c, Fcall *fcall)
p = ixp_enc_stat(p, &stat);
}
break;
- case Dpage:
+ case Dtag:
/* jump to offset */
len = type2stat(&stat, "ctl", &m->qid);
- len += type2stat(&stat, "new", &m->qid);
- for(i = 0; i < page[i1]->narea; i++) {
- if(i == page[i1]->sel)
+ for(i = 0; i < tag[i1]->narea; i++) {
+ if(i == tag[i1]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i);
@@ -743,8 +728,8 @@ xread(IXPConn *c, Fcall *fcall)
break;
}
/* offset found, proceeding */
- for(; i < page[i1]->narea; i++) {
- if(i == page[i1]->sel)
+ for(; i < tag[i1]->narea; i++) {
+ if(i == tag[i1]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i);
@@ -760,8 +745,8 @@ xread(IXPConn *c, Fcall *fcall)
len = type2stat(&stat, "ctl", &m->qid);
if(i2)
len += type2stat(&stat, "mode", &m->qid);
- for(i = 0; i < page[i1]->area[i2]->nclient; i++) {
- if(i == page[i1]->area[i2]->sel)
+ for(i = 0; i < tag[i1]->area[i2]->nclient; i++) {
+ if(i == tag[i1]->area[i2]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i);
@@ -771,8 +756,8 @@ xread(IXPConn *c, Fcall *fcall)
break;
}
/* offset found, proceeding */
- for(; i < page[i1]->area[i2]->nclient; i++) {
- if(i == page[i1]->area[i2]->sel)
+ for(; i < tag[i1]->area[i2]->nclient; i++) {
+ if(i == tag[i1]->area[i2]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i);
@@ -807,7 +792,7 @@ xread(IXPConn *c, Fcall *fcall)
p = ixp_enc_stat(p, &stat);
fcall->count += type2stat(&stat, "new", &m->qid);
p = ixp_enc_stat(p, &stat);
- for(i = 0; i < npage; i++) {
+ for(i = 0; i < ntag; i++) {
if(i == sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
@@ -862,13 +847,11 @@ xread(IXPConn *c, Fcall *fcall)
fcall->count += type2stat(&stat, "font", &m->qid);
p = ixp_enc_stat(p, &stat);
break;
- case Dpage:
+ case Dtag:
fcall->count = type2stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
- fcall->count += type2stat(&stat, "new", &m->qid);
- p = ixp_enc_stat(p, &stat);
- for(i = 0; i < page[i1]->narea; i++) {
- if(i == page[i1]->sel)
+ for(i = 0; i < tag[i1]->narea; i++) {
+ if(i == tag[i1]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i);
@@ -885,8 +868,8 @@ xread(IXPConn *c, Fcall *fcall)
if(i2)
fcall->count += type2stat(&stat, "mode", &m->qid);
p = ixp_enc_stat(p, &stat);
- for(i = 0; i < page[i1]->area[i2]->nclient; i++) {
- if(i == page[i1]->area[i2]->sel)
+ for(i = 0; i < tag[i1]->area[i2]->nclient; i++) {
+ if(i == tag[i1]->area[i2]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i);
@@ -921,7 +904,7 @@ xread(IXPConn *c, Fcall *fcall)
memcpy(p, buf, fcall->count);
break;
case Fgeom:
- client = page[i1]->area[i2]->client[i3];
+ client = tag[i1]->area[i2]->client[i3];
snprintf(buf, sizeof(buf), "%d %d %d %d", client->frame.rect.x, client->frame.rect.y,
client->frame.rect.width, client->frame.rect.height);
fcall->count = strlen(buf);
@@ -933,8 +916,8 @@ xread(IXPConn *c, Fcall *fcall)
memcpy(p, buf, fcall->count);
break;
case Fname:
- if((fcall->count = strlen(page[i1]->area[i2]->client[i3]->name)))
- memcpy(p, page[i1]->area[i2]->client[i3]->name, fcall->count);
+ if((fcall->count = strlen(tag[i1]->area[i2]->client[i3]->name)))
+ memcpy(p, tag[i1]->area[i2]->client[i3]->name, fcall->count);
break;
case Fexpand:
snprintf(buf, sizeof(buf), "%u", iexpand);
@@ -968,7 +951,7 @@ xread(IXPConn *c, Fcall *fcall)
case Fmode:
if(!i2)
return Enofile;
- snprintf(buf, sizeof(buf), "%s", colmode2str(page[i1]->area[i2]->mode));
+ snprintf(buf, sizeof(buf), "%s", colmode2str(tag[i1]->area[i2]->mode));
fcall->count = strlen(buf);
memcpy(p, buf, fcall->count);
break;
@@ -1024,10 +1007,8 @@ xwrite(IXPConn *c, Fcall *fcall)
case Droot:
if(!strncmp(buf, "quit", 5))
srv.running = 0;
- else if(!strncmp(buf, "pager", 6))
- pager();
else if(!strncmp(buf, "select", 6))
- select_page(&buf[7]);
+ select_tag(&buf[7]);
else if(!strncmp(buf, "warp ", 5)) {
char *err;
if((err = warp_mouse(&buf[5])))
@@ -1036,23 +1017,23 @@ xwrite(IXPConn *c, Fcall *fcall)
else
return Enocommand;
break;
- case Dpage:
+ case Dtag:
if(!strncmp(buf, "select ", 7))
- select_area(page[i1]->area[page[i1]->sel], &buf[7]);
+ select_area(tag[i1]->area[tag[i1]->sel], &buf[7]);
break;
case Darea:
if(!strncmp(buf, "select ", 7)) {
- Area *a = page[i1]->area[i2];
+ Area *a = tag[i1]->area[i2];
if(a->nclient)
select_client(a->client[a->sel], &buf[7]);
}
break;
case Dclient:
- cl = page[i1]->area[i2]->client[i3];
+ cl = tag[i1]->area[i2]->client[i3];
if(!strncmp(buf, "kill", 5))
kill_client(cl);
- else if(!strncmp(buf, "sendtopage ", 11))
- sendtopage_client(cl, &buf[11]);
+ else if(!strncmp(buf, "sendtotag ", 11))
+ sendtotag_client(cl, &buf[11]);
else if(!strncmp(buf, "sendtoarea ", 11))
sendtoarea_client(cl, &buf[11]);
break;
@@ -1082,7 +1063,7 @@ xwrite(IXPConn *c, Fcall *fcall)
resize_all_clients();
break;
case Fgeom:
- cl = page[i1]->area[i2]->client[i3];
+ cl = tag[i1]->area[i2]->client[i3];
if(fcall->count > sizeof(buf))
return "geometry values out of range";
memcpy(buf, fcall->data, fcall->count);
@@ -1137,7 +1118,7 @@ xwrite(IXPConn *c, Fcall *fcall)
def.selcolor[fcall->count] = 0;
blitz_loadcolor(dpy, screen, def.selcolor, &def.sel);
for(i = 0; i < nclient; i++)
- if(client[i]->area->page == page[sel])
+ if(client[i]->area->tag == tag[sel])
draw_client(client[i]);
break;
case Fnormcolors:
@@ -1150,7 +1131,7 @@ xwrite(IXPConn *c, Fcall *fcall)
def.normcolor[fcall->count] = 0;
blitz_loadcolor(dpy, screen, def.normcolor, &def.norm);
for(i = 0; i < nclient; i++)
- if(client[i]->area->page == page[sel])
+ if(client[i]->area->tag == tag[sel])
draw_client(client[i]);
break;
case Ffont:
@@ -1173,8 +1154,8 @@ xwrite(IXPConn *c, Fcall *fcall)
mode = str2colmode(buf);
if(mode == -1)
return "invalid area mode";
- page[i1]->area[i2]->mode = mode;
- arrange_area(page[i1]->area[i2]);
+ tag[i1]->area[i2]->mode = mode;
+ arrange_area(tag[i1]->area[i2]);
}
break;
case Fkey:
diff --git a/cmd/wm/page.c b/cmd/wm/page.c
@@ -1,174 +0,0 @@
-/*
- * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
- * See LICENSE file for license details.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <X11/Xatom.h>
-
-#include "wm.h"
-
-Page *
-alloc_page()
-{
- static unsigned short id = 1;
- Page *p = cext_emallocz(sizeof(Page));
-
- p->id = id++;
- alloc_area(p);
- alloc_area(p);
- page = (Page **)cext_array_attach((void **)page, p, sizeof(Page *), &pagesz);
- npage++;
- focus_page(p);
- XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
- 32, PropModeReplace, (unsigned char *) &npage, 1);
- return p;
-}
-
-char *
-destroy_page(Page *p)
-{
- unsigned int i;
- Page *old = p->revert;
- Client *c;
-
- for(i = 0; i < p->narea; i++)
- if(p->area[i]->nclient)
- return "page not empty";
-
- while(p->narea)
- destroy_area(p->area[0]);
-
- cext_array_detach((void **)page, p, &pagesz);
- npage--;
-
- for(i = 0; i < npage; i++) {
- if(page[i]->revert == p)
- page[i]->revert = nil;
- XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
- 32, PropModeReplace, (unsigned char *) &i, 1);
- }
-
- free(p);
- if(npage && old) {
- focus_page(old);
- if((c = sel_client_of_page(old)))
- focus_client(c);
- }
- else
- write_event("PN -\n");
- return nil;
-}
-
-int
-page2index(Page *p)
-{
- int i;
- for(i = 0; i < npage; i++)
- if(p == page[i])
- return i;
- return -1;
-}
-
-void
-focus_page(Page *p)
-{
- Page *old = page ? page[sel] : nil;
- char buf[16];
- Client *c;
- int i, pi = page2index(p);
- int px;
-
- if(!npage || (pi == -1))
- return;
-
- if(old && old != p)
- p->revert = old;
- sel = pi;
- px = sel * rect.width;
- /* gives all(!) clients proper geometry (for use of different pagers) */
- for(i = 0; i < nclient; i++) {
- c = client[i];
- if(c->area) {
- pi = page2index(c->area->page);
- XMoveWindow(dpy, c->frame.win, px - (pi * rect.width) + c->frame.rect.x, c->frame.rect.y);
- if(c->area->page == p)
- draw_client(c);
- }
- }
- snprintf(buf, sizeof(buf), "PN %d\n", sel);
- write_event(buf);
- XChangeProperty(dpy, root, net_atoms[NET_CURRENT_DESKTOP], XA_CARDINAL,
- 32, PropModeReplace, (unsigned char *) &sel, 1);
- XSync(dpy, False);
-}
-
-XRectangle *
-rectangles(unsigned int *num)
-{
- XRectangle *result = 0;
- int i, j = 0;
- Window d1, d2;
- Window *wins;
- XWindowAttributes wa;
- XRectangle r;
-
- if(XQueryTree(dpy, root, &d1, &d2, &wins, num)) {
- result = cext_emallocz(*num * sizeof(XRectangle));
- for(i = 0; i < *num; i++) {
- if(!XGetWindowAttributes(dpy, wins[i], &wa))
- continue;
- if(wa.override_redirect && (wa.map_state == IsViewable)) {
- r.x = wa.x;
- r.y = wa.y;
- r.width = wa.width;
- r.height = wa.height;
- result[j++] = r;
- }
- }
- }
- if(wins)
- XFree(wins);
- *num = j;
- return result;
-}
-
-int
-pid2index(unsigned short id)
-{
- int i;
- for(i = 0; i < npage; i++)
- if(page[i]->id == id)
- return i;
- return -1;
-}
-
-void
-select_page(char *arg)
-{
- unsigned int new = sel;
- const char *err;
- Client *c;
-
- if(!npage)
- return;
- if(!strncmp(arg, "prev", 5)) {
- if(new <= 1)
- new = npage;
- new--;
- } else if(!strncmp(arg, "next", 5)) {
- if(new < npage - 1)
- new++;
- else
- new = 1;
- } else {
- int idx = cext_strtonum(arg, 0, npage - 1, &err);
- if(idx < npage)
- new = idx;
- }
- focus_page(page[new]);
- if((c = sel_client_of_page(page[new])))
- focus_client(c);
-}
diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c
@@ -0,0 +1,174 @@
+/*
+ * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
+ * See LICENSE file for license details.
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xatom.h>
+
+#include "wm.h"
+
+Tag *
+alloc_tag()
+{
+ static unsigned short id = 1;
+ Tag *t = cext_emallocz(sizeof(Tag));
+
+ t->id = id++;
+ alloc_area(t);
+ alloc_area(t);
+ tag = (Tag **)cext_array_attach((void **)tag, t, sizeof(Tag *), &tagsz);
+ ntag++;
+ focus_tag(t);
+ XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
+ 32, PropModeReplace, (unsigned char *) &ntag, 1);
+ return t;
+}
+
+char *
+destroy_tag(Tag *t)
+{
+ unsigned int i;
+ Tag *old = t->revert;
+ Client *c;
+
+ for(i = 0; i < t->narea; i++)
+ if(t->area[i]->nclient)
+ return "tag not empty";
+
+ while(t->narea)
+ destroy_area(t->area[0]);
+
+ cext_array_detach((void **)tag, t, &tagsz);
+ ntag--;
+
+ for(i = 0; i < ntag; i++) {
+ if(tag[i]->revert == t)
+ tag[i]->revert = nil;
+ XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
+ 32, PropModeReplace, (unsigned char *) &i, 1);
+ }
+
+ free(t);
+ if(ntag && old) {
+ focus_tag(old);
+ if((c = sel_client_of_tag(old)))
+ focus_client(c);
+ }
+ else
+ write_event("PN -\n");
+ return nil;
+}
+
+int
+tag2index(Tag *t)
+{
+ int i;
+ for(i = 0; i < ntag; i++)
+ if(t == tag[i])
+ return i;
+ return -1;
+}
+
+void
+focus_tag(Tag *t)
+{
+ Tag *old = tag ? tag[sel] : nil;
+ char buf[16];
+ Client *c;
+ int i, pi = tag2index(t);
+ int px;
+
+ if(!ntag || (pi == -1))
+ return;
+
+ if(old && old != t)
+ t->revert = old;
+ sel = pi;
+ px = sel * rect.width;
+ /* gives all(!) clients proper geometry (for use of different tagrs) */
+ for(i = 0; i < nclient; i++) {
+ c = client[i];
+ if(c->area) {
+ pi = tag2index(c->area->tag);
+ XMoveWindow(dpy, c->frame.win, px - (pi * rect.width) + c->frame.rect.x, c->frame.rect.y);
+ if(c->area->tag == t)
+ draw_client(c);
+ }
+ }
+ snprintf(buf, sizeof(buf), "PN %d\n", sel);
+ write_event(buf);
+ XChangeProperty(dpy, root, net_atoms[NET_CURRENT_DESKTOP], XA_CARDINAL,
+ 32, PropModeReplace, (unsigned char *) &sel, 1);
+ XSync(dpy, False);
+}
+
+XRectangle *
+rectangles(unsigned int *num)
+{
+ XRectangle *result = 0;
+ int i, j = 0;
+ Window d1, d2;
+ Window *wins;
+ XWindowAttributes wa;
+ XRectangle r;
+
+ if(XQueryTree(dpy, root, &d1, &d2, &wins, num)) {
+ result = cext_emallocz(*num * sizeof(XRectangle));
+ for(i = 0; i < *num; i++) {
+ if(!XGetWindowAttributes(dpy, wins[i], &wa))
+ continue;
+ if(wa.override_redirect && (wa.map_state == IsViewable)) {
+ r.x = wa.x;
+ r.y = wa.y;
+ r.width = wa.width;
+ r.height = wa.height;
+ result[j++] = r;
+ }
+ }
+ }
+ if(wins)
+ XFree(wins);
+ *num = j;
+ return result;
+}
+
+int
+pid2index(unsigned short id)
+{
+ int i;
+ for(i = 0; i < ntag; i++)
+ if(tag[i]->id == id)
+ return i;
+ return -1;
+}
+
+void
+select_tag(char *arg)
+{
+ unsigned int new = sel;
+ const char *err;
+ Client *c;
+
+ if(!ntag)
+ return;
+ if(!strncmp(arg, "prev", 5)) {
+ if(new <= 1)
+ new = ntag;
+ new--;
+ } else if(!strncmp(arg, "next", 5)) {
+ if(new < ntag - 1)
+ new++;
+ else
+ new = 1;
+ } else {
+ int idx = cext_strtonum(arg, 0, ntag - 1, &err);
+ if(idx < ntag)
+ new = idx;
+ }
+ focus_tag(tag[new]);
+ if((c = sel_client_of_tag(tag[new])))
+ focus_client(c);
+}
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -17,7 +17,6 @@
#include "wm.h"
-static XRectangle initial_rect;
static int other_wm_running;
static int (*x_error_handler) (Display *, XErrorEvent *);
@@ -30,207 +29,6 @@ usage()
exit(1);
}
-static void
-scale_rect(XRectangle * from_dim, XRectangle * to_dim,
- XRectangle * src, XRectangle * tgt)
-{
- double wfact = (double) to_dim->width / (double) from_dim->width;
- double hfact = (double) to_dim->height / (double) from_dim->height;
-
- tgt->x = to_dim->x + (src->x * wfact);
- tgt->y = to_dim->y + (src->y * hfact);
- tgt->width = (src->width * wfact);
- tgt->height = (src->height * hfact);
-
- if(tgt->width < 1)
- tgt->width = 1;
- if(tgt->height < 1)
- tgt->height = 1;
-}
-
-static void
-draw_pager_client(Client *c, Draw *d)
-{
- if(c == sel_client_of_page(c->area->page))
- d->color = def.sel;
- else
- d->color = def.norm;
-
- d->data = c->name;
- scale_rect(&rect, &initial_rect, &c->frame.rect, &d->rect);
-
- if(d->rect.height < bar_height())
- d->data = nil;
-
- blitz_drawlabel(dpy, d);
- XSync(dpy, False); /* do not clear upwards */
-}
-
-static void
-draw_pager_page(unsigned int idx, Draw *d)
-{
- int i, j;
- char name[4];
- initial_rect = d->rect;
-
- if(idx == sel)
- d->color = def.sel;
- else
- d->color = def.norm;
- snprintf(name, sizeof(name), "%d", idx);
- d->data = name;
- blitz_drawlabel(dpy, d);
- XSync(dpy, False);
-
- for(i = 0; i < page[idx]->narea; i++) {
- Area *a = page[idx]->area[i];
- if(!a->nclient)
- continue;
- for(j = 0; j < a->nclient; j++)
- draw_pager_client(a->client[j], d);
- }
-}
-
-static void
-draw_pager()
-{
- Draw d = { 0 };
- unsigned int i, ic, ir, tw, th, rows, cols;
- int dx;
-
- blitz_getbasegeometry(npage - 1, &cols, &rows);
- dx = (cols - 1) * DEF_PAGER_GAP; /* DEF_PAGER_GAPpx space */
- tw = (rect.width - dx) / cols;
- th = ((double) tw / rect.width) * rect.height;
- d.drawable = transient;
- d.gc = gc_transient;
- d.font = xfont;
- d.align = CENTER;
- i = 1;
- for(ir = 0; ir < rows; ir++) {
- for(ic = 0; ic < cols; ic++) {
- d.rect.x = ic * tw + (ic * DEF_PAGER_GAP);
- d.rect.width = tw;
- if(rows == 1)
- d.rect.y = 0;
- else
- d.rect.y = ir * (rect.height - th) / (rows - 1);
- d.rect.height = th;
- draw_pager_page(i++, &d);
- if(i == npage)
- return;
- }
- }
-}
-
-static int
-xy2pager_page(int x, int y)
-{
- unsigned int i, ic, ir, tw, th, rows, cols;
- int dx;
- XRectangle r;
-
- blitz_getbasegeometry(npage - 1, &cols, &rows);
- dx = (cols - 1) * DEF_PAGER_GAP; /* DEF_PAGER_GAPpx space */
- tw = (rect.width - dx) / cols;
- th = ((double) tw / rect.width) * rect.height;
-
- i = 1;
- for(ir = 0; ir < rows; ir++) {
- for(ic = 0; ic < cols; ic++) {
- r.x = ic * tw + (ic * DEF_PAGER_GAP);
- r.width = tw;
- if(rows == 1)
- r.y = 0;
- else
- r.y = ir * (rect.height - th) / (rows - 1);
- r.height = th;
- if(blitz_ispointinrect(x, y, &r))
- return i;
- i++;
- if(i == npage)
- return -1;
- }
- }
- return -1;
-}
-
-static int
-handle_kpress(XKeyEvent * e)
-{
- KeySym ksym = XKeycodeToKeysym(dpy, e->keycode, 0);
-
- if(ksym >= XK_1 && ksym <= XK_9)
- return ksym - XK_1 + 1;
- else if(ksym >= XK_a && ksym <= XK_z)
- return 10 + ksym - XK_a;
- return -1;
-}
-
-void
-pager()
-{
- XEvent ev;
- int i;
- Client *c;
-
- if(npage < 2)
- return;
-
- XClearWindow(dpy, transient);
- XMapRaised(dpy, transient);
- draw_pager();
-
- while(XGrabKeyboard
- (dpy, transient, True, GrabModeAsync, GrabModeAsync,
- CurrentTime) != GrabSuccess)
- usleep(20000);
-
- while(XGrabPointer
- (dpy, transient, False, ButtonPressMask, GrabModeAsync,
- GrabModeAsync, None, normal_cursor, CurrentTime) != GrabSuccess)
- usleep(20000);
-
- for(;;) {
- while(!XCheckWindowEvent
- (dpy, transient, ButtonPressMask | KeyPressMask, &ev)) {
- usleep(20000);
- continue;
- }
-
- switch (ev.type) {
- case KeyPress:
- XUnmapWindow(dpy, transient);
- if((i = handle_kpress(&ev.xkey)) != -1)
- if(i < npage) {
- focus_page(page[i]);
- if((c = sel_client_of_page(page[i])))
- focus_client(c);
- }
- XUngrabKeyboard(dpy, CurrentTime);
- XUngrabPointer(dpy, CurrentTime /* ev.xbutton.time */ );
- XSync(dpy, False);
- return;
- break;
- case ButtonPress:
- XUnmapWindow(dpy, transient);
- if(ev.xbutton.button == Button1) {
- if((i = xy2pager_page(ev.xbutton.x, ev.xbutton.y)) != -1) {
- focus_page(page[i]);
- if((c = sel_client_of_page(page[i])))
- focus_client(c);
- }
-
- }
- XUngrabKeyboard(dpy, CurrentTime);
- XUngrabPointer(dpy, CurrentTime /* ev.xbutton.time */ );
- XSync(dpy, False);
- return;
- break;
- }
- }
-}
-
Client *
win2client(Window w)
{
@@ -369,7 +167,6 @@ static void
init_screen()
{
XGCValues gcv;
- XSetWindowAttributes wa;
gcv.subwindow_mode = IncludeInferiors;
gcv.function = GXxor;
@@ -384,18 +181,6 @@ init_screen()
rect.width = DisplayWidth(dpy, screen);
rect.height = DisplayHeight(dpy, screen);
- wa.override_redirect = 1;
- wa.background_pixmap = ParentRelative;
- wa.event_mask = ExposureMask | ButtonPressMask;
-
- transient = XCreateWindow(dpy, root, 0, 0, rect.width, rect.height,
- 0, DefaultDepth(dpy, screen), CopyFromParent,
- DefaultVisual(dpy, screen),
- CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
-
- XSync(dpy, False);
- gc_transient = XCreateGC(dpy, transient, 0, 0);
- XDefineCursor(dpy, transient, normal_cursor);
XDefineCursor(dpy, root, normal_cursor);
}
@@ -528,8 +313,8 @@ main(int argc, char *argv[])
ixp_server_open_conn(&srv, ConnectionNumber(dpy), check_x_event, nil);
init_x_event_handler();
- npage = nclient = pagesz = clientsz = sel = 0;
- page = nil;
+ ntag = nclient = tagsz = clientsz = sel = 0;
+ tag = nil;
client = nil;
key = nil;
@@ -573,8 +358,8 @@ main(int argc, char *argv[])
XMapRaised(dpy, winbar);
draw_bar();
- alloc_page(); /* page 0 */
- alloc_page(); /* page 1 */
+ alloc_tag(); /* tag 0 */
+ alloc_tag(); /* tag 1 */
scan_wins();
/* main event loop */
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -22,7 +22,7 @@ enum {
enum {
Droot,
Ddef,
- Dpage,
+ Dtag,
Darea,
Dclient,
Dkeys,
@@ -56,7 +56,7 @@ enum {
#define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask)
typedef struct Area Area;
-typedef struct Page Page;
+typedef struct Tag Tag;
typedef struct Client Client;
typedef enum { COL_EQUAL, COL_STACK, COL_MAX, COL_MODE_LAST } ColumnMode;
@@ -64,7 +64,7 @@ typedef enum { COL_EQUAL, COL_STACK, COL_MAX, COL_MODE_LAST } ColumnMode;
struct Area {
unsigned short id;
Client **client;
- Page *page;
+ Tag *tag;
unsigned int clientsz;
unsigned int sel;
unsigned int nclient;
@@ -72,13 +72,13 @@ struct Area {
XRectangle rect;
};
-struct Page {
+struct Tag {
unsigned short id;
Area **area;
unsigned int areasz;
unsigned int narea;
unsigned int sel;
- Page *revert;
+ Tag *revert;
};
struct Client {
@@ -131,9 +131,9 @@ typedef struct {
} Default;
/* global variables */
-Page **page;
-unsigned int npage;
-unsigned int pagesz;
+Tag **tag;
+unsigned int ntag;
+unsigned int tagsz;
unsigned int sel;
Client **client;
unsigned int nclient;
@@ -150,11 +150,9 @@ Display *dpy;
IXPServer *ixps;
int screen;
Window root;
-Window transient; /* pager / attach */
XRectangle rect;
XFontStruct *xfont;
GC gc_xor;
-GC gc_transient;
IXPServer srv;
Pixmap pmapbar;
Window winbar;
@@ -187,19 +185,19 @@ Cursor se_cursor;
unsigned int valid_mask, num_lock_mask;
/* area.c */
-Area *alloc_area(Page *p);
+Area *alloc_area(Tag *t);
void destroy_area(Area *a);
int area2index(Area *a);
-int aid2index(Page *p, unsigned short id);
+int aid2index(Tag *t, unsigned short id);
void update_area_geometry(Area *a);
void select_area(Area *a, char *arg);
void send_toarea(Area *to, Client *c);
void attach_toarea(Area *a, Client *c);
void detach_fromarea(Client *c);
-void arrange_page(Page *p, Bool updategeometry);
+void arrange_tag(Tag *t, Bool updategeometry);
void arrange_area(Area *a);
void resize_area(Client *c, XRectangle *r, XPoint *pt);
-Area *new_area(Page *p);
+Area *new_area(Tag *t);
ColumnMode str2colmode(char *arg);
char *colmode2str(ColumnMode mode);
@@ -223,17 +221,17 @@ void unmap_client(Client *c);
void map_client(Client *c);
void reparent_client(Client *c, Window w, int x, int y);
void attach_client(Client *c);
-void attach_topage(Page *p, Client *c);
+void attach_totag(Tag *t, Client *c);
void detach_client(Client *c, Bool unmap);
Client *sel_client();
-Client *sel_client_of_page(Page *p);
+Client *sel_client_of_tag(Tag *t);
void focus_client(Client *c);
Client *win2clientframe(Window w);
void resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall);
int cid2index(Area *a, unsigned short id);
int client2index(Client *c);
void select_client(Client *c, char *arg);
-void sendtopage_client(Client *c, char *arg);
+void sendtotag_client(Client *c, char *arg);
void sendtoarea_client(Client *c, char *arg);
void resize_all_clients();
void focus(Client *c);
@@ -269,20 +267,17 @@ void grab_mouse(Window w, unsigned long mod, unsigned int button);
void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
char *warp_mouse(char *arg);
-/* page.c */
-Page *alloc_page();
-char *destroy_page(Page *p);
-void focus_page(Page *p);
+/* tag.c */
+Tag *alloc_tag();
+char *destroy_tag(Tag *t);
+void focus_tag(Tag *t);
XRectangle *rectangles(unsigned int *num);
int pid2index(unsigned short id);
-void select_page(char *arg);
-int page2index(Page *p);
+void select_tag(char *arg);
+int tag2index(Tag *t);
/* wm.c */
void scan_wins();
Client *win2client(Window w);
int win_proto(Window w);
int win_state(Window w);
-/*void handle_after_write(IXPServer * s, File * f);*/
-void pager();
-
diff --git a/rc/wmiirc b/rc/wmiirc
@@ -40,11 +40,9 @@ do
:
done
xwrite /bar/new/colors $WMII_NORMCOLORS
-xwrite /bar/new/colors $WMII_NORMCOLORS
xwrite /bar/new/colors $WMII_SELCOLORS
xwrite /bar/0/data 1
-xwrite /bar/1/data 1
-xwrite /bar/expand 2
+xwrite /bar/expand 1
# MISC
xsetroot -solid '#0b1014'
@@ -76,7 +74,6 @@ $MODKEY-Shift-s
$MODKEY-Shift-equal
$MODKEY-Shift-h
$MODKEY-Shift-l
-$MODKEY-Shift-p
$MODKEY-Shift-Return
$MODKEY-Shift-0
$MODKEY-Shift-1
@@ -101,19 +98,10 @@ do
case "$type" in
PN)
xwrite /bar/0/data "$@";;
- AN)
- xwrite /bar/1/data "$@";;
- CN)
- xwrite /bar/2/data "$@";;
LB)
case "$2" in
1)
- if test 1 -eq "$1"
- then
- xwrite /ctl pager
- else
- xwrite /ctl select prev
- fi;;
+ xwrite /ctl select prev;;
3|4)
xwrite /ctl select next;;
5)
@@ -163,8 +151,6 @@ do
xwrite /ctl select prev;;
$MODKEY-Shift-l)
xwrite /ctl select next;;
- $MODKEY-Shift-p)
- xwrite /ctl pager;;
$MODKEY-Shift-[0-9])
xwrite /ctl select `echo $1 | sed 's/.*-//'`;;
$MODKEY-d)