commit d53c4451bdd39bc0f3a90cd71c5ea50de53e9e6e
parent b976aa473d8c576f521becf9b41f721bb10d78de
Author: garbeam <garbeam@mmv.wmii.de>
Date: Sun, 11 Dec 2005 00:43:45 +0200
sanitized layout interface
Diffstat:
6 files changed, 56 insertions(+), 64 deletions(-)
diff --git a/cmd/wm/area.c b/cmd/wm/area.c
@@ -10,13 +10,6 @@
#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)
{
@@ -61,22 +54,14 @@ void destroy_area(Area *a)
free(a);
}
-static void iter_raise_frame(void *item, void *aux)
-{
- XRaiseWindow(dpy, ((Frame *)item)->win);
-}
-
void sel_area(Area *a)
{
Page *p = a->page;
Frame *f;
- Bool raise = cext_list_get_item_index(&p->areas, a) == 0;
- if (raise)
- cext_stack_iterate_up(a->layout->get_frames(a), nil, iter_raise_frame);
cext_stack_top_item(&p->areas, a);
p->file[P_SEL_AREA]->content = a->file[A_PREFIX]->content;
if ((f = get_sel_frame_of_area(a)))
- sel_frame(f, raise);
+ a->layout->select(f, True);
}
void draw_area(Area *a)
@@ -128,7 +113,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, a, layout_acttbl);
+ run_action(file, a, a->layout->get_actions(a));
return;
}
if (file == a->file[A_LAYOUT]) {
@@ -156,9 +141,4 @@ static void handle_after_write_area(IXPServer *s, File *f) {
}
-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, 0);
+ c->frame->area->layout->select(c->frame, False);
draw_frame(old, nil);
draw_frame(c->frame, nil);
}
diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c
@@ -99,16 +99,6 @@ Frame *alloc_frame(XRectangle * r)
return f;
}
-void sel_frame(Frame * f, Bool raise)
-{
- Area *a = f->area;
- sel_client(cext_stack_get_top_item(&f->clients));
- cext_stack_top_item(a->layout->get_frames(a), f);
- a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content;
- if (raise)
- XRaiseWindow(dpy, f->win);
-}
-
static int comp_frame_win(void *pattern, void *frame)
{
Window w = *(Window *)pattern;
@@ -293,7 +283,7 @@ void handle_frame_buttonpress(XButtonEvent *e, Frame *f)
/*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);
+ f->area->layout->select(f, True);
if (e->button == Button1) {
align = cursor_to_align(f->cursor);
if (align == CENTER)
diff --git a/cmd/wm/layout_column.c b/cmd/wm/layout_column.c
@@ -30,12 +30,16 @@ 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 void select_col(Area *a, char *arg);
-static void aux_col(Area *a, char *aux);
+static void select_col(Frame *f, Bool raise);
static Container *get_frames_col(Area *a);
+static Action *get_actions_col(Area *a);
+
+static Action lcol_acttbl[] = {
+ {0, 0}
+};
static Layout lcol = { "col", init_col, deinit_col, arrange_col, attach_col, detach_col,
- resize_col, select_col, aux_col, get_frames_col };
+ resize_col, select_col, get_frames_col, get_actions_col };
void init_layout_column()
{
@@ -268,13 +272,15 @@ static void resize_col(Frame *f, XRectangle *new, XPoint *pt)
draw_area(f->area);
}
-static void select_col(Area *a, char *arg)
-{
-
-}
-
-static void aux_col(Area *a, char *aux)
+static void select_col(Frame *f, Bool raise)
{
+ Area *a = f->area;
+ Acme *acme = a->aux;
+ Column *col = f->aux;
+ sel_client(cext_stack_get_top_item(&f->clients));
+ cext_stack_top_item(&col->frames, f);
+ cext_stack_top_item(&acme->frames, f);
+ a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content;
}
static Container *get_frames_col(Area *a)
@@ -283,3 +289,7 @@ static Container *get_frames_col(Area *a)
return &acme->frames;
}
+static Action *get_actions_col(Area *a)
+{
+ return lcol_acttbl;
+}
diff --git a/cmd/wm/layout_float.c b/cmd/wm/layout_float.c
@@ -16,12 +16,19 @@ 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 void select_float(Frame *f, Bool raise);
static Container *get_frames_float(Area *a);
+static Action *get_actions_float(Area *a);
+
+static void select_frame(void *obj, char *arg);
+
+Action lfloat_acttbl[] = {
+ {"select", select_frame},
+ {0, 0}
+};
static Layout lfloat = { "float", init_float, deinit_float, arrange_float, attach_float,
- detach_float, resize_float, select_float, aux_float, get_frames_float };
+ detach_float, resize_float, select_float, get_frames_float, get_actions_float };
void init_layout_float()
{
@@ -75,7 +82,7 @@ static Bool attach_float(Area *a, Client *c)
XMapWindow(dpy, f->win);
if (center)
center_pointer(f);
- sel_frame(f, 1);
+ select_float(f, True);
draw_frame(f, nil);
return True;
}
@@ -96,8 +103,24 @@ static void resize_float(Frame *f, XRectangle *new, XPoint *pt)
f->rect = *new;
}
-static void select_float(Area *a, char *arg)
+static void select_float(Frame *f, Bool raise)
+{
+ Area *a = f->area;
+ sel_client(cext_stack_get_top_item(&f->clients));
+ cext_stack_top_item(a->aux, f);
+ a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content;
+ if (raise)
+ XRaiseWindow(dpy, f->win);
+}
+
+static Container *get_frames_float(Area *a)
+{
+ return a->aux;
+}
+
+static void select_frame(void *obj, char *arg)
{
+ Area *a = obj;
Container *c = a->aux;
Frame *f, *old;
@@ -111,19 +134,14 @@ static void select_float(Area *a, char *arg)
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);
+ select_float(f, True);
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)
+static Action *get_actions_float(Area *a)
{
- return a->aux;
+ return lfloat_acttbl;
}
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -104,11 +104,6 @@ typedef struct Area Area;
typedef struct Frame Frame;
typedef struct Client Client;
-/* new layout interface:
- * /page/[1..n]/0/ floating space
- * /page/[1..n]/[1..n]/ layout space
- */
-
struct Page {
Container areas;
File *file[P_LAST];
@@ -122,9 +117,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 */
- void (*select) (Area *, char *arg); /* called after resize */
- void (*aux) (Area *, char *aux); /* aux interface */
+ void (*select) (Frame *, Bool raise); /* selection */
Container *(*get_frames) (Area *); /* called after resize */
+ Action *(*get_actions) (Area *);
};
struct Area {
@@ -236,7 +231,6 @@ void detach_client(Client *c);
Client *get_sel_client();
/* frame.c */
-void sel_frame(Frame * f, Bool raise);
Frame *win_to_frame(Window w);
Frame *alloc_frame(XRectangle * r);
void destroy_frame(Frame * f);