commit 62c11d4a5ba93f90b28cd1f4cfe97363051b5208
parent ace9b63747b753f3c7885547db68f4bba4a712a6
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Thu, 19 Jan 2006 17:01:01 +0200
now applying float layout works as expected
Diffstat:
6 files changed, 62 insertions(+), 32 deletions(-)
diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c
@@ -74,9 +74,10 @@ win_to_frame(Window w)
Page *p;
for(p = pages; p; p = p->next) {
Frame *f;
- for(f = p->managed->def->frames(p->managed); f; f = f->next)
- if(f->win == w)
- return f;
+ if(p->managed->def)
+ for(f = p->managed->def->frames(p->managed); f; f = f->next)
+ if(f->win == w)
+ return f;
for(f = p->floating->def->frames(p->floating); f; f = f->next)
if(f->win == w)
return f;
@@ -320,6 +321,8 @@ handle_before_read_frames(IXPServer *s, File *file, Layout *l)
{
Frame *f;
char buf[32];
+ if(!l->def)
+ return nil;
for(f = l->def->frames(l); f; f = f->next) {
if(file == f->file[F_GEOMETRY]) {
snprintf(buf, sizeof(buf), "%d %d %d %d", f->rect.x, f->rect.y,
diff --git a/cmd/wm/layout.c b/cmd/wm/layout.c
@@ -18,27 +18,21 @@ alloc_layout(Page * p, char *layout)
Layout *l = (Layout *) cext_emallocz(sizeof(Layout));
l->page = p;
- if(strncmp(layout, "float", 6))
+ if(strncmp(layout, LAYOUT_FLOAT, strlen(LAYOUT_FLOAT) + 1))
name = "managed";
else
name = "float";
snprintf(buf, MAX_BUF, "/%s/layout/%s", p->file[P_PREFIX]->name, name);
l->file[L_PREFIX] = ixp_create(ixps, buf);
- snprintf(buf, MAX_BUF, "/%s/layout/%s/frame", p->file[P_PREFIX]->name,
- name);
+ snprintf(buf, MAX_BUF, "/%s/layout/%s/frame", p->file[P_PREFIX]->name, name);
l->file[L_FRAME_PREFIX] = ixp_create(ixps, buf);
snprintf(buf, MAX_BUF, "/%s/layout/%s/frame/sel",
p->file[P_PREFIX]->name, name);
l->file[L_SEL_FRAME] = ixp_create(ixps, buf);
l->file[L_SEL_FRAME]->bind = 1;
- snprintf(buf, MAX_BUF, "/%s/layout/%s/ctl", p->file[P_PREFIX]->name,
- name);
+ snprintf(buf, MAX_BUF, "/%s/layout/%s/ctl", p->file[P_PREFIX]->name, name);
l->file[L_CTL] = ixp_create(ixps, buf);
l->file[L_CTL]->after_write = handle_after_write_layout;
- snprintf(buf, MAX_BUF, "/%s/layout/%s/name", p->file[P_PREFIX]->name,
- name);
- l->file[L_NAME] = wmii_create_ixpfile(ixps, buf, layout);
- l->file[L_NAME]->after_write = handle_after_write_layout;
l->def = match_layout_def(layout);
l->def->init(l, nil);
p->file[P_SEL_LAYOUT]->content = l->file[L_PREFIX]->content;
@@ -69,6 +63,8 @@ void
unmap_layout(Layout *l)
{
Frame *f;
+ if(!l->def)
+ return;
for(f = l->def->frames(l); f; f = f->next)
XMoveWindow(dpy, f->win, 2 * rect.width, 2 * rect.height);
}
@@ -77,6 +73,8 @@ void
map_layout(Layout *l, Bool raise)
{
Frame *f;
+ if(!l->def)
+ return;
for(f = l->def->frames(l); f; f = f->next) {
XMoveWindow(dpy, f->win, f->rect.x, f->rect.y);
if(raise)
@@ -110,7 +108,7 @@ handle_after_write_layout(IXPServer * s, File * file)
{
Page *p;
for(p = pages; p; p = p->next) {
- if(file == p->managed->file[L_CTL]) {
+ if(p->managed && (file == p->managed->file[L_CTL])) {
run_action(file, p->managed,
p->managed->def->actions(p->managed));
return;
@@ -118,15 +116,7 @@ handle_after_write_layout(IXPServer * s, File * file)
run_action(file, p->floating,
p->floating->def->actions(p->floating));
return;
- } else if(file == p->managed->file[L_NAME]) {
- LayoutDef *l = match_layout_def(file->content);
- if(l) {
- Client *clients = p->managed->def->deinit(p->managed);
- p->managed->def = l;
- p->managed->def->init(p->managed, clients);
- invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
- }
- }
+ }
}
}
diff --git a/cmd/wm/page.c b/cmd/wm/page.c
@@ -38,10 +38,13 @@ alloc_page()
snprintf(buf, sizeof(buf), "/%d/layout/sel", pageid);
new->file[P_SEL_LAYOUT] = ixp_create(ixps, buf);
new->file[P_SEL_LAYOUT]->bind = 1; /* mount point */
+ snprintf(buf, MAX_BUF, "/%d/layoutname", pageid);
+ new->file[P_LAYOUT_NAME] = wmii_create_ixpfile(ixps, buf, def[WM_LAYOUT]->content);
+ new->file[P_LAYOUT_NAME]->after_write = handle_after_write_page;
snprintf(buf, sizeof(buf), "/%d/ctl", pageid);
new->file[P_CTL] = ixp_create(ixps, buf);
new->file[P_CTL]->after_write = handle_after_write_page;
- new->floating = alloc_layout(new, "float");
+ new->floating = alloc_layout(new, LAYOUT_FLOAT);
new->sel = new->managed = alloc_layout(new, def[WM_LAYOUT]->content);
for(p = pages; p && p->next; p = p->next);
if(!p) {
@@ -186,6 +189,31 @@ handle_after_write_page(IXPServer * s, File * file)
run_action(file, p, page_acttbl);
return;
}
+ else if(file == p->file[P_LAYOUT_NAME]) {
+ LayoutDef *l = match_layout_def(file->content);
+ Client *clients = nil;
+
+ if(!strncmp(file->content, LAYOUT_FLOAT, strlen(LAYOUT_FLOAT)))
+ l = nil;
+
+ if(p->managed->def)
+ clients = p->managed->def->deinit(p->managed);
+ p->managed->def = l;
+ if(l) {
+ p->managed->def->init(p->managed, clients);
+ focus_layout(p->managed);
+ }
+ else {
+ Client *n;
+ focus_layout(p->floating);
+ while(clients) {
+ n = clients->next;
+ p->floating->def->attach(p->floating, clients);
+ clients = n;
+ }
+ }
+ invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
+ }
}
}
@@ -215,6 +243,9 @@ toggle_layout(void *obj, char *arg)
else
p->sel = p->managed;
+ if(!p->sel->def)
+ p->sel = p->floating;
+
focus_layout(p->sel);
}
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -307,6 +307,10 @@ map_detached_clients()
XRectangle cr;
blitz_getbasegeometry(ndetached, &cols, &rows);
+ if(!cols)
+ cols = 1;
+ if(!rows)
+ rows = 1;
dx = (cols - 1) * GAP; /* GAPpx space */
dy = (rows - 1) * GAP; /* GAPpx space */
tw = (rect.width - dx) / cols;
@@ -459,11 +463,12 @@ win_to_client(Window w)
return c;
for(p = pages; p; p = p->next) {
Frame *f;
- for(f = p->managed->def->frames(p->managed); f; f = f->next) {
- for(c = f->clients; c; c = c->next)
- if(c->win == w)
- return c;
- }
+ if(p->managed->def)
+ for(f = p->managed->def->frames(p->managed); f; f = f->next) {
+ for(c = f->clients; c; c = c->next)
+ if(c->win == w)
+ return c;
+ }
for(f = p->floating->def->frames(p->floating); f; f = f->next) {
for(c = f->clients; c; c = c->next)
if(c->win == w)
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -14,6 +14,7 @@ enum {
P_NAME,
P_LAYOUT_PREFIX,
P_SEL_LAYOUT,
+ P_LAYOUT_NAME,
P_CTL,
P_LAST
};
@@ -24,7 +25,6 @@ enum {
L_FRAME_PREFIX,
L_SEL_FRAME,
L_CTL,
- L_NAME,
L_LAST
};
@@ -80,6 +80,7 @@ enum {
#define PROTO_DEL 1
#define BORDER_WIDTH 3
#define LAYOUT "column"
+#define LAYOUT_FLOAT "float"
#define GAP 5
#define ROOT_MASK SubstructureRedirectMask
diff --git a/rc/wmiirc b/rc/wmiirc
@@ -113,7 +113,7 @@ wmiir write /wm/event/clientupdate \
wmiir write /wm/event/pageupdate \
'wmiir write /bar/'^$plab^'/data `{wmiir read /wm/sel/name} &&' ^\
'wmiir write /bar/'^$klab^'/data `{wmiir read /keys/lookup|sed ''s|/mode/||''} && ' ^\
-'wmiir write /bar/'^$llab^'/data `{wmiir read /wm/sel/layout/sel/name}'
+'wmiir write /bar/'^$llab^'/data `{wmiir read /wm/sel/layoutname}'
for(page in `{wmiir read /wm | grep '^[0-9]'}) {
framesconf /wm/$page/layout/float/frame
@@ -162,9 +162,9 @@ 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-S-c 'wmiir write /wm/sel/layout/managed/name column'
+kbind normal $MODKEY-S-c 'wmiir write /wm/sel/layoutname column'
kbind normal $MODKEY-n 'wmiir write /wm/sel/layout/sel/ctl new'
-kbind normal $MODKEY-S-f 'wmiir write /wm/sel/layout/sel/name float'
+kbind normal $MODKEY-S-f 'wmiir write /wm/sel/layoutname float'
kbind normal $MODKEY-Return 'wmiir write /wm/sel/layout/sel/ctl ''swap west'''
kbind normal $MODKEY-S-Return 'wmiir write /wm/sel/layout/sel/ctl ''swap east'''
kbind normal $MODKEY-C-y 'wmiir write /wm/ctl new'