commit a1c727693103446bdbd0e7ab16771b15d2e10509
parent 2313fd952dff5957f807af711e88df0c47a3c393
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Thu, 26 Jan 2006 20:58:30 +0200
proceeded further, adapted wmiirc as well
Diffstat:
7 files changed, 86 insertions(+), 109 deletions(-)
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -21,7 +21,7 @@ Action client_acttbl[] = {
{0, 0}
};
-void
+Client **
attach_client_to_array(Client *c, Client **array, size_t *size)
{
size_t i;
@@ -39,6 +39,7 @@ attach_client_to_array(Client *c, Client **array, size_t *size)
free(tmp);
}
array[i] = c;
+ return array;
}
void
@@ -113,6 +114,7 @@ alloc_client(Window w, XWindowAttributes *wa)
bw = border_width(c);
th = tab_height(c);
+ c->frame.rect = c->rect;
c->frame.rect.width += 2 * bw;
c->frame.rect.height += bw + (th ? th : bw);
c->frame.win = XCreateWindow(dpy, root, c->frame.rect.x, c->frame.rect.y,
@@ -124,7 +126,7 @@ alloc_client(Window w, XWindowAttributes *wa)
c->frame.gc = XCreateGC(dpy, c->frame.win, 0, 0);
XSync(dpy, False);
- attach_client_to_array(c, client, &clientsz);
+ client = attach_client_to_array(c, client, &clientsz);
return c;
}
@@ -148,9 +150,12 @@ focus_client(Client *c)
Client *old = sel_client();
/* setup indexes */
- if(c->page != p)
+ if(c->page != p) {
focus_page(c->page);
+ p = c->page;
+ }
p->is_column = c->column != nil;
+ p->file[P_SEL_PREFIX]->content = c->file[P_PREFIX]->content;
if(p->is_column) {
for(i = 0; (i < p->columnsz) && p->column[i]; i++) {
Column *col = p->column[i];
@@ -158,17 +163,14 @@ focus_client(Client *c)
if((j < col->clientsz) && col->client[j]) {
p->sel_column = i;
col->sel = j;
- p->file[P_SEL_COLUMN_CLIENT]->content = c->file[P_PREFIX]->content;
break;
}
}
}
else {
for(i = 0; (i < p->floatingsz) && p->floating[i] && (p->floating[i] != c); i++);
- if((i < p->floatingsz) && p->floating[i]) {
- p->file[P_SEL_FLOATING_CLIENT]->content = c->file[P_PREFIX]->content;
+ if((i < p->floatingsz) && p->floating[i])
p->sel_float = i;
- }
}
if(old && (old != c)) {
@@ -426,22 +428,20 @@ attach_client(Client *c)
{
Page *p;
if(!page)
- alloc_page();
- p = page[sel_page];
+ p = alloc_page();
+ else
+ p = page[sel_page];
- /* XXX: do we need */ resize_client(c, &c->rect, 0);
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_column) {
- wmii_move_ixpfile(c->file[C_PREFIX], p->file[P_COLUMN_PREFIX]);
+ if(p->is_column)
attach_column(c);
- }
- else {
- wmii_move_ixpfile(c->file[C_PREFIX], p->file[P_FLOATING_PREFIX]);
- attach_client_to_array(c, p->floating, &p->floatingsz);
- }
+ else
+ p->floating = attach_client_to_array(c, p->floating, &p->floatingsz);
map_client(c);
+ XMapWindow(dpy, c->frame.win);
focus_client(c);
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
@@ -457,7 +457,7 @@ detach_client(Client *c, Bool unmap)
detach_client_from_array(c, c->page->floating);
if(!c->destroyed) {
if(!unmap) {
- attach_client_to_array(c, detached, &detachedsz);
+ detached = attach_client_to_array(c, detached, &detachedsz);
unmap_client(c);
}
c->rect.x = c->frame.rect.x;
@@ -495,8 +495,7 @@ Client *
win_to_frame(Window w)
{
size_t i;
-
- for(i = 0; client && client[i]; i++)
+ for(i = 0; (i < clientsz) && client[i]; i++)
if(client[i]->frame.win == w)
return client[i];
return nil;
diff --git a/cmd/wm/column.c b/cmd/wm/column.c
@@ -8,7 +8,7 @@
#include "wm.h"
-static void
+static Column **
attach_column_to_array(Column *col, Column **array, size_t *size)
{
size_t i;
@@ -26,6 +26,7 @@ attach_column_to_array(Column *col, Column **array, size_t *size)
free(tmp);
}
array[i] = col;
+ return array;
}
static void
@@ -41,22 +42,22 @@ detach_column_from_array(Column *col, Column **array)
void
arrange_column(Page *p, Column *col)
{
- size_t i, nc;
+ size_t i;
unsigned int h;
- for(nc = 0; (nc < col->clientsz) && col->client[nc]; nc++);
+ for(i = 0; (i < col->clientsz) && col->client[i]; i++);
h = col->rect.height;
- if(nc)
- h /= nc;
+ if(i)
+ h /= i;
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;
- if(col->client[i + 1])
+ 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;
- else
- c->frame.rect.height = h;
resize_client(c, &c->frame.rect, 0);
}
}
@@ -78,12 +79,12 @@ attach_column(Client *c)
if(!col) {
col = cext_emallocz(sizeof(Column));
col->rect = p->rect_column;
- attach_column_to_array(col, p->column, &p->columnsz);
+ p->column = attach_column_to_array(col, p->column, &p->columnsz);
p->sel_column = 0;
}
c->column = col;
- attach_client_to_array(c, col->client, &col->clientsz);
+ col->client = attach_client_to_array(c, col->client, &col->clientsz);
arrange_column(p, col);
}
@@ -204,7 +205,7 @@ drop_moving(Client *c, XRectangle *new, XPoint * pt)
if(src->clientsz <= 1 || !src->client[1])
return;
detach_client_from_array(c, src->client);
- attach_client_to_array(c, tgt->client, &tgt->clientsz);
+ tgt->client = attach_client_to_array(c, tgt->client, &tgt->clientsz);
arrange_column(p, src);
arrange_column(p, tgt);
} else {
@@ -291,10 +292,10 @@ new_column(Page *p)
col = cext_emallocz(sizeof(Column));
col->rect = p->rect_column;
- attach_column_to_array(col, p->column, &p->columnsz);
+ p->column = attach_column_to_array(col, p->column, &p->columnsz);
p->sel_column = i;
detach_client_from_array(c, old->client);
- attach_client_to_array(c, col->client, &col->clientsz);
+ col->client = attach_client_to_array(c, col->client, &col->clientsz);
c->column = col;
update_column_width(p);
focus_client(c);
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -61,7 +61,7 @@ handle_buttonpress(XEvent * e)
Align align;
int bindex;
- if((c == win_to_frame(ev->window))) {
+ if((c = win_to_frame(ev->window))) {
focus_client(c);
if(ev->button == Button1) {
align = cursor_to_align(c->frame.cursor);
diff --git a/cmd/wm/page.c b/cmd/wm/page.c
@@ -28,7 +28,7 @@ Action page_acttbl[] = {
{0, 0}
};
-void
+Page **
attach_page_to_array(Page *p, Page **array, size_t *size)
{
size_t i;
@@ -46,6 +46,7 @@ attach_page_to_array(Page *p, Page **array, size_t *size)
free(tmp);
}
array[i] = p;
+ return array;
}
void
@@ -61,42 +62,35 @@ detach_page_from_array(Page *p, Page **array)
Page *
alloc_page()
{
- Page *p, *new = cext_emallocz(sizeof(Page));
+ Page *p = cext_emallocz(sizeof(Page));
char buf[MAX_BUF], buf2[16];
static int id = 1;
size_t np;
snprintf(buf2, sizeof(buf2), "%d", id);
snprintf(buf, sizeof(buf), "/%d", id);
- new->file[P_PREFIX] = ixp_create(ixps, buf);
+ p->file[P_PREFIX] = ixp_create(ixps, buf);
snprintf(buf, sizeof(buf), "/%d/name", id);
- new->file[P_NAME] = wmii_create_ixpfile(ixps, buf, buf2);
- snprintf(buf, sizeof(buf), "/%d/floating/", id);
- new->file[P_FLOATING_PREFIX] = ixp_create(ixps, buf);
- snprintf(buf, sizeof(buf), "/%d/column/", id);
- new->file[P_COLUMN_PREFIX] = ixp_create(ixps, buf);
- snprintf(buf, sizeof(buf), "/%d/sel/", id);
- new->file[P_SEL_PREFIX] = ixp_create(ixps, buf);
- new->file[P_SEL_PREFIX]->bind = 1; /* mount point */
- snprintf(buf, sizeof(buf), "/%d/floating/sel", id);
- new->file[P_SEL_FLOATING_CLIENT] = ixp_create(ixps, buf);
- new->file[P_SEL_FLOATING_CLIENT]->bind = 1;
- snprintf(buf, sizeof(buf), "/%d/column/sel", id);
- new->file[P_SEL_COLUMN_CLIENT] = ixp_create(ixps, buf);
- new->file[P_SEL_COLUMN_CLIENT]->bind = 1;
+ 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);
- new->file[P_CTL] = ixp_create(ixps, buf);
- new->file[P_CTL]->after_write = handle_after_write_page;
- def[WM_SEL_PAGE]->content = new->file[P_PREFIX]->content;
+ 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_column = rect;
- attach_page_to_array(p, page, &pagesz);
+ page = attach_page_to_array(p, page, &pagesz);
for(np = 0; (np < pagesz) && page[np]; np++);
- focus_page(new);
+ focus_page(p);
XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL,
32, PropModeReplace, (unsigned char *) &np, 1);
- return new;
+ p->is_column = True;
+ return p;
}
void
@@ -140,31 +134,25 @@ destroy_page(Page *p)
void
focus_page(Page *p)
{
- unsigned int i, j;
+ size_t i;
Page *old = page ? page[sel_page] : nil;
if(!page)
return;
- for(i = 0; (i < pagesz) && page[i]; i++);
-
+ for(i = 0; (i < pagesz) && page[i] && (page[i] != p); i++);
if(i == sel_page)
return;
sel_page = i;
- for(j = 0; (j < clientsz) && client[j]; j++) {
- if(client[j]->page == old)
- XMoveWindow(dpy, client[j]->frame.win, 2 * rect.width, 2 * rect.height);
- else if(client[j]->page == p)
- XMoveWindow(dpy, client[j]->frame.win,
- client[j]->frame.rect.x, client[j]->frame.rect.y);
+ for(i = 0; (i < clientsz) && client[i]; 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;
- if(p->is_column)
- p->file[P_SEL_PREFIX]->content = p->file[P_COLUMN_PREFIX]->content;
- else
- p->file[P_SEL_PREFIX]->content = p->file[P_FLOATING_PREFIX]->content;
-
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
XChangeProperty(dpy, root, net_atoms[NET_CURRENT_DESKTOP], XA_CARDINAL,
32, PropModeReplace, (unsigned char *) &sel_page, 1);
@@ -217,7 +205,7 @@ handle_after_write_page(IXPServer *s, File *file)
static void
xexec(void *obj, char *arg)
{
- attach_page_to_array(obj, aqueue, &aqueuesz);
+ aqueue = attach_page_to_array(obj, aqueue, &aqueuesz);
wmii_spawn(dpy, arg);
}
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -458,7 +458,7 @@ win_to_client(Window w)
{
size_t i;
- for(i = 0; client && client[i]; i++)
+ for(i = 0; (i < clientsz) && client[i]; i++)
if(client[i]->win == w)
return client[i];
return nil;
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -13,11 +13,8 @@
enum {
P_PREFIX,
P_NAME,
- P_COLUMN_PREFIX,
- P_FLOATING_PREFIX,
+ P_CLIENT_PREFIX,
P_SEL_PREFIX,
- P_SEL_COLUMN_CLIENT,
- P_SEL_FLOATING_CLIENT,
P_CTL,
P_LAST
};
@@ -175,7 +172,7 @@ unsigned int valid_mask, num_lock_mask;
/* client.c */
-void attach_client_to_array(Client *c, Client **array, size_t *size);
+Client **attach_client_to_array(Client *c, Client **array, size_t *size);
void detach_client_from_array(Client *c, Client **array);
Client *alloc_client(Window w, XWindowAttributes *wa);
void destroy_client(Client * c);
@@ -212,7 +209,7 @@ Align xy_to_align(XRectangle * rect, int x, int y);
void drop_move(Client *c, XRectangle *new, XPoint *pt);
/* page.c */
-void attach_page_to_array(Page *p, Page **array, size_t *size);
+Page **attach_page_to_array(Page *p, Page **array, size_t *size);
void detach_page_from_array(Page *p, Page **array);
Page *alloc_page();
void destroy_page(Page *p);
diff --git a/rc/wmiirc b/rc/wmiirc
@@ -52,11 +52,11 @@ fn items {
} | sort | wmiir -f &
}
-fn framesconf {
- for(frame in `{wmiir read $1 | grep '^[0-9]'}) {
- wmiir write $1/$frame/tab $TAB
- wmiir write $1/$frame/handleinc $HANDLEINC
- wmiir write $1/$frame/geometry '+0 +0 +0 +0' # causes refresh
+fn clientsconf {
+ for(client in `{wmiir read $1 | grep '^[0-9]'}) {
+ wmiir write $1/$client/tab $TAB
+ wmiir write $1/$client/handleinc $HANDLEINC
+ wmiir write $1/$client/geometry '+0 +0 +0 +0' # causes refresh
}
}
@@ -88,9 +88,6 @@ wmiir write /bar/bordercolor $NORM_BORDER_COLOR
plab=`{wmiir read /bar/new}
wmiir write /bar/$plab/b1press 'wmiir write /wm/ctl pager'
-llab=`{wmiir read /bar/new}
-wmiir write /bar/$llab/b1press 'wmiir write /wm/ctl pager'
-
klab=`{wmiir read /bar/new}
clab=`{wmiir read /bar/new}
@@ -116,13 +113,10 @@ wmiir write /wm/event/clientupdate \
'wmiir write /bar/'^$clab^'/data $"s'
wmiir write /wm/event/pageupdate \
's=`{wmiir read /wm/sel/name} wmiir write /bar/'$plab'/data $"s && ' ^\
-'s=`{wmiir read /keys/lookup | sed s,/mode/,,} wmiir write /bar/'$klab'/data $"s && ' ^\
-'s=`{wmiir read /wm/sel/layoutname} wmiir write /bar/'$llab'/data $"s'
+'s=`{wmiir read /keys/lookup | sed s,/mode/,,} wmiir write /bar/'$klab'/data $"s'
-for(page in `{wmiir read /wm | grep '^[0-9]'}) {
- framesconf /wm/$page/layout/float/frame
- framesconf /wm/$page/layout/managed/frame
-}
+for(page in `{wmiir read /wm | grep '^[0-9]'})
+ clientsconf /wm/$page/client
wmiir write /wm/default/sstyle/fgcolor $SEL_FG_COLOR
wmiir write /wm/default/sstyle/bgcolor $SEL_BG_COLOR
@@ -139,21 +133,21 @@ kbind bare $MODKEY-Escape 'kmode normal'
kbind move Escape 'kmode normal'
kbind move $MODKEY-C-r 'kmode resize'
-kbind move $NORTHKEY 'wmiir write /wm/sel/sel/sel/geometry ''-0 -30 -0 -0'''
-kbind move $SOUTHKEY 'wmiir write /wm/sel/sel/sel/geometry ''+0 +30 +0 +0'''
-kbind move $WESTKEY 'wmiir write /wm/sel/sel/sel/geometry ''-40 -0 -0 -0'''
-kbind move $EASTKEY 'wmiir write /wm/sel/sel/sel/geometry ''+40 +0 +0 +0'''
-kbind move S-$NORTHKEY 'wmiir write /wm/sel/sel/sel/geometry ''-0 north -0 -0'''
-kbind move S-$SOUTHKEY 'wmiir write /wm/sel/sel/sel/geometry ''+0 south +0 +0'''
-kbind move S-$WESTKEY 'wmiir write /wm/sel/sel/sel/geometry ''west -0 -0 -0'''
-kbind move S-$EASTKEY 'wmiir write /wm/sel/sel/sel/geometry ''east +0 +0 +0'''
+kbind move $NORTHKEY 'wmiir write /wm/sel/client/sel/geometry ''-0 -30 -0 -0'''
+kbind move $SOUTHKEY 'wmiir write /wm/sel/client/sel/geometry ''+0 +30 +0 +0'''
+kbind move $WESTKEY 'wmiir write /wm/sel/client/sel/geometry ''-40 -0 -0 -0'''
+kbind move $EASTKEY 'wmiir write /wm/sel/client/sel/geometry ''+40 +0 +0 +0'''
+kbind move S-$NORTHKEY 'wmiir write /wm/sel/client/sel/geometry ''-0 north -0 -0'''
+kbind move S-$SOUTHKEY 'wmiir write /wm/sel/client/sel/geometry ''+0 south +0 +0'''
+kbind move S-$WESTKEY 'wmiir write /wm/sel/client/sel/geometry ''west -0 -0 -0'''
+kbind move S-$EASTKEY 'wmiir write /wm/sel/client/sel/geometry ''east +0 +0 +0'''
kbind resize Escape 'kmode normal'
kbind resize $MODKEY-C-m 'kmode move'
-kbind resize $NORTHKEY 'wmiir write /wm/sel/sel/sel/geometry ''+0 +0 +0 -30'''
-kbind resize $SOUTHKEY 'wmiir write /wm/sel/sel/sel/geometry ''+0 +0 +0 +30'''
-kbind resize $WESTKEY 'wmiir write /wm/sel/sel/sel/geometry ''+0 +0 -40 +0'''
-kbind resize $EASTKEY 'wmiir write /wm/sel/sel/sel/geometry ''+0 +0 +40 +0'''
+kbind resize $NORTHKEY 'wmiir write /wm/sel/client/sel/geometry ''+0 +0 +0 -30'''
+kbind resize $SOUTHKEY 'wmiir write /wm/sel/client/sel/geometry ''+0 +0 +0 +30'''
+kbind resize $WESTKEY 'wmiir write /wm/sel/client/sel/geometry ''+0 +0 -40 +0'''
+kbind resize $EASTKEY 'wmiir write /wm/sel/client/sel/geometry ''+0 +0 +40 +0'''
kbind normal $MODKEY-C-b 'kmode bare'
kbind normal $MODKEY-C-m 'kmode move'
@@ -167,8 +161,8 @@ kbind normal $MODKEY-t 'extern xterm ''+sb'' -bg ''#000000'' -fg ''#ffffff'' -cr
kbind normal $MODKEY-d 'wmiir write /wm/ctl detach'
kbind normal $MODKEY-a 'wmiir write /wm/ctl attach'
kbind normal $MODKEY-S-a 'wmiir write /wm/ctl detclients'
-kbind normal $MODKEY-n 'wmiir write /wm/sel/ctl new'
-kbind normal $MODKEY-m 'wmiir write /wm/sel/sel/sel/ctl max'
+kbind normal $MODKEY-n 'wmiir write /wm/sel/ctl newcol'
+kbind normal $MODKEY-m 'wmiir write /wm/sel/client/sel/ctl max'
kbind normal $MODKEY-Return 'wmiir write /wm/sel/ctl ''swap west'''
kbind normal $MODKEY-S-Return 'wmiir write /wm/sel/ctl ''swap east'''
kbind normal $MODKEY-C-y 'wmiir write /wm/ctl new'
@@ -189,7 +183,6 @@ wmiir write /keys/box/font $FONT
selstyle /keys/box
kmode normal
-
# WMIIMENU CONFIGURATION
wmiir write /menu/geometry $BAR_ALIGN
items actions $WMII_CONFDIR:$HOME/.wmii-3
@@ -199,7 +192,6 @@ wmiir write /menu/font $FONT
normstyle /menu/nstyle >[2]/dev/null
selstyle /menu/sstyle >[2]/dev/null
-
# MISC
xsetroot -solid black
status&