wmii

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

commit 9ced0cc2a5110e3d4e1fcc2072cd04dbd561a89d
parent 1d92df0536d2fff38455c33d054844733e3a3d07
Author: garbeam <garbeam@mmv.wmii.de>
Date:   Fri,  9 Dec 2005 18:02:03 +0200

added file after_write handler in areas, which allows to change the layout onthefly


Diffstat:
cmd/wm/area.c | 40++++++++++++++++++++++++++++++++++++++++
cmd/wm/frame.c | 9+++++----
cmd/wm/layout_column.c | 4++--
cmd/wm/layout_float.c | 2+-
cmd/wm/wm.c | 63+++++++++++++++++++++++++++++----------------------------------
cmd/wm/wm.h | 3++-
6 files changed, 79 insertions(+), 42 deletions(-)

diff --git a/cmd/wm/area.c b/cmd/wm/area.c @@ -9,6 +9,8 @@ #include "wm.h" +static void handle_after_write_area(IXPServer * s, File * f); + Area *alloc_area(Page *p, XRectangle * r, char *layout) { char buf[MAX_BUF]; @@ -26,13 +28,17 @@ Area *alloc_area(Page *p, XRectangle * r, char *layout) a->file[A_SEL_FRAME]->bind = 1; snprintf(buf, MAX_BUF, "/%s/layout/%d/ctl", p->file[P_PREFIX]->name, id); a->file[A_CTL] = ixp_create(ixps, buf); + a->file[A_CTL]->after_write = handle_after_write_area; snprintf(buf, MAX_BUF, "/%s/layout/%d/geometry", p->file[P_PREFIX]->name, id); a->file[A_GEOMETRY] = ixp_create(ixps, buf); + a->file[A_GEOMETRY]->after_write = handle_after_write_area; snprintf(buf, MAX_BUF, "/%s/layout/%d/name", p->file[P_PREFIX]->name, id); a->file[A_LAYOUT] = wmii_create_ixpfile(ixps, buf, layout); + a->file[A_LAYOUT]->after_write = handle_after_write_area; a->layout = get_layout(layout); a->layout->init(a); cext_attach_item(&p->areas, a); + cext_attach_item(&areas, a); p->file[P_SEL_AREA]->content = a->file[A_PREFIX]->content; return a; } @@ -44,6 +50,7 @@ void destroy_area(Area *a) while ((c = cext_stack_get_top_item(&a->clients))) cext_detach_item(&a->clients, c); ixp_remove_file(ixps, a->file[A_PREFIX]); + cext_detach_item(&areas, a); free(a); } @@ -108,3 +115,36 @@ void detach_frame_from_area(Frame *f) { f->area->file[A_SEL_FRAME]->content = 0; f->area = 0; } + +static void iter_after_write_area(void *item, void *aux) +{ + Area *a = item; + File *file = aux; + if (file == a->file[A_CTL]) { + /*run_action(file, f, frame_acttbl);*/ + return; + } + if (file == a->file[A_LAYOUT]) { + Layout *l = get_layout(file->content); + if (l) { + a->layout->deinit(a); + a->layout = l; + a->layout->init(a); + } + draw_page(a->page); + return; + } else if (file == a->file[A_GEOMETRY]) { + char *geom = a->file[A_GEOMETRY]->content; + if (geom && strrchr(geom, ',')) { + blitz_strtorect(&rect, &a->rect, geom); + a->layout->arrange(a); + draw_page(a->page); + } + return; + } +} + +static void handle_after_write_area(IXPServer *s, File *f) { + cext_list_iterate(&areas, f, iter_after_write_area); +} + diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c @@ -320,8 +320,9 @@ void attach_client_to_frame(Frame *f, Client *c) sel_client(c); } -void detach_client_from_frame(Frame *f, Client *c) +void detach_client_from_frame(Client *c) { + Frame *f = c->frame; Client *client; c->frame = nil; f->file[F_SEL_CLIENT]->content = nil; @@ -384,10 +385,10 @@ static void iter_after_write_frame(void *item, void *aux) draw_page(f->area->page); return; } else if (file == f->file[F_GEOMETRY]) { - char *size = f->file[F_GEOMETRY]->content; - if (size && strrchr(size, ',')) { + char *geom = f->file[F_GEOMETRY]->content; + if (geom && strrchr(geom, ',')) { XRectangle frect; - blitz_strtorect(&rect, &frect, size); + blitz_strtorect(&rect, &frect, geom); resize_frame(f, &frect, 0); draw_page(f->area->page); } diff --git a/cmd/wm/layout_column.c b/cmd/wm/layout_column.c @@ -156,7 +156,7 @@ static void init_col(Area *a) static void iter_detach_client(void *client, void *aux) { Client *c = client; - detach_client_from_frame(c->frame, c); + detach_client_from_frame(c); } static void iter_detach_frame(void *frame, void *aux) @@ -203,7 +203,7 @@ static void detach_col(Area *a, Client *c) cext_detach_item(&col->frames, f); col->refresh = 1; - detach_client_from_frame(f, c); + detach_client_from_frame(c); detach_frame_from_area(f); destroy_frame(f); diff --git a/cmd/wm/layout_float.c b/cmd/wm/layout_float.c @@ -81,7 +81,7 @@ static Bool attach_float(Area *a, Client *c) static void detach_float(Area *a, Client *c) { Frame *f = c->frame; - detach_client_from_frame(f, c); + detach_client_from_frame(c); if (!cext_sizeof(&f->clients)) { detach_frame_from_area(f); cext_detach_item((Container *)a->aux, f); diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -680,39 +680,6 @@ static void cleanup() XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); } -static void run() -{ - /* init */ - init_event_hander(); - - if (!(def[WM_CTL] = ixp_create(ixps, "/ctl"))) { - perror("wmiiwm: cannot connect IXP server"); - exit(1); - } - def[WM_CTL]->after_write = handle_after_write; - - detached.list = detached.stack = 0; - pages.list = pages.stack = 0; - frames.list = frames.stack = 0; - clients.list = clients.stack = 0; - layouts.list = layouts.stack = 0; - - init_atoms(); - init_cursors(); - init_default(); - font = blitz_getfont(dpy, def[WM_FONT]->content); - init_lock_modifiers(dpy, &valid_mask, &num_lock_mask); - init_screen(); - init_layouts(); - scan_wins(); - - /* main event loop */ - run_server_with_fd_support(ixps, ConnectionNumber(dpy), check_event, 0); - cleanup(); - deinit_server(ixps); - XCloseDisplay(dpy); -} - int main(int argc, char *argv[]) { int i; @@ -770,7 +737,35 @@ int main(int argc, char *argv[]) ixps = wmii_setup_server(sockfile); - run(); + init_event_hander(); + + if (!(def[WM_CTL] = ixp_create(ixps, "/ctl"))) { + perror("wmiiwm: cannot connect IXP server"); + exit(1); + } + def[WM_CTL]->after_write = handle_after_write; + + detached.list = detached.stack = 0; + pages.list = pages.stack = 0; + areas.list = areas.stack = 0; + frames.list = frames.stack = 0; + clients.list = clients.stack = 0; + layouts.list = layouts.stack = 0; + + init_atoms(); + init_cursors(); + init_default(); + font = blitz_getfont(dpy, def[WM_FONT]->content); + init_lock_modifiers(dpy, &valid_mask, &num_lock_mask); + init_screen(); + init_layouts(); + scan_wins(); + + /* main event loop */ + run_server_with_fd_support(ixps, ConnectionNumber(dpy), check_event, 0); + cleanup(); + deinit_server(ixps); + XCloseDisplay(dpy); return 0; } diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -170,6 +170,7 @@ Window transient; XRectangle rect; Container detached; Container pages; +Container areas; Container frames; Container clients; Container layouts; @@ -243,7 +244,7 @@ void resize_frame(Frame * f, XRectangle * r, XPoint * pt); void draw_frame(void *frame, void *aux); void handle_frame_buttonpress(XButtonEvent *e, Frame *f); void attach_client_to_frame(Frame *f, Client *c); -void detach_client_from_frame(Frame *f, Client *c); +void detach_client_from_frame(Client *c); unsigned int tab_height(Frame * f); unsigned int border_width(Frame * f); Frame *get_sel_frame();