wmii

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

commit 829191aa19e29012c8550be4a03b8fe888dd8535
parent ca60ffdf74818462352e0b710ff2435cf9f29dae
Author: garbeam <garbeam@localhost>
Date:   Thu, 12 Jan 2006 17:06:50 +0200

renamed Area to Layout


Diffstat:
cmd/wm/Makefile.wm | 2+-
cmd/wm/area.c | 130-------------------------------------------------------------------------------
cmd/wm/client.c | 15+++++++--------
cmd/wm/event.c | 12++++++------
cmd/wm/frame.c | 26+++++++++++++-------------
cmd/wm/layout.c | 126+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
cmd/wm/layout_column.c | 134++++++++++++++++++++++++++++++++++++++++----------------------------------------
cmd/wm/layout_float.c | 86++++++++++++++++++++++++++++++++++++++++----------------------------------------
cmd/wm/page.c | 26+++++++++++++-------------
cmd/wm/wm.c | 62+++++++++++++++++++++++++-------------------------------------
cmd/wm/wm.h | 73++++++++++++++++++++++++++++++++++++-------------------------------------
11 files changed, 335 insertions(+), 357 deletions(-)

diff --git a/cmd/wm/Makefile.wm b/cmd/wm/Makefile.wm @@ -8,7 +8,7 @@ CFLAGS += -I../../liblitz -I../../libixp -I../../libwmii \ LDFLAGS += -L../../liblitz -llitz -L../../libixp -lixp \ -L../../libwmii -lwmii -L../../libcext -lcext -SRC = wm.c client.c event.c mouse.c frame.c area.c page.c layoutdef.c layout.c +SRC = wm.c client.c event.c mouse.c frame.c page.c layoutdef.c layout.c include layoutdef.mk diff --git a/cmd/wm/area.c b/cmd/wm/area.c @@ -1,130 +0,0 @@ -/* - * (C)opyright MMIV-MMV Anselm R. Garbe <garbeam at gmail dot com> - * See LICENSE file for license details. - */ - -#include <assert.h> -#include <stdlib.h> -#include <string.h> - -#include "wm.h" - -static void handle_after_write_area(IXPServer * s, File * file); - -Area * -alloc_area(Page * p, char *layout) -{ - char buf[MAX_BUF], *name; - Area *a = (Area *) cext_emallocz(sizeof(Area)); - - a->page = p; - if(strncmp(layout, "float", 6)) - name = "managed"; - else - name = "float"; - snprintf(buf, MAX_BUF, "/%s/layout/%s", p->file[P_PREFIX]->name, name); - a->file[A_PREFIX] = ixp_create(ixps, buf); - snprintf(buf, MAX_BUF, "/%s/layout/%s/frame", p->file[P_PREFIX]->name, - name); - a->file[A_FRAME_PREFIX] = ixp_create(ixps, buf); - snprintf(buf, MAX_BUF, "/%s/layout/%s/frame/sel", - p->file[P_PREFIX]->name, name); - a->file[A_SEL_FRAME] = ixp_create(ixps, buf); - a->file[A_SEL_FRAME]->bind = 1; - snprintf(buf, MAX_BUF, "/%s/layout/%s/ctl", p->file[P_PREFIX]->name, - name); - a->file[A_CTL] = ixp_create(ixps, buf); - a->file[A_CTL]->after_write = handle_after_write_area; - snprintf(buf, MAX_BUF, "/%s/layout/%s/name", p->file[P_PREFIX]->name, - name); - a->file[A_LAYOUT] = wmii_create_ixpfile(ixps, buf, layout); - a->file[A_LAYOUT]->after_write = handle_after_write_area; - a->layout = match_layout(layout); - a->layout->init(a, nil); - p->file[P_SEL_AREA]->content = a->file[A_PREFIX]->content; - return a; -} - -void -destroy_area(Area * a) -{ - a->layout->deinit(a); - ixp_remove_file(ixps, a->file[A_PREFIX]); - free(a); -} - -void -focus_area(Area * a) -{ - Page *p = a->page; - Frame *f; - p->sel = a; - p->file[P_SEL_AREA]->content = a->file[A_PREFIX]->content; - if((f = a->layout->sel(a))) - a->layout->focus(f, False); -} - -void -hide_area(Area * a) -{ - Frame *f; - for(f = a->layout->frames(a); f; f = f->next) - XMoveWindow(dpy, f->win, 2 * rect.width, 2 * rect.height); -} - -void -show_area(Area * a, Bool raise) -{ - Frame *f; - for(f = a->layout->frames(a); f; f = f->next) { - XMoveWindow(dpy, f->win, f->rect.x, f->rect.y); - if(raise) - XRaiseWindow(dpy, f->win); - } -} - -Area * -sel_area() -{ - return selpage ? selpage->sel : nil; -} - -void -attach_frame_to_area(Area * a, Frame * f) -{ - wmii_move_ixpfile(f->file[F_PREFIX], a->file[A_FRAME_PREFIX]); - a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content; - f->area = a; -} - -void -detach_frame_from_area(Frame * f) -{ - f->area->file[A_SEL_FRAME]->content = 0; - f->area = 0; -} - -static void -handle_after_write_area(IXPServer * s, File * file) -{ - Page *p; - for(p = pages; p; p = p->next) { - if(file == p->managed->file[A_CTL]) { - run_action(file, p->managed, - p->managed->layout->actions(p->managed)); - return; - } else if(file == p->floating->file[A_CTL]) { - run_action(file, p->floating, - p->floating->layout->actions(p->floating)); - return; - } else if(file == p->managed->file[A_LAYOUT]) { - Layout *l = match_layout(file->content); - if(l) { - Client *clients = p->managed->layout->deinit(p->managed); - p->managed->layout = l; - p->managed->layout->init(p->managed, clients); - invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]); - } - } - } -} diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -324,19 +324,19 @@ gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert) void attach_client(Client * c) { - Area *a = 0; + Layout *l = 0; Page *p = selpage; if(!p) p = alloc_page(); /* transient stuff */ - a = p->sel; + l = p->sel; if(c && c->trans) { Client *t = win_to_client(c->trans); if(t && t->frame) - a = p->floating; + l = p->floating; } - a->layout->attach(a, c); + l->def->attach(l, c); invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]); } @@ -344,10 +344,9 @@ void detach_client(Client * c, Bool unmap) { Frame *f = c->frame; - Area *a = f ? f->area : nil; - if(a) { - a->layout->detach(a, c, unmap); - } + Layout *l = f ? f->layout : nil; + if(l) + l->def->detach(l, c, unmap); if(c->destroyed) destroy_client(c); if(selpage) diff --git a/cmd/wm/event.c b/cmd/wm/event.c @@ -64,9 +64,9 @@ handle_buttonpress(XEvent * e) handle_frame_buttonpress(ev, f); else if((c = win_to_client(ev->window))) { if(c->frame) { /* client is attached */ - focus_area(c->frame->area); + focus_layout(c->frame->layout); focus_client(c); - c->frame->area->layout->focus(c->frame, False); + c->frame->layout->def->focus(c->frame, False); ev->state &= valid_mask; if(ev->state & Mod1Mask) { Align align; @@ -107,10 +107,10 @@ handle_configurerequest(XEvent * e) f = c->frame; if(f) { - Page *p = f->area->page; - if(f->area == p->managed) { - f->area->layout->detach(f->area, c, False); - p->floating->layout->attach(p->floating, c); + Page *p = f->layout->page; + if(f->layout == p->managed) { + f->layout->def->detach(f->layout, c, False); + p->floating->def->attach(p->floating, c); f = c->frame; } bw = border_width(f); diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c @@ -75,10 +75,10 @@ win_to_frame(Window w) Page *p; for(p = pages; p; p = p->next) { Frame *f; - for(f = p->managed->layout->frames(p->managed); f; f = f->next) + for(f = p->managed->def->frames(p->managed); f; f = f->next) if(f->win == w) return f; - for(f = p->floating->layout->frames(p->floating); f; f = f->next) + for(f = p->floating->def->frames(p->floating); f; f = f->next) if(f->win == w) return f; } @@ -165,12 +165,12 @@ resize_incremental(Frame * f, unsigned int tabh, unsigned int bw) void resize_frame(Frame * f, XRectangle * r, XPoint * pt) { - Area *a = f->area; + Layout *l = f->layout; unsigned int tabh = tab_height(f); unsigned int bw = border_width(f); Client *c; - a->layout->resize(f, r, pt); + l->def->resize(f, r, pt); /* resize if client requests special size */ check_dimensions(f, tabh, bw); @@ -260,7 +260,7 @@ handle_frame_buttonpress(XButtonEvent * e, Frame * f) Align align; int bindex, cindex = e->x / (f->rect.width / f->nclients); Client *new = clientat(f->clients, cindex); - f->area->layout->focus(f, False); + f->layout->def->focus(f, False); sel_client(new); if(e->button == Button1) { align = cursor_to_align(f->cursor); @@ -330,11 +330,11 @@ detach_client_from_frame(Client * c, Bool unmap) } static Frame * -handle_before_read_frames(IXPServer * s, File * file, Area * a) +handle_before_read_frames(IXPServer *s, File *file, Layout *l) { Frame *f; char buf[32]; - for(f = a->layout->frames(a); f; f = f->next) { + 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, f->rect.width, f->rect.height); @@ -373,13 +373,13 @@ handle_before_read_frame(IXPServer * s, File * file) } static Frame * -handle_after_write_frames(IXPServer * s, File * file, Area * a) +handle_after_write_frames(IXPServer *s, File *file, Layout *l) { Frame *f; - for(f = a->layout->frames(a); f; f = f->next) { + for(f = l->def->frames(l); f; f = f->next) { if(file == f->file[F_TAB] || file == f->file[F_BORDER] || file == f->file[F_HANDLE_INC]) { - f->area->layout->arrange(f->area); + f->layout->def->arrange(f->layout); return f; } else if(file == f->file[F_GEOMETRY]) { char *geom = f->file[F_GEOMETRY]->content; @@ -408,8 +408,8 @@ handle_after_write_frame(IXPServer * s, File * file) Frame * sel_frame() { - Area *a = sel_area(); - if(!a) + Layout *l = sel_layout(); + if(!l) return nil; - return a->layout->sel(a); + return l->def->sel(l); } diff --git a/cmd/wm/layout.c b/cmd/wm/layout.c @@ -3,14 +3,136 @@ * See LICENSE file for license details. */ +#include <assert.h> +#include <stdlib.h> #include <string.h> #include "wm.h" +static void handle_after_write_layout(IXPServer * s, File * file); + +Layout * +alloc_layout(Page * p, char *layout) +{ + char buf[MAX_BUF], *name; + Layout *l = (Layout *) cext_emallocz(sizeof(Layout)); + + l->page = p; + if(strncmp(layout, "float", 6)) + 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); + 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); + 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_AREA]->content = l->file[L_PREFIX]->content; + return l; +} + +void +destroy_layout(Layout *l) +{ + l->def->deinit(l); + ixp_remove_file(ixps, l->file[L_PREFIX]); + free(l); +} + +void +focus_layout(Layout *l) +{ + Page *p = l->page; + Frame *f; + p->sel = l; + p->file[P_SEL_AREA]->content = l->file[L_PREFIX]->content; + if((f = l->def->sel(l))) + l->def->focus(f, False); +} + +void +hide_layout(Layout *l) +{ + Frame *f; + for(f = l->def->frames(l); f; f = f->next) + XMoveWindow(dpy, f->win, 2 * rect.width, 2 * rect.height); +} + +void +show_layout(Layout *l, Bool raise) +{ + Frame *f; + for(f = l->def->frames(l); f; f = f->next) { + XMoveWindow(dpy, f->win, f->rect.x, f->rect.y); + if(raise) + XRaiseWindow(dpy, f->win); + } +} + Layout * -match_layout(char *name) +sel_layout() +{ + return selpage ? selpage->sel : nil; +} + +void +attach_frame_to_layout(Layout *l, Frame * f) +{ + wmii_move_ixpfile(f->file[F_PREFIX], l->file[L_FRAME_PREFIX]); + l->file[L_SEL_FRAME]->content = f->file[F_PREFIX]->content; + f->layout = l; +} + +void +detach_frame_from_layout(Frame * f) +{ + f->layout->file[L_SEL_FRAME]->content = 0; + f->layout = 0; +} + +static void +handle_after_write_layout(IXPServer * s, File * file) +{ + Page *p; + for(p = pages; p; p = p->next) { + if(file == p->managed->file[L_CTL]) { + run_action(file, p->managed, + p->managed->def->actions(p->managed)); + return; + } else if(file == p->floating->file[L_CTL]) { + 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]); + } + } + } +} + +LayoutDef * +match_layout_def(char *name) { - Layout *l; + LayoutDef *l; for(l = layouts; l; l = l->next) if(!strncmp(name, l->name, strlen(l->name))) return l; diff --git a/cmd/wm/layout_column.c b/cmd/wm/layout_column.c @@ -39,16 +39,16 @@ struct Column { Column *next; }; -static void init_col(Area * a, Client * clients); -static Client *deinit_col(Area * a); -static void arrange_col(Area * a); -static Bool attach_col(Area * a, Client * c); -static void detach_col(Area * a, Client * c, Bool unmap); +static void init_col(Layout *l, Client * clients); +static Client *deinit_col(Layout *l); +static void arrange_col(Layout *l); +static Bool attach_col(Layout *l, Client * c); +static void detach_col(Layout *l, Client * c, Bool unmap); static void resize_col(Frame * f, XRectangle * new, XPoint * pt); static void focus_col(Frame * f, Bool raise); -static Frame *frames_col(Area * a); -static Frame *sel_col(Area * a); -static Action *actions_col(Area * a); +static Frame *frames_col(Layout *l); +static Frame *sel_col(Layout *l); +static Action *actions_col(Layout *l); static void select_frame(void *obj, char *arg); static void swap_frame(void *obj, char *arg); @@ -66,7 +66,7 @@ static Action lcol_acttbl[] = { void init_layout_column() { - Layout *lp, *l = cext_emallocz(sizeof(Layout)); + LayoutDef *lp, *l = cext_emallocz(sizeof(LayoutDef)); l->name = "column"; l->init = init_col; l->deinit = deinit_col; @@ -90,13 +90,13 @@ static void arrange_column(Column * col) { Cell *cell; - unsigned int i = 0, h = area_rect.height / col->ncells; + unsigned int i = 0, h = layout_rect.height / col->ncells; for(cell = col->cells; cell; cell = cell->next) { Frame *f = cell->frame; f->rect = col->rect; - f->rect.y = area_rect.y + i * h; + f->rect.y = layout_rect.y + i * h; if(!cell->next) - f->rect.height = area_rect.height - f->rect.y + area_rect.y; + f->rect.height = layout_rect.height - f->rect.y + layout_rect.y; else f->rect.height = h; resize_frame(f, &f->rect, 0); @@ -105,9 +105,9 @@ arrange_column(Column * col) } static void -arrange_col(Area * a) +arrange_col(Layout *l) { - Acme *acme = a->aux; + Acme *acme = l->aux; Column *col; for(col = acme->columns; col; col = col->next) arrange_column(col); @@ -115,22 +115,22 @@ arrange_col(Area * a) } static void -init_col(Area * a, Client * clients) +init_col(Layout *l, Client * clients) { Client *n, *c = clients; - a->aux = cext_emallocz(sizeof(Acme)); + l->aux = cext_emallocz(sizeof(Acme)); while(c) { n = c->next; - attach_col(a, c); + attach_col(l, c); c = n; } } static void -attach_frame(Area * a, Column * col, Frame * new) +attach_frame(Layout *l, Column * col, Frame * new) { - Acme *acme = a->aux; + Acme *acme = l->aux; Cell *c, *cell = cext_emallocz(sizeof(Cell)); Frame *f; @@ -154,14 +154,14 @@ attach_frame(Area * a, Column * col, Frame * new) f->next = new; new->prev = f; } - attach_frame_to_area(a, new); + attach_frame_to_layout(l, new); acme->nframes++; } static void -detach_frame(Area * a, Frame * old) +detach_frame(Layout *l, Frame * old) { - Acme *acme = a->aux; + Acme *acme = l->aux; Cell *cell = old->aux; Column *col = cell->col; @@ -189,14 +189,14 @@ detach_frame(Area * a, Frame * old) if(old->next) old->next->prev = old->prev; old->aux = nil; - detach_frame_from_area(old); + detach_frame_from_layout(old); acme->nframes--; } static Client * -deinit_col(Area * a) +deinit_col(Layout *l) { - Acme *acme = a->aux; + Acme *acme = l->aux; Frame *f; Client *cl, *res = nil, *c = nil; Column *col = acme->columns; @@ -213,7 +213,7 @@ deinit_col(Area * a) c = cl; } } - detach_frame(a, f); + detach_frame(l, f); destroy_frame(f); } while((col = acme->columns)) { @@ -221,21 +221,21 @@ deinit_col(Area * a) free(col); } free(acme); - a->aux = 0; + l->aux = 0; return res; } static Bool -attach_col(Area * a, Client * c) +attach_col(Layout *l, Client * c) { - Acme *acme = a->aux; + Acme *acme = l->aux; Column *col = acme->sel; Frame *f = nil; if(!col) { col = cext_emallocz(sizeof(Column)); col->exclusive = True; /* first col is exclusive */ - col->rect = area_rect; + col->rect = layout_rect; acme->columns = acme->sel = col; acme->ncolumns++; } @@ -246,48 +246,48 @@ attach_col(Area * a, Client * c) } f = alloc_frame(&c->rect); - attach_frame(a, col, f); + attach_frame(l, col, f); attach_client_to_frame(f, c); arrange_column(col); - if(a->page == selpage) + if(l->page == selpage) XMapWindow(dpy, f->win); focus_col(f, True); if(col->exclusive && col->ncells > 1) - new_col(a, nil); + new_col(l, nil); return True; } static void -update_column_width(Area * a) +update_column_width(Layout *l) { - Acme *acme = a->aux; + Acme *acme = l->aux; unsigned int i = 0, width; Column *col; if(!acme->ncolumns) return; - width = area_rect.width / acme->ncolumns; + width = layout_rect.width / acme->ncolumns; for(col = acme->columns; col; col = col->next) { - col->rect = area_rect; + col->rect = layout_rect; col->rect.x = i * width; col->rect.width = width; i++; } - arrange_col(a); + arrange_col(l); } static void -detach_col(Area * a, Client * c, Bool unmap) +detach_col(Layout *l, Client * c, Bool unmap) { - Acme *acme = a->aux; + Acme *acme = l->aux; Frame *f = c->frame; Cell *cell = f->aux; Column *col = cell->col; detach_client_from_frame(c, unmap); if(!f->clients) { - detach_frame(a, f); + detach_frame(l, f); destroy_frame(f); } else return; @@ -310,7 +310,7 @@ detach_col(Area * a, Client * c, Bool unmap) acme->sel = acme->columns; acme->ncolumns--; free(col); - update_column_width(a); + update_column_width(l); } } @@ -378,10 +378,10 @@ drop_resize(Frame * f, XRectangle * new) static void drop_moving(Frame * f, XRectangle * new, XPoint * pt) { - Area *a = f->area; + Layout *l = f->layout; Cell *cell = f->aux; Column *src = cell->col, *tgt = 0; - Acme *acme = a->aux; + Acme *acme = l->aux; if(!pt) return; @@ -393,8 +393,8 @@ drop_moving(Frame * f, XRectangle * new, XPoint * pt) if(tgt != src) { if(src->ncells < 2) return; - detach_frame(a, f); - attach_frame(a, tgt, f); + detach_frame(l, f); + attach_frame(l, tgt, f); arrange_column(src); arrange_column(tgt); focus_col(f, True); @@ -427,14 +427,14 @@ resize_col(Frame * f, XRectangle * new, XPoint * pt) static void focus_col(Frame * f, Bool raise) { - Area *a = f->area; - Acme *acme = a->aux; - Frame *old = sel_col(a); + Layout *l = f->layout; + Acme *acme = l->aux; + Frame *old = sel_col(l); Cell *cell = f->aux; acme->sel = cell->col; cell->col->sel = cell; - a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content; + l->file[L_SEL_FRAME]->content = f->file[F_PREFIX]->content; if(raise) XWarpPointer(dpy, None, f->sel->win, 0, 0, 0, 0, f->sel->rect.width / 2, f->sel->rect.height / 2); @@ -445,16 +445,16 @@ focus_col(Frame * f, Bool raise) } static Frame * -frames_col(Area * a) +frames_col(Layout *l) { - Acme *acme = a->aux; + Acme *acme = l->aux; return acme->frames; } static Frame * -sel_col(Area * a) +sel_col(Layout *l) { - Acme *acme = a->aux; + Acme *acme = l->aux; Column *col = acme->sel; if(col && col->sel) @@ -463,7 +463,7 @@ sel_col(Area * a) } static Action * -actions_col(Area * a) +actions_col(Layout *l) { return lcol_acttbl; } @@ -471,8 +471,8 @@ actions_col(Area * a) static void select_frame(void *obj, char *arg) { - Area *a = obj; - Acme *acme = a->aux; + Layout *l = obj; + Acme *acme = l->aux; Column *c, *col = acme->sel; Cell *cell; @@ -514,8 +514,8 @@ select_frame(void *obj, char *arg) static void swap_frame(void *obj, char *arg) { - Area *a = obj; - Acme *acme = a->aux; + Layout *l = obj; + Acme *acme = l->aux; Column *west = nil, *east = nil, *col = acme->sel; Cell *north = nil, *south = nil, *cell = col->sel; Frame *f; @@ -585,8 +585,8 @@ swap_frame(void *obj, char *arg) static void new_col(void *obj, char *arg) { - Area *a = obj; - Acme *acme = a->aux; + Layout *l = obj; + Acme *acme = l->aux; Column *c, *new, *col = acme->sel; Frame *f; @@ -597,24 +597,24 @@ new_col(void *obj, char *arg) for(c = acme->columns; c && c->next; c = c->next); new = cext_emallocz(sizeof(Column)); - new->rect = area_rect; + new->rect = layout_rect; new->prev = c; c->next = new; acme->ncolumns++; acme->sel = new; - detach_frame(a, f); - attach_frame(a, new, f); + detach_frame(l, f); + attach_frame(l, new, f); - update_column_width(a); + update_column_width(l); focus_col(f, True); } static void toggle_excl_col(void *obj, char *arg) { - Area *a = obj; - Acme *acme = a->aux; + Layout *l = obj; + Acme *acme = l->aux; Column *col = acme->sel; if(!col) diff --git a/cmd/wm/layout_float.c b/cmd/wm/layout_float.c @@ -10,16 +10,16 @@ #include "wm.h" #include "layoutdef.h" -static void init_float(Area * a, Client * clients); -static Client *deinit_float(Area * a); -static void arrange_float(Area * a); -static Bool attach_float(Area * a, Client * c); -static void detach_float(Area * a, Client * c, Bool unmap); +static void init_float(Layout *l, Client * clients); +static Client *deinit_float(Layout *l); +static void arrange_float(Layout *l); +static Bool attach_float(Layout *l, Client * c); +static void detach_float(Layout *l, Client * c, Bool unmap); static void resize_float(Frame * f, XRectangle * new, XPoint * pt); static void focus_float(Frame * f, Bool raise); -static Frame *frames_float(Area * a); -static Frame *sel_float(Area * a); -static Action *actions_float(Area * a); +static Frame *frames_float(Layout *l); +static Frame *sel_float(Layout *l); +static Action *actions_float(Layout *l); static void select_frame(void *obj, char *arg); @@ -37,7 +37,7 @@ typedef struct { void init_layout_float() { - Layout *lp, *l = cext_emallocz(sizeof(Layout)); + LayoutDef *lp, *l = cext_emallocz(sizeof(LayoutDef)); l->name = "float"; l->init = init_float; l->deinit = deinit_float; @@ -58,28 +58,28 @@ init_layout_float() } static void -arrange_float(Area * a) +arrange_float(Layout *l) { } static void -init_float(Area * a, Client * clients) +init_float(Layout *l, Client * clients) { Client *n, *c = clients; Float *fl = cext_emallocz(sizeof(Float)); - a->aux = fl; + l->aux = fl; while(c) { n = c->next; - attach_float(a, c); + attach_float(l, c); c = n; } } static void -attach_frame(Area * a, Frame * new) +attach_frame(Layout *l, Frame * new) { - Float *fl = a->aux; + Float *fl = l->aux; Frame *f; for(f = fl->frames; f && f->next; f = f->next); @@ -89,15 +89,15 @@ attach_frame(Area * a, Frame * new) f->next = new; new->prev = f; } - attach_frame_to_area(a, new); + attach_frame_to_layout(l, new); fl->sel = new; fl->nframes++; } static void -detach_frame(Area * a, Frame * old) +detach_frame(Layout *l, Frame * old) { - Float *fl = a->aux; + Float *fl = l->aux; if(fl->sel == old) { if(old->prev) @@ -113,14 +113,14 @@ detach_frame(Area * a, Frame * old) old->next->prev = old->prev; if(!fl->sel) fl->sel = fl->frames; - detach_frame_from_area(old); + detach_frame_from_layout(old); fl->nframes--; } static Client * -deinit_float(Area * a) +deinit_float(Layout *l) { - Float *fl = a->aux; + Float *fl = l->aux; Client *res = nil, *c = nil, *cl; Frame *f; @@ -136,42 +136,42 @@ deinit_float(Area * a) c = cl; } } - detach_frame(a, f); + detach_frame(l, f); destroy_frame(f); } free(fl); - a->aux = nil; + l->aux = nil; return res; } static Bool -attach_float(Area * a, Client * c) +attach_float(Layout *l, Client * c) { Frame *f; /* check for tabbing? */ - if(c->rect.y < area_rect.y) - c->rect.y = area_rect.y; - if(c->rect.x < area_rect.x) - c->rect.x = area_rect.x; + if(c->rect.y < layout_rect.y) + c->rect.y = layout_rect.y; + if(c->rect.x < layout_rect.x) + c->rect.x = layout_rect.x; f = alloc_frame(&c->rect); - attach_frame_to_area(a, f); - attach_frame(a, f); + attach_frame_to_layout(l, f); + attach_frame(l, f); attach_client_to_frame(f, c); - if(a->page == selpage) + if(l->page == selpage) XMapWindow(dpy, f->win); focus_float(f, True); return True; } static void -detach_float(Area * a, Client * c, Bool unmap) +detach_float(Layout *l, Client * c, Bool unmap) { Frame *f = c->frame; detach_client_from_frame(c, unmap); if(!f->clients) { - detach_frame(a, f); + detach_frame(l, f); destroy_frame(f); } } @@ -185,12 +185,12 @@ resize_float(Frame * f, XRectangle * new, XPoint * pt) static void focus_float(Frame * f, Bool raise) { - Area *a = f->area; - Float *fl = a->aux; + Layout *l = f->layout; + Float *fl = l->aux; Frame *old = fl->sel; fl->sel = f; - a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content; + l->file[L_SEL_FRAME]->content = f->file[F_PREFIX]->content; if(raise) { XRaiseWindow(dpy, f->win); XWarpPointer(dpy, None, f->sel->win, 0, 0, 0, 0, @@ -203,17 +203,17 @@ focus_float(Frame * f, Bool raise) } static Frame * -frames_float(Area * a) +frames_float(Layout *l) { - Float *fl = a->aux; + Float *fl = l->aux; return fl->frames; } static void select_frame(void *obj, char *arg) { - Area *a = obj; - Float *fl = a->aux; + Layout *l = obj; + Float *fl = l->aux; Frame *f = fl->sel; if(!f || !arg) @@ -238,14 +238,14 @@ select_frame(void *obj, char *arg) } static Frame * -sel_float(Area * a) +sel_float(Layout *l) { - Float *fl = a->aux; + Float *fl = l->aux; return fl->sel; } static Action * -actions_float(Area * a) +actions_float(Layout *l) { return lfloat_acttbl; } diff --git a/cmd/wm/page.c b/cmd/wm/page.c @@ -12,12 +12,12 @@ static void handle_after_write_page(IXPServer * s, File * file); -static void toggle_area(void *obj, char *arg); +static void toggle_layout(void *obj, char *arg); static void xexec(void *obj, char *arg); /* action table for /?/ namespace */ Action page_acttbl[] = { - {"toggle", toggle_area}, + {"toggle", toggle_layout}, {"exec", xexec}, {0, 0} }; @@ -41,8 +41,8 @@ alloc_page() snprintf(buf, sizeof(buf), "/%d/ctl", (int)npages); new->file[P_CTL] = ixp_create(ixps, buf); new->file[P_CTL]->after_write = handle_after_write_page; - new->floating = alloc_area(new, "float"); - new->sel = new->managed = alloc_area(new, def[WM_LAYOUT]->content); + new->floating = alloc_layout(new, "float"); + new->sel = new->managed = alloc_layout(new, def[WM_LAYOUT]->content); for(p = pages; p && p->next; p = p->next); if(!p) { pages = new; @@ -86,8 +86,8 @@ destroy_page(Page * p) n = n->next; } - destroy_area(p->floating); - destroy_area(p->managed); + destroy_layout(p->floating); + destroy_layout(p->managed); def[WM_SEL_PAGE]->content = 0; ixp_remove_file(ixps, p->file[P_PREFIX]); if(p == selpage) { @@ -134,7 +134,7 @@ focus_page(Page * p) show_page(p); def[WM_SEL_PAGE]->content = p->file[P_PREFIX]->content; invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]); - focus_area(sel_area()); + focus_layout(sel_layout()); XChangeProperty(dpy, root, net_atoms[NET_CURRENT_DESKTOP], XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &(selpage->index), 1); } @@ -172,15 +172,15 @@ rectangles(unsigned int *num) void hide_page(Page * p) { - hide_area(p->managed); - hide_area(p->floating); + hide_layout(p->managed); + hide_layout(p->floating); } void show_page(Page * p) { - show_area(p->managed, False); - show_area(p->floating, False); + show_layout(p->managed, False); + show_layout(p->floating, False); } static void @@ -212,7 +212,7 @@ xexec(void *obj, char *arg) } static void -toggle_area(void *obj, char *arg) +toggle_layout(void *obj, char *arg) { Page *p = obj; @@ -221,7 +221,7 @@ toggle_area(void *obj, char *arg) else p->sel = p->managed; - focus_area(p->sel); + focus_layout(p->sel); invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]); } diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -29,7 +29,7 @@ static void _detach_client(void *obj, char *arg); static void _close_client(void *obj, char *arg); static void pager(void *obj, char *arg); static void detached_clients(void *obj, char *arg); -static void reserve_area(void *obj, char *arg); +static void reserve_layout(void *obj, char *arg); /* action table for /ctl namespace */ Action wm_acttbl[] = { @@ -42,7 +42,7 @@ Action wm_acttbl[] = { {"quit", quit}, {"pager", pager}, {"detached_clients", detached_clients}, - {"reserve_area", reserve_area}, + {"reserve_layout", reserve_layout}, {0, 0} }; @@ -118,31 +118,19 @@ scale_rect(XRectangle * from_dim, XRectangle * to_dim, } static void -draw_pager_area(Area * a, Draw * d) +draw_pager_layout(Layout *l, Draw * d) { Frame *f; Frame *sel = sel_frame(); - for(f = a->layout->frames(a); f; f = f->next) { + for(f = l->def->frames(l); f; f = f->next) { if(f == sel) { - d->bg = - blitz_loadcolor(dpy, screen_num, - def[WM_SEL_BG_COLOR]->content); - d->fg = - blitz_loadcolor(dpy, screen_num, - def[WM_SEL_FG_COLOR]->content); - d->border = - blitz_loadcolor(dpy, screen_num, - def[WM_SEL_BORDER_COLOR]->content); + d->bg = blitz_loadcolor(dpy, screen_num, def[WM_SEL_BG_COLOR]->content); + d->fg = blitz_loadcolor(dpy, screen_num, def[WM_SEL_FG_COLOR]->content); + d->border = blitz_loadcolor(dpy, screen_num, def[WM_SEL_BORDER_COLOR]->content); } else { - d->bg = - blitz_loadcolor(dpy, screen_num, - def[WM_NORM_BG_COLOR]->content); - d->fg = - blitz_loadcolor(dpy, screen_num, - def[WM_NORM_FG_COLOR]->content); - d->border = - blitz_loadcolor(dpy, screen_num, - def[WM_NORM_BORDER_COLOR]->content); + d->bg = blitz_loadcolor(dpy, screen_num, def[WM_NORM_BG_COLOR]->content); + d->fg = blitz_loadcolor(dpy, screen_num, def[WM_NORM_FG_COLOR]->content); + d->border = blitz_loadcolor(dpy, screen_num, def[WM_NORM_BORDER_COLOR]->content); } d->data = f->sel->name; scale_rect(&rect, &initial_rect, &f->rect, &d->rect); @@ -187,8 +175,8 @@ draw_pager_page(Page * p, Draw * d) blitz_drawlabel(dpy, d); XSync(dpy, False); if(p->managed) - draw_pager_area(p->managed, d); - draw_pager_area(p->floating, d); + draw_pager_layout(p->managed, d); + draw_pager_layout(p->floating, d); } static void @@ -364,7 +352,7 @@ draw_detached_clients() } static void -reserve_area(void *obj, char *arg) +reserve_layout(void *obj, char *arg) { if(arg && strrchr(arg, ' ')) { XRectangle r; @@ -500,12 +488,12 @@ win_to_client(Window w) return c; for(p = pages; p; p = p->next) { Frame *f; - for(f = p->managed->layout->frames(p->managed); f; f = f->next) { + 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->layout->frames(p->floating); f; f = f->next) { + for(f = p->floating->def->frames(p->floating); f; f = f->next) { for(c = f->clients; c; c = c->next) if(c->win == w) return c; @@ -606,8 +594,8 @@ update_pages() Page *p; for(p = pages; p; p = p->next) { - p->floating->layout->arrange(p->floating); - p->managed->layout->arrange(p->managed); + p->floating->def->arrange(p->floating); + p->managed->def->arrange(p->managed); } } @@ -616,8 +604,8 @@ handle_before_read(IXPServer * s, File * f) { char buf[64]; if(f == def[WM_AREA_GEOMETRY]) { - snprintf(buf, 64, "%d %d %d %d", area_rect.x, area_rect.y, - area_rect.width, area_rect.height); + snprintf(buf, 64, "%d %d %d %d", layout_rect.x, layout_rect.y, + layout_rect.width, layout_rect.height); if(f->content) free(f->content); f->content = cext_estrdup(buf); @@ -644,8 +632,8 @@ handle_after_write(IXPServer * s, File * f) } else if(f == def[WM_AREA_GEOMETRY]) { char *geom = def[WM_AREA_GEOMETRY]->content; if(geom && strrchr(geom, ' ')) { - area_rect = rect; - blitz_strtorect(&rect, &area_rect, geom); + layout_rect = rect; + blitz_strtorect(&rect, &layout_rect, geom); update_pages(); } } @@ -693,7 +681,7 @@ init_default() BLITZ_SEL_FG_COLOR); def[WM_TRANS_COLOR]->after_write = handle_after_write; def[WM_AREA_GEOMETRY] = - wmii_create_ixpfile(ixps, "/default/area/geometry", + wmii_create_ixpfile(ixps, "/default/layout/geometry", BLITZ_SEL_FG_COLOR); def[WM_AREA_GEOMETRY]->after_write = handle_after_write; def[WM_AREA_GEOMETRY]->before_read = handle_before_read; @@ -753,7 +741,7 @@ init_screen() rect.x = rect.y = 0; rect.width = DisplayWidth(dpy, screen_num); rect.height = DisplayHeight(dpy, screen_num); - area_rect = rect; + layout_rect = rect; wa.override_redirect = 1; wa.background_pixmap = ParentRelative; @@ -814,11 +802,11 @@ cleanup() Client *c; for(p = pages; p; p = p->next) { Frame *f; - for(f = p->managed->layout->frames(p->managed); f; f = f->next) { + for(f = p->managed->def->frames(p->managed); f; f = f->next) { while((c = f->clients)) detach_client_from_frame(c, False); } - for(f = p->floating->layout->frames(p->floating); f; f = f->next) { + for(f = p->floating->def->frames(p->floating); f; f = f->next) { while((c = f->clients)) detach_client_from_frame(c, False); } diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -18,14 +18,14 @@ enum { P_LAST }; -/* array indexes of area file pointers */ +/* array indexes of layout file pointers */ enum { - A_PREFIX, - A_FRAME_PREFIX, - A_SEL_FRAME, - A_CTL, - A_LAYOUT, - A_LAST + L_PREFIX, + L_FRAME_PREFIX, + L_SEL_FRAME, + L_CTL, + L_NAME, + L_LAST }; /* array indexes of frame file pointers */ @@ -89,8 +89,8 @@ enum { typedef struct Page Page; typedef struct AttachQueue AttachQueue; +typedef struct LayoutDef LayoutDef; typedef struct Layout Layout; -typedef struct Area Area; typedef struct Frame Frame; typedef struct Client Client; @@ -100,39 +100,39 @@ struct AttachQueue { }; struct Page { - Area *managed; - Area *floating; - Area *sel; + Layout *managed; + Layout *floating; + Layout *sel; File *file[P_LAST]; Page *next; Page *prev; size_t index; }; -struct Layout { +struct LayoutDef { char *name; - void (*init) (Area *, Client *); /* called when layout is initialized */ - Client *(*deinit) (Area *); /* called when layout is uninitialized */ - void (*arrange) (Area *); /* called when area is resized */ - Bool(*attach) (Area *, Client *); /* called on attach */ - void (*detach) (Area *, Client *, Bool unmap); /* called on detach */ + void (*init) (Layout *, Client *); /* called when layout is initialized */ + Client *(*deinit) (Layout *); /* called when layout is uninitialized */ + void (*arrange) (Layout *); /* called when layout is resized */ + Bool(*attach) (Layout *, Client *); /* called on attach */ + void (*detach) (Layout *, Client *, Bool unmap); /* called on detach */ void (*resize) (Frame *, XRectangle *, XPoint *); /* called after resize */ void (*focus) (Frame *, Bool raise); /* focussing a frame */ - Frame *(*frames) (Area *); /* called for drawing */ - Frame *(*sel) (Area *); /* returns selected frame */ - Action *(*actions) (Area *); /* local action table */ - Layout *next; + Frame *(*frames) (Layout *); /* called for drawing */ + Frame *(*sel) (Layout *); /* returns selected frame */ + Action *(*actions) (Layout *); /* local action table */ + LayoutDef *next; }; -struct Area { +struct Layout { Page *page; - Layout *layout; + LayoutDef *def; void *aux; /* free pointer */ - File *file[A_LAST]; + File *file[L_LAST]; }; struct Frame { - Area *area; + Layout *layout; Window win; Client *sel; Client *clients; @@ -169,7 +169,7 @@ AttachQueue *attachqueue; size_t npages; Client *detached; size_t ndetached; -Layout *layouts; +LayoutDef *layouts; Display *dpy; IXPServer *ixps; @@ -177,7 +177,7 @@ int screen_num; Window root; Window transient; XRectangle rect; -XRectangle area_rect; +XRectangle layout_rect; XFontStruct *font; XColor xorcolor; GC xorgc; @@ -208,15 +208,6 @@ File *def[WM_LAST]; unsigned int valid_mask, num_lock_mask; -/* area.c */ -Area *alloc_area(Page * p, char *layout); -void destroy_area(Area * a); -void focus_area(Area * a); -void hide_area(Area * a); -void show_area(Area * a, Bool raise); -Area *sel_area(); -void attach_frame_to_area(Area * a, Frame * f); -void detach_frame_from_area(Frame * f); /* client.c */ Client *alloc_client(Window w); @@ -276,7 +267,15 @@ void hide_page(Page * p); void show_page(Page * p); /* layout.c */ -Layout *match_layout(char *name); +Layout *alloc_layout(Page * p, char *layout); +void destroy_layout(Layout *l); +void focus_layout(Layout *l); +void hide_layout(Layout *l); +void show_layout(Layout *l, Bool raise); +Layout *sel_layout(); +void attach_frame_to_layout(Layout *l, Frame * f); +void detach_frame_from_layout(Frame * f); +LayoutDef *match_layout_def(char *name); /* layoutdef.c */ void init_layouts();