mirror of
https://github.com/0intro/wmii
synced 2024-11-22 13:52:17 +03:00
reduced draw_frame operations drastically, centralized call to select_frame function
This commit is contained in:
parent
d2683b3e4b
commit
1c8092146a
@ -62,11 +62,6 @@ void sel_area(Area *a)
|
||||
a->layout->select(f, False);
|
||||
}
|
||||
|
||||
void draw_area(Area *a)
|
||||
{
|
||||
cext_list_iterate(a->layout->get_frames(a), nil, draw_frame);
|
||||
}
|
||||
|
||||
static void iter_hide_area(void *item, void *aux)
|
||||
{
|
||||
XUnmapWindow(dpy, ((Frame *)item)->win);
|
||||
@ -122,7 +117,6 @@ static void iter_after_write_area(void *item, void *aux)
|
||||
a->layout->init(a);
|
||||
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
|
||||
}
|
||||
draw_page(a->page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +294,6 @@ void gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert)
|
||||
void attach_client(Client * c)
|
||||
{
|
||||
Area *a = 0;
|
||||
Frame *old = get_sel_frame();
|
||||
if (!cext_sizeof_container(&pages))
|
||||
alloc_page();
|
||||
/* transient stuff */
|
||||
@ -306,8 +305,6 @@ void attach_client(Client * c)
|
||||
}
|
||||
cext_attach_item(&a->clients, c);
|
||||
a->layout->attach(a, c);
|
||||
if (old)
|
||||
draw_frame(old, nil);
|
||||
invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]);
|
||||
}
|
||||
|
||||
@ -321,10 +318,8 @@ void detach_client(Client *c, Bool unmap) {
|
||||
}
|
||||
if (c->destroyed)
|
||||
destroy_client(c);
|
||||
if ((p = get_sel_page())) {
|
||||
if ((p = get_sel_page()))
|
||||
sel_page(p);
|
||||
draw_page(p);
|
||||
}
|
||||
}
|
||||
|
||||
Client *get_sel_client()
|
||||
|
@ -187,7 +187,7 @@ static void handle_expose(XEvent * e)
|
||||
if (e->xexpose.count == 0) {
|
||||
f = win_to_frame(e->xbutton.window);
|
||||
if (f)
|
||||
draw_frame(f, nil);
|
||||
draw_frame(f);
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,12 +266,8 @@ static void handle_enternotify(XEvent * e)
|
||||
/*fprintf(stderr, "%s\n", "handle_enternotify");*/
|
||||
c = win_to_client(ev->window);
|
||||
if (c && c->frame) {
|
||||
Frame *old = get_sel_frame();
|
||||
sel_area(c->frame->area);
|
||||
c->frame->area->layout->select(c->frame, False);
|
||||
draw_frame(c->frame, nil);
|
||||
if (old && old != c->frame)
|
||||
draw_frame(old, nil);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,9 +238,8 @@ void resize_frame(Frame * f, XRectangle * r, XPoint * pt)
|
||||
* ./norm-style/bg-color "#RRGGBBAA"
|
||||
* ./norm-style/border-color "#RRGGBBAA [#RRGGBBAA [#RRGGBBAA [#RRGGBBAA]]]"
|
||||
*/
|
||||
void draw_frame(void *frame, void *aux)
|
||||
void draw_frame(Frame *f)
|
||||
{
|
||||
Frame *f = frame;
|
||||
Draw d = { 0 };
|
||||
int bw = border_width(f);
|
||||
XRectangle notch;
|
||||
@ -295,7 +294,6 @@ void handle_frame_buttonpress(XButtonEvent *e, Frame *f)
|
||||
/* frame mouse handling */
|
||||
if (f->file[bindex]->content)
|
||||
wmii_spawn(dpy, f->file[bindex]->content);
|
||||
draw_frame(f, nil);
|
||||
}
|
||||
|
||||
void attach_client_to_frame(Frame *f, Client *c)
|
||||
@ -329,7 +327,7 @@ void detach_client_from_frame(Client *c, Bool unmap)
|
||||
}
|
||||
if ((client = cext_stack_get_top_item(&f->clients))) {
|
||||
sel_client(client);
|
||||
draw_frame(f, nil);
|
||||
f->area->layout->select(f, False);
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,7 +346,7 @@ static void select_client(void *obj, char *arg)
|
||||
else
|
||||
c = cext_list_get_item(&f->clients, blitz_strtonum(arg, 0, cext_sizeof_container(&f->clients) - 1));
|
||||
sel_client(c);
|
||||
draw_frame(f, nil);
|
||||
f->area->layout->select(f, False);
|
||||
}
|
||||
|
||||
static void iter_before_read_frame(void *item, void *aux)
|
||||
@ -380,7 +378,6 @@ static void iter_after_write_frame(void *item, void *aux)
|
||||
}
|
||||
if (file == f->file[F_TAB] || file == f->file[F_BORDER] || file == f->file[F_HANDLE_INC]) {
|
||||
f->area->layout->arrange(f->area);
|
||||
draw_page(f->area->page);
|
||||
return;
|
||||
} else if (file == f->file[F_GEOMETRY]) {
|
||||
char *geom = f->file[F_GEOMETRY]->content;
|
||||
@ -388,7 +385,6 @@ static void iter_after_write_frame(void *item, void *aux)
|
||||
XRectangle frect = f->rect;
|
||||
blitz_strtorect(&rect, &frect, geom);
|
||||
resize_frame(f, &frect, 0);
|
||||
draw_page(f->area->page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,9 +149,9 @@ static Bool attach_col(Area *a, Client *c)
|
||||
cext_attach_item(&col->frames, f);
|
||||
}
|
||||
attach_client_to_frame(f, c);
|
||||
iter_arrange_column(col, a);
|
||||
if (a->page == get_sel_page())
|
||||
XMapWindow(dpy, f->win);
|
||||
iter_arrange_column(col, a);
|
||||
select_col(f, True);
|
||||
return True;
|
||||
}
|
||||
@ -315,7 +315,6 @@ static void resize_col(Frame *f, XRectangle *new, XPoint *pt)
|
||||
drop_moving(f, new, pt);
|
||||
else
|
||||
drop_resize(f, new);
|
||||
draw_area(f->area);
|
||||
}
|
||||
|
||||
static void select_col(Frame *f, Bool raise)
|
||||
@ -323,6 +322,8 @@ static void select_col(Frame *f, Bool raise)
|
||||
Area *a = f->area;
|
||||
Acme *acme = a->aux;
|
||||
Column *col = f->aux;
|
||||
Frame *old = get_sel_frame();
|
||||
|
||||
cext_stack_top_item(&acme->columns, col);
|
||||
sel_client(cext_stack_get_top_item(&f->clients));
|
||||
cext_stack_top_item(&col->frames, f);
|
||||
@ -330,6 +331,9 @@ static void select_col(Frame *f, Bool raise)
|
||||
a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content;
|
||||
if (raise)
|
||||
center_pointer(f);
|
||||
if (old != f)
|
||||
draw_frame(old);
|
||||
draw_frame(f);
|
||||
}
|
||||
|
||||
static Container *get_frames_col(Area *a)
|
||||
@ -348,12 +352,12 @@ static void select_frame(void *obj, char *arg)
|
||||
Area *a = obj;
|
||||
Acme *acme = a->aux;
|
||||
Column *col = get_sel_column(acme);
|
||||
Frame *f, *old;
|
||||
Frame *f;
|
||||
|
||||
if (!col)
|
||||
return;
|
||||
|
||||
f = old = cext_stack_get_top_item(&col->frames);
|
||||
f = cext_stack_get_top_item(&col->frames);
|
||||
if (!f || !arg)
|
||||
return;
|
||||
if (!strncmp(arg, "prev", 5))
|
||||
@ -372,11 +376,7 @@ static void select_frame(void *obj, char *arg)
|
||||
}
|
||||
else
|
||||
f = cext_list_get_item(&col->frames, blitz_strtonum(arg, 0, cext_sizeof_container(&col->frames) - 1));
|
||||
if (f && old != f) {
|
||||
select_col(f, True);
|
||||
draw_frame(old, nil);
|
||||
draw_frame(f, nil);
|
||||
}
|
||||
}
|
||||
|
||||
static void swap_frame(void *obj, char *arg)
|
||||
@ -459,7 +459,6 @@ static void swap_frame(void *obj, char *arg)
|
||||
resize_frame(other, &other->rect, nil);
|
||||
select_col(f, True);
|
||||
}
|
||||
draw_frame(f, nil);
|
||||
}
|
||||
|
||||
static void new_col(void *obj, char *arg)
|
||||
@ -479,5 +478,4 @@ static void new_col(void *obj, char *arg)
|
||||
cext_attach_item(&acme->columns, col);
|
||||
update_column_width(a);
|
||||
select_col(f, True);
|
||||
draw_frame(f, nil);
|
||||
}
|
||||
|
@ -85,7 +85,6 @@ static Bool attach_float(Area *a, Client *c)
|
||||
if (a->page == get_sel_page())
|
||||
XMapWindow(dpy, f->win);
|
||||
select_float(f, True);
|
||||
draw_frame(f, nil);
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -108,6 +107,8 @@ static void resize_float(Frame *f, XRectangle *new, XPoint *pt)
|
||||
static void select_float(Frame *f, Bool raise)
|
||||
{
|
||||
Area *a = f->area;
|
||||
Frame *old = get_sel_frame();
|
||||
|
||||
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;
|
||||
@ -115,6 +116,9 @@ static void select_float(Frame *f, Bool raise)
|
||||
XRaiseWindow(dpy, f->win);
|
||||
center_pointer(f);
|
||||
}
|
||||
if (old != f)
|
||||
draw_frame(old);
|
||||
draw_frame(f);
|
||||
}
|
||||
|
||||
static Container *get_frames_float(Area *a)
|
||||
@ -126,9 +130,9 @@ static void select_frame(void *obj, char *arg)
|
||||
{
|
||||
Area *a = obj;
|
||||
Container *c = a->aux;
|
||||
Frame *f, *old;
|
||||
Frame *f;
|
||||
|
||||
f = old = cext_stack_get_top_item(c);
|
||||
f = cext_stack_get_top_item(c);
|
||||
if (!f || !arg)
|
||||
return;
|
||||
if (!strncmp(arg, "prev", 5))
|
||||
@ -137,12 +141,8 @@ static void select_frame(void *obj, char *arg)
|
||||
f = cext_list_get_next_item(c, f);
|
||||
else
|
||||
f = cext_list_get_item(c, blitz_strtonum(arg, 0, cext_sizeof_container(c) - 1));
|
||||
if (old != f) {
|
||||
select_float(f, True);
|
||||
center_pointer(f);
|
||||
draw_frame(old, nil);
|
||||
draw_frame(f, nil);
|
||||
}
|
||||
}
|
||||
|
||||
static Action *get_actions_float(Area *a)
|
||||
|
@ -325,7 +325,6 @@ void mouse_move(Frame * f)
|
||||
draw_pseudo_border(&frect);
|
||||
resize_frame(f, &frect, &pt);
|
||||
}
|
||||
draw_page(get_sel_page());
|
||||
free(rects);
|
||||
XUngrabPointer(dpy, CurrentTime /* ev.xbutton.time */ );
|
||||
XUngrabServer(dpy);
|
||||
|
@ -80,16 +80,6 @@ void sel_page(Page * p)
|
||||
sel_area(get_sel_area());
|
||||
}
|
||||
|
||||
static void iter_draw_page(void *item, void *aux)
|
||||
{
|
||||
draw_area((Area *)item);
|
||||
}
|
||||
|
||||
void draw_page(Page * p)
|
||||
{
|
||||
cext_list_iterate(&p->areas, nil, iter_draw_page);
|
||||
}
|
||||
|
||||
XRectangle *rectangles(unsigned int *num)
|
||||
{
|
||||
XRectangle *result = 0;
|
||||
|
@ -204,7 +204,6 @@ unsigned int valid_mask, num_lock_mask;
|
||||
Area *alloc_area(Page *p, char *layout);
|
||||
void destroy_area(Area * a);
|
||||
void sel_area(Area * a);
|
||||
void draw_area(Area * a);
|
||||
void hide_area(Area * a);
|
||||
void show_area(Area * a);
|
||||
Area *get_sel_area();
|
||||
@ -236,7 +235,7 @@ Frame *win_to_frame(Window w);
|
||||
Frame *alloc_frame(XRectangle * r);
|
||||
void destroy_frame(Frame * f);
|
||||
void resize_frame(Frame *f, XRectangle *r, XPoint *pt);
|
||||
void draw_frame(void *frame, void *aux);
|
||||
void draw_frame(Frame *f);
|
||||
void handle_frame_buttonpress(XButtonEvent *e, Frame *f);
|
||||
void attach_client_to_frame(Frame *f, Client *c);
|
||||
void detach_client_from_frame(Client *c, Bool unmap);
|
||||
@ -267,7 +266,6 @@ void sel_page(Page *p);
|
||||
XRectangle *rectangles(unsigned int *num);
|
||||
void hide_page(Page * p);
|
||||
void show_page(Page * p);
|
||||
void draw_page(Page * p);
|
||||
|
||||
/* layout.c */
|
||||
Layout *get_layout(char *name);
|
||||
|
Loading…
Reference in New Issue
Block a user