wmii

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

commit 4acbd3286e491181a636bc3b9b5ceb62f19dfc4e
parent c07fee01c297e3cff300bfe58d1c222460d0fbd0
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Fri, 13 Jan 2006 12:11:14 +0200

first step of layout interface change, next step is moving Frame->aux to Client->aux


Diffstat:
cmd/wm/client.c | 28++++++++--------------------
cmd/wm/frame.c | 33+++++++++------------------------
cmd/wm/layout.c | 6+++---
cmd/wm/layout_column.c | 74+++++++++++++++++++++++---------------------------------------------------
cmd/wm/layout_float.c | 35+++++++++++++++++------------------
cmd/wm/wm.c | 24++++++------------------
cmd/wm/wm.h | 16++++++++--------
7 files changed, 74 insertions(+), 142 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -232,25 +232,13 @@ draw_client(Client * client) d.font = font; if((f == sel_frame()) && (c == 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); } blitz_drawlabel(dpy, &d); XSync(dpy, False); @@ -360,8 +348,8 @@ detach_client(Client * c, Bool unmap) Client * sel_client() { - Frame *f = sel_frame(); - return f ? f->sel : nil; + Layout *l = sel_layout(); + return l ? l->def->sel(l) : nil; } Client * diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c @@ -224,25 +224,13 @@ draw_frame(Frame * f) /* define ground plate (i = 0) */ if(f == sel_frame()) { - 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.rect = f->rect; d.rect.x = d.rect.y = 0; @@ -260,8 +248,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->layout->def->focus(f, False); - sel_client(new); + f->layout->def->focus(f->layout, new, False); if(e->button == Button1) { align = cursor_to_align(f->cursor); if(align == CENTER) @@ -408,8 +395,6 @@ handle_after_write_frame(IXPServer * s, File * file) Frame * sel_frame() { - Layout *l = sel_layout(); - if(!l) - return nil; - return l->def->sel(l); + Client *c = sel_client(); + return c ? c->frame : nil; } diff --git a/cmd/wm/layout.c b/cmd/wm/layout.c @@ -57,11 +57,11 @@ void focus_layout(Layout *l) { Page *p = l->page; - Frame *f; + Client *c; p->sel = l; p->file[P_SEL_LAYOUT]->content = l->file[L_PREFIX]->content; - if((f = l->def->sel(l))) - l->def->focus(f, False); + if((c = l->def->sel(l))) + l->def->focus(l, c, False); } void diff --git a/cmd/wm/layout_column.c b/cmd/wm/layout_column.c @@ -33,7 +33,6 @@ struct Column { Cell *sel; Cell *cells; size_t ncells; - Bool exclusive; XRectangle rect; Column *prev; Column *next; @@ -45,21 +44,19 @@ 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 void focus_col(Layout *l, Client *c, Bool raise); static Frame *frames_col(Layout *l); -static Frame *sel_col(Layout *l); +static Client *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); static void new_col(void *obj, char *arg); -static void toggle_excl_col(void *obj, char *arg); static Action lcol_acttbl[] = { {"select", select_frame}, {"swap", swap_frame}, {"new", new_col}, - {"toggle", toggle_excl_col}, {0, 0} }; @@ -234,16 +231,10 @@ attach_col(Layout *l, Client * c) if(!col) { col = cext_emallocz(sizeof(Column)); - col->exclusive = True; /* first col is exclusive */ col->rect = layout_rect; acme->columns = acme->sel = col; acme->ncolumns++; } - else if(col->exclusive && col->ncells && col->next) { - f = col->sel->frame; - acme->sel = col = col->next; - draw_frame(f); - } f = alloc_frame(&c->rect); attach_frame(l, col, f); @@ -251,9 +242,7 @@ attach_col(Layout *l, Client * c) arrange_column(col); if(l->page == selpage) XMapWindow(dpy, f->win); - focus_col(f, True); - if(col->exclusive && col->ncells > 1) - new_col(l, nil); + focus_col(l, c, True); return True; } @@ -397,7 +386,7 @@ drop_moving(Frame * f, XRectangle * new, XPoint * pt) attach_frame(l, tgt, f); arrange_column(src); arrange_column(tgt); - focus_col(f, True); + focus_col(l, f->sel, True); } else { Cell *c; for(c = src->cells; @@ -408,7 +397,7 @@ drop_moving(Frame * f, XRectangle * new, XPoint * pt) c->frame = f; cell->frame = tmp; arrange_column(src); - focus_col(f, True); + focus_col(l, f->sel, True); } } } @@ -425,23 +414,22 @@ resize_col(Frame * f, XRectangle * new, XPoint * pt) } static void -focus_col(Frame * f, Bool raise) +focus_col(Layout *l, Client *c, Bool raise) { - Layout *l = f->layout; Acme *acme = l->aux; - Frame *old = sel_col(l); - Cell *cell = f->aux; + Client *old = sel_col(l); + Cell *cell = c->frame->aux; acme->sel = cell->col; cell->col->sel = cell; - l->file[L_SEL_FRAME]->content = f->file[F_PREFIX]->content; + c->frame->file[L_SEL_FRAME]->content = c->frame->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); - focus_client(f->sel); - if(old && old != f) - draw_frame(old); - draw_frame(f); + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, + c->rect.width / 2, c->rect.height / 2); + focus_client(c); + if(old && old != c) + draw_frame(old->frame); + draw_frame(c->frame); } static Frame * @@ -451,14 +439,14 @@ frames_col(Layout *l) return acme->frames; } -static Frame * +static Client * sel_col(Layout *l) { Acme *acme = l->aux; Column *col = acme->sel; if(col && col->sel) - return col->sel->frame; + return col->sel->frame->sel; return nil; } @@ -508,7 +496,7 @@ select_frame(void *obj, char *arg) i++; } if(cell) - focus_col(cell->frame, True); + focus_col(l, cell->frame->sel, True); } static void @@ -540,7 +528,7 @@ swap_frame(void *obj, char *arg) north->frame->aux = north; resize_frame(cell->frame, &cell->frame->rect, nil); resize_frame(north->frame, &north->frame->rect, nil); - focus_col(cell->frame, True); + focus_col(l, cell->frame->sel, True); } else if(!strncmp(arg, "south", 6) && south) { r = south->frame->rect; south->frame->rect = cell->frame->rect; @@ -552,7 +540,7 @@ swap_frame(void *obj, char *arg) south->frame->aux = south; resize_frame(cell->frame, &cell->frame->rect, nil); resize_frame(south->frame, &south->frame->rect, nil); - focus_col(cell->frame, True); + focus_col(l, cell->frame->sel, True); } else if(!strncmp(arg, "west", 5) && west && (col->ncells > 1)) { Cell *other = west->sel; r = other->frame->rect; @@ -565,7 +553,7 @@ swap_frame(void *obj, char *arg) cell->frame->aux = cell; resize_frame(cell->frame, &cell->frame->rect, nil); resize_frame(other->frame, &other->frame->rect, nil); - focus_col(other->frame, True); + focus_col(l, other->frame->sel, True); } else if(!strncmp(arg, "east", 5) && east && (col->ncells > 1)) { Cell *other = east->sel; r = other->frame->rect; @@ -578,7 +566,7 @@ swap_frame(void *obj, char *arg) cell->frame->aux = cell; resize_frame(cell->frame, &cell->frame->rect, nil); resize_frame(other->frame, &other->frame->rect, nil); - focus_col(cell->frame, True); + focus_col(l, other->frame->sel, True); } } @@ -607,21 +595,5 @@ new_col(void *obj, char *arg) attach_frame(l, new, f); update_column_width(l); - focus_col(f, True); -} - -static void -toggle_excl_col(void *obj, char *arg) -{ - Layout *l = obj; - Acme *acme = l->aux; - Column *col = acme->sel; - - if(!col) - return; - - if(!strncmp(arg, "0", 1)) - col->exclusive = False; - else if(!strncmp(arg, "1", 1)) - col->exclusive = True; + focus_col(l, f->sel, True); } diff --git a/cmd/wm/layout_float.c b/cmd/wm/layout_float.c @@ -16,9 +16,9 @@ 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 void focus_float(Layout * l, Client * c, Bool raise); static Frame *frames_float(Layout *l); -static Frame *sel_float(Layout *l); +static Client *sel_float(Layout *l); static Action *actions_float(Layout *l); static void select_frame(void *obj, char *arg); @@ -161,7 +161,7 @@ attach_float(Layout *l, Client * c) attach_client_to_frame(f, c); if(l->page == selpage) XMapWindow(dpy, f->win); - focus_float(f, True); + focus_float(l, c, True); return True; } @@ -183,23 +183,22 @@ resize_float(Frame * f, XRectangle * new, XPoint * pt) } static void -focus_float(Frame * f, Bool raise) +focus_float(Layout *l, Client *c, Bool raise) { - Layout *l = f->layout; Float *fl = l->aux; - Frame *old = fl->sel; + Client *old = fl->sel->sel; - fl->sel = f; - l->file[L_SEL_FRAME]->content = f->file[F_PREFIX]->content; + fl->sel = c->frame; + l->file[L_SEL_FRAME]->content = c->frame->file[F_PREFIX]->content; if(raise) { - XRaiseWindow(dpy, f->win); - XWarpPointer(dpy, None, f->sel->win, 0, 0, 0, 0, - f->sel->rect.width / 2, f->sel->rect.height / 2); + XRaiseWindow(dpy, c->frame->win); + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, + c->rect.width / 2, c->rect.height / 2); } - focus_client(f->sel); - if(old && old != f) - draw_frame(old); - draw_frame(f); + focus_client(c); + if(old && old != c) + draw_frame(old->frame); + draw_frame(c->frame); } static Frame * @@ -234,14 +233,14 @@ select_frame(void *obj, char *arg) i++; } if(f) - focus_float(f, True); + focus_float(l, f->sel, True); } -static Frame * +static Client * sel_float(Layout *l) { Float *fl = l->aux; - return fl->sel; + return fl->sel ? fl->sel->sel : nil; } static Action * diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -148,25 +148,13 @@ draw_pager_page(Page * p, Draw * d) Page *page; if(p == selpage) { - 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); } for(page = pages; page && page != p; page = page->next) idx++; diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -110,16 +110,16 @@ struct Page { struct LayoutDef { char *name; - void (*init) (Layout *, Client *); /* called when layout is initialized */ + 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 */ + 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) (Layout *); /* called for drawing */ - Frame *(*sel) (Layout *); /* returns selected frame */ - Action *(*actions) (Layout *); /* local action table */ + void (*detach) (Layout *, Client *, Bool unmap); /* called on detach */ + void (*resize) (Frame *, XRectangle *, XPoint *); /* called after resize */ + void (*focus) (Layout *, Client *, Bool raise); /* focussing a client */ + Frame *(*frames) (Layout *); /* called for drawing */ + Client *(*sel) (Layout *); /* returns selected client */ + Action *(*actions) (Layout *); /* local action table */ LayoutDef *next; };