wmii

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

commit 62ba6045d0d9a00904963bf412510d7292ff4f5b
parent 0615c276f98fa240892fcdd1e731eb9a25596840
Author: garbeam <garbeam@mmv.wmii.de>
Date:   Sat, 10 Dec 2005 15:50:20 +0200

added select to layout interface, now the layouts look pretty good from interface POV


Diffstat:
cmd/wm/area.c | 16+++++++++++++++-
cmd/wm/event.c | 2+-
cmd/wm/frame.c | 27++++++++++++++++-----------
cmd/wm/layout_column.c | 19+++++++++++++------
cmd/wm/layout_float.c | 34++++++++++++++++++++++++++++++++--
cmd/wm/page.c | 26--------------------------
cmd/wm/wm.h | 3++-
rc/wmirc | 6+++---
8 files changed, 82 insertions(+), 51 deletions(-)

diff --git a/cmd/wm/area.c b/cmd/wm/area.c @@ -10,6 +10,13 @@ #include "wm.h" static void handle_after_write_area(IXPServer * s, File * f); +static void select_frame(void *obj, char *cmd); + +/* action table for /?/layout/?/ namespace */ +Action layout_acttbl[] = { + {"select", select_frame}, + {0, 0} +}; Area *alloc_area(Page *p, XRectangle * r, char *layout) { @@ -121,7 +128,7 @@ 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);*/ + run_action(file, a, layout_acttbl); return; } if (file == a->file[A_LAYOUT]) { @@ -148,3 +155,10 @@ static void handle_after_write_area(IXPServer *s, File *f) { cext_list_iterate(&areas, f, iter_after_write_area); } + +static void select_frame(void *obj, char *cmd) +{ + Area *a = obj; + a->layout->select(a, cmd); +} + diff --git a/cmd/wm/event.c b/cmd/wm/event.c @@ -248,7 +248,7 @@ static void handle_enternotify(XEvent * e) if (c && c->frame && (ev->serial != ignore_enternotify_crap)) { Frame *old = get_sel_frame(); if (old != c->frame) { - sel_frame(c->frame, 1); + sel_frame(c->frame, 0); draw_frame(old, nil); draw_frame(c->frame, nil); } diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c @@ -10,7 +10,7 @@ #include "wm.h" -static void select_client(void *obj, char *cmd); +static void select_client(void *obj, char *arg); static void handle_after_write_frame(IXPServer * s, File * f); static void handle_before_read_frame(IXPServer * s, File * f); @@ -289,9 +289,10 @@ void handle_frame_buttonpress(XButtonEvent *e, Frame *f) { Align align; size_t size = cext_sizeof(&f->clients); - int bindex, cindex = e->x / f->rect.width / size; - Client *c = cext_list_get_item(&f->clients, cindex); - cext_stack_top_item(&f->clients, c); + int bindex, cindex = e->x / (f->rect.width / size); + /*fprintf(stderr, "%d (x) / %d (w) / %d (size) = %d (#c)\n", e->x, f->rect.width, size, cindex);*/ + /*sel_client(cext_list_get_item(&f->clients, cindex));*/ + cext_stack_top_item(&f->clients, cext_list_get_item(&f->clients, cindex)); sel_frame(f, cext_list_get_item_index(&f->area->page->areas, f->area) == 0); if (e->button == Button1) { align = cursor_to_align(f->cursor); @@ -339,17 +340,21 @@ void detach_client_from_frame(Client *c) } } -static void select_client(void *obj, char *cmd) +static void select_client(void *obj, char *arg) { + Client *c; Frame *f = obj; size_t size = cext_sizeof(&f->clients); - if (!f || !cmd || size == 1) + if (!f || !arg || size == 1) return; - if (!strncmp(cmd, "prev", 5)) - cext_stack_top_item(&f->clients, cext_stack_get_up_item(&f->clients, cext_stack_get_top_item(&f->clients))); - else if (!strncmp(cmd, "next", 5)) - cext_stack_top_item(&f->clients, cext_stack_get_down_item(&f->clients, cext_stack_get_top_item(&f->clients))); - sel_client(cext_stack_get_top_item(&f->clients)); + c = cext_stack_get_top_item(&f->clients); + if (!strncmp(arg, "prev", 5)) + c = cext_list_get_prev_item(&f->clients, c); + else if (!strncmp(arg, "next", 5)) + c = cext_list_get_next_item(&f->clients, c); + else + c = cext_list_get_item(&f->clients, _strtonum(arg, 0, cext_sizeof(&f->clients) - 1)); + sel_client(c); draw_frame(f, nil); } diff --git a/cmd/wm/layout_column.c b/cmd/wm/layout_column.c @@ -31,12 +31,13 @@ static void 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); -static void resize_col(Frame * f, XRectangle * new, XPoint * pt); -static Container *get_frames_col(Area *a); +static void resize_col(Frame *f, XRectangle * new, XPoint * pt); +static void select_col(Area *a, char *arg); static void aux_col(Area *a, char *aux); +static Container *get_frames_col(Area *a); static Layout lcol = { "col", init_col, deinit_col, arrange_col, attach_col, detach_col, - resize_col, get_frames_col, aux_col }; + resize_col, select_col, aux_col, get_frames_col }; void init_layout_column() { @@ -375,12 +376,18 @@ static void resize_col(Frame *f, XRectangle *new, XPoint *pt) drop_resize(f, new); } -static Container *get_frames_col(Area *a) +static void select_col(Area *a, char *arg) { - Acme *acme = a->aux; - return &acme->frames; + } static void aux_col(Area *a, char *aux) { } + +static Container *get_frames_col(Area *a) +{ + Acme *acme = a->aux; + return &acme->frames; +} + diff --git a/cmd/wm/layout_float.c b/cmd/wm/layout_float.c @@ -16,10 +16,12 @@ static void arrange_float(Area *a); static Bool attach_float(Area *a, Client *c); static void detach_float(Area *a, Client *c); static void resize_float(Frame *f, XRectangle *new, XPoint *pt); +static void select_float(Area *a, char *arg); +static void aux_float(Area *a, char *aux); static Container *get_frames_float(Area *a); static Layout lfloat = { "float", init_float, deinit_float, arrange_float, attach_float, - detach_float, resize_float, get_frames_float }; + detach_float, resize_float, select_float, aux_float, get_frames_float }; void init_layout_float() { @@ -94,6 +96,34 @@ static void resize_float(Frame *f, XRectangle *new, XPoint *pt) f->rect = *new; } -static Container *get_frames_float(Area *a) { +static void select_float(Area *a, char *arg) +{ + Container *c = a->aux; + Frame *f, *old; + + f = old = cext_stack_get_top_item(c); + if (!f || !arg) + return; + if (!strncmp(arg, "prev", 5)) + f = cext_list_get_prev_item(c, f); + else if (!strncmp(arg, "next", 5)) + f = cext_list_get_next_item(c, f); + else + f = cext_list_get_item(c, _strtonum(arg, 0, cext_sizeof(c) - 1)); + if (old != f) { + sel_frame(f, cext_list_get_item_index(&a->page->areas, a) == 0); + center_pointer(f); + draw_frame(old, nil); + draw_frame(f, nil); + } +} + +static void aux_float(Area *a, char *aux) +{ + +} + +static Container *get_frames_float(Area *a) +{ return a->aux; } diff --git a/cmd/wm/page.c b/cmd/wm/page.c @@ -9,12 +9,10 @@ #include "wm.h" -static void select_frame(void *obj, char *cmd); static void handle_after_write_page(IXPServer * s, File * f); /* action table for /?/ namespace */ Action page_acttbl[] = { - {"select", select_frame}, {0, 0} }; @@ -118,30 +116,6 @@ XRectangle *rectangles(unsigned int *num) return result; } -static void select_frame(void *obj, char *cmd) -{ - Area *a; - Frame *f, *old; - f = old = get_sel_frame(); - if (!f || !cmd) - return; - a = f->area; - if (!strncmp(cmd, "prev", 5)) { - f = cext_stack_get_up_item(a->layout->get_frames(a), f); - cext_stack_top_item(a->layout->get_frames(a), f); - } - else if (!strncmp(cmd, "next", 5)) { - f = cext_stack_get_down_item(a->layout->get_frames(a), f); - cext_stack_top_item(a->layout->get_frames(a), f); - } - if (old != f) { - sel_frame(f, cext_list_get_item_index(&a->page->areas, a) == 0); - center_pointer(f); - draw_frame(old, nil); - draw_frame(f, nil); - } -} - static void iter_hide_page(void *item, void *aux) { hide_area((Area *)item); diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -123,8 +123,9 @@ struct Layout { Bool (*attach) (Area *, Client *); /* called on attach */ void (*detach) (Area *, Client *); /* called on detach */ void (*resize) (Frame *, XRectangle *, XPoint *); /* called after resize */ - Container *(*get_frames) (Area *); /* called after resize */ + void (*select) (Area *, char *arg); /* called after resize */ void (*aux) (Area *, char *aux); /* aux interface */ + Container *(*get_frames) (Area *); /* called after resize */ }; struct Area { diff --git a/rc/wmirc b/rc/wmirc @@ -137,9 +137,9 @@ kbind normal $MODKEY-u 'wmir write /wm/sel/layout/sel/frame/sel/locked 0' kbind normal $MODKEY-S-u 'wmir write /wm/sel/layout/sel/frame/sel/locked 1' kbind normal $MODKEY-$WESTKEY 'wmir write /wm/ctl ''select prev''' kbind normal $MODKEY-$EASTKEY 'wmir write /wm/ctl ''select next''' -kbind normal $MODKEY-Tab 'wmir write /wm/sel/ctl ''select next''' -kbind normal $MODKEY-$SOUTHKEY 'wmir write /wm/sel/ctl ''select next''' -kbind normal $MODKEY-$NORTHKEY 'wmir write /wm/sel/ctl ''select prev''' +kbind normal $MODKEY-Tab 'wmir write /wm/sel/layout/sel/ctl ''select next''' +kbind normal $MODKEY-$SOUTHKEY 'wmir write /wm/sel/layout/sel/ctl ''select next''' +kbind normal $MODKEY-$NORTHKEY 'wmir write /wm/sel/layout/sel/ctl ''select prev''' kbind normal $MODKEY-S-Tab 'wmir write /wm/sel/layout/sel/frame/sel/ctl ''select next''' kbind normal $MODKEY-S-$SOUTHKEY 'wmir write /wm/sel/layout/sel/frame/sel/ctl ''select next''' kbind normal $MODKEY-S-$NORTHKEY 'wmir write /wm/sel/layout/sel/frame/sel/ctl ''select prev'''