add a new cache system for arrange()ing

This commit is contained in:
Julien Danjou 2008-01-17 19:17:53 +01:00
parent 5f72c9f056
commit 6e4d13c9dc
12 changed files with 62 additions and 50 deletions

View File

@ -399,6 +399,7 @@ main(int argc, char *argv[])
} }
statusbar_refresh(); statusbar_refresh();
layout_refresh();
/* need to resync */ /* need to resync */
XSync(dpy, False); XSync(dpy, False);

View File

@ -338,7 +338,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
ewmh_update_net_client_list(phys_screen); ewmh_update_net_client_list(phys_screen);
/* rearrange to display new window */ /* rearrange to display new window */
arrange(c->screen); globalconf.screens[c->screen].need_arrange = True;
} }
/** Resize client window /** Resize client window
@ -447,8 +447,12 @@ void
client_setfloating(Client *c, Bool floating) client_setfloating(Client *c, Bool floating)
{ {
if(c->isfloating != floating) if(c->isfloating != floating)
{
if((c->isfloating = floating)) if((c->isfloating = floating))
client_resize(c, c->f_geometry, False); client_resize(c, c->f_geometry, False);
globalconf.screens[c->screen].need_arrange = True;
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
}
} }
/** Save client properties as an X property /** Save client properties as an X property
@ -516,7 +520,8 @@ client_unmanage(Client *c)
XSync(globalconf.display, False); XSync(globalconf.display, False);
XUngrabServer(globalconf.display); XUngrabServer(globalconf.display);
arrange(c->screen); globalconf.screens[c->screen].need_arrange = True;
p_delete(&c); p_delete(&c);
} }
@ -704,14 +709,15 @@ client_find_next_visible(Client *sel)
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_client_swapprev(int screen, char *arg __attribute__ ((unused))) uicb_client_swapprev(int screen __attribute__ ((unused)),
char *arg __attribute__ ((unused)))
{ {
Client *prev; Client *prev;
if((prev = client_find_prev_visible(globalconf.focus->client))) if((prev = client_find_prev_visible(globalconf.focus->client)))
{ {
client_list_swap(&globalconf.clients, prev, globalconf.focus->client); client_list_swap(&globalconf.clients, prev, globalconf.focus->client);
arrange(screen); globalconf.screens[prev->screen].need_arrange = True;
} }
} }
@ -721,14 +727,15 @@ uicb_client_swapprev(int screen, char *arg __attribute__ ((unused)))
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_client_swapnext(int screen, char *arg __attribute__ ((unused))) uicb_client_swapnext(int screen __attribute__ ((unused)),
char *arg __attribute__ ((unused)))
{ {
Client *next; Client *next;
if((next = client_find_next_visible(globalconf.focus->client))) if((next = client_find_next_visible(globalconf.focus->client)))
{ {
client_list_swap(&globalconf.clients, globalconf.focus->client, next); client_list_swap(&globalconf.clients, globalconf.focus->client, next);
arrange(screen); globalconf.screens[next->screen].need_arrange = True;
} }
} }
@ -846,7 +853,6 @@ client_maximize(Client *c, Area geometry)
else else
{ {
client_setfloating(c, False); client_setfloating(c, False);
arrange(c->screen);
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
} }
} }
@ -936,7 +942,7 @@ uicb_client_zoom(int screen, char *arg __attribute__ ((unused)))
client_list_detach(&globalconf.clients, sel); client_list_detach(&globalconf.clients, sel);
client_list_push(&globalconf.clients, sel); client_list_push(&globalconf.clients, sel);
arrange(screen); globalconf.screens[screen].need_arrange = True;
} }
/** Send focus to next client in stack /** Send focus to next client in stack
@ -984,13 +990,14 @@ uicb_client_focusprev(int screen, char *arg __attribute__ ((unused)))
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_client_togglefloating(int screen, char *arg) uicb_client_togglefloating(int screen __attribute__ ((unused)), char *arg)
{ {
Client *sel = globalconf.focus->client; Client *sel = globalconf.focus->client;
if(!sel) if(!sel)
return; return;
/* XXX should use client_setfloating */
if((sel->isfloating = !sel->isfloating)) if((sel->isfloating = !sel->isfloating))
{ {
if(!arg) if(!arg)
@ -998,10 +1005,8 @@ uicb_client_togglefloating(int screen, char *arg)
} }
else if(sel->ismax) else if(sel->ismax)
client_resize(sel, sel->m_geometry, False); client_resize(sel, sel->m_geometry, False);
globalconf.screens[sel->screen].need_arrange = True;
widget_invalidate_cache(sel->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(sel->screen, WIDGET_CACHE_CLIENTS);
client_saveprops(sel);
arrange(screen);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

11
event.c
View File

@ -169,10 +169,10 @@ handle_event_configurerequest(XEvent * e)
if(old_screen != c->screen) if(old_screen != c->screen)
{ {
widget_invalidate_cache(old_screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(old_screen, WIDGET_CACHE_CLIENTS);
arrange(old_screen); globalconf.screens[old_screen].need_arrange = True;
} }
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
arrange(c->screen); globalconf.screens[c->screen].need_arrange = True;
} }
else else
window_configure(c->win, geometry, c->border); window_configure(c->win, geometry, c->border);
@ -215,7 +215,7 @@ handle_event_configurenotify(XEvent * e)
globalconf.screens[screen].statusbar->height); globalconf.screens[screen].statusbar->height);
widget_invalidate_cache(screen, WIDGET_CACHE_ALL); widget_invalidate_cache(screen, WIDGET_CACHE_ALL);
arrange(screen); globalconf.screens[screen].need_arrange = True;
} }
} }
@ -374,8 +374,9 @@ handle_event_propertynotify(XEvent * e)
{ {
case XA_WM_TRANSIENT_FOR: case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(e->xany.display, c->win, &trans); XGetTransientForHint(e->xany.display, c->win, &trans);
if(!c->isfloating && (c->isfloating = (get_client_bywin(globalconf.clients, trans) != NULL))) if(!c->isfloating
arrange(c->screen); && (c->isfloating = (get_client_bywin(globalconf.clients, trans) != NULL)))
globalconf.screens[c->screen].need_arrange = True;
break; break;
case XA_WM_NORMAL_HINTS: case XA_WM_NORMAL_HINTS:
client_updatesizehints(c); client_updatesizehints(c);

2
ewmh.c
View File

@ -275,8 +275,8 @@ ewmh_process_state_atom(Client *c, Atom state, int set)
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
client_resize(c, geometry, False); client_resize(c, geometry, False);
XRaiseWindow(globalconf.display, c->win); XRaiseWindow(globalconf.display, c->win);
globalconf.screens[c->screen].need_arrange = True;
} }
arrange(c->screen);
} }
static void static void

View File

@ -43,7 +43,7 @@ extern AwesomeConf globalconf;
/** Arrange windows following current selected layout /** Arrange windows following current selected layout
* \param screen the screen to arrange * \param screen the screen to arrange
*/ */
void static void
arrange(int screen) arrange(int screen)
{ {
Client *c; Client *c;
@ -77,8 +77,26 @@ arrange(int screen)
p_delete(&curtags); p_delete(&curtags);
restack(screen); restack(screen);
/* reset status */
globalconf.screens[screen].need_arrange = False;
} }
Bool
layout_refresh(void)
{
int screen;
Bool arranged = False;
for(screen = 0; screen < get_screen_count(); screen++)
if(globalconf.screens[screen].need_arrange)
{
arrange(screen);
arranged = True;
}
return arranged;
}
Layout * Layout *
get_current_layout(int screen) get_current_layout(int screen)

View File

@ -38,7 +38,7 @@ struct Layout
DO_SLIST(Layout, layout, p_delete); DO_SLIST(Layout, layout, p_delete);
void arrange(int); Bool layout_refresh(void);
Layout * get_current_layout(int); Layout * get_current_layout(int);
void restack(int); void restack(int);
void loadawesomeprops(int); void loadawesomeprops(int);

View File

@ -48,7 +48,7 @@ uicb_tag_setnmaster(int screen, char * arg)
p_delete(&curtags); p_delete(&curtags);
arrange(screen); globalconf.screens[screen].need_arrange = True;
} }
void void
@ -68,7 +68,7 @@ uicb_tag_setncol(int screen, char * arg)
p_delete(&curtags); p_delete(&curtags);
arrange(screen); globalconf.screens[screen].need_arrange = True;
} }
void void
@ -100,7 +100,7 @@ uicb_tag_setmwfact(int screen, char *arg)
p_delete(&newarg); p_delete(&newarg);
p_delete(&curtags); p_delete(&curtags);
arrange(screen); globalconf.screens[screen].need_arrange = True;
} }
static void static void

View File

@ -217,9 +217,7 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
if(fabs(curtags[0]->mwfact - mwfact) >= 0.05) if(fabs(curtags[0]->mwfact - mwfact) >= 0.05)
{ {
curtags[0]->mwfact = mwfact; curtags[0]->mwfact = mwfact;
arrange(screen); globalconf.screens[screen].need_arrange = True;
/* drop possibly arrived events while we where arrange()ing */
while(XCheckMaskEvent(globalconf.display, PointerMotionMask, &ev));
} }
} }

View File

@ -266,7 +266,8 @@ move_client_to_screen(Client *c, int new_screen, Bool doresize)
else else
{ {
c->f_geometry = new_f_geometry; c->f_geometry = new_f_geometry;
arrange(c->screen); globalconf.screens[old_screen].need_arrange = True;
globalconf.screens[c->screen].need_arrange = True;
} }
} }
} }
@ -346,8 +347,6 @@ uicb_client_movetoscreen(int screen __attribute__ ((unused)), char *arg)
prev_screen = sel->screen; prev_screen = sel->screen;
move_client_to_screen(sel, new_screen, True); move_client_to_screen(sel, new_screen, True);
move_mouse_pointer_to_screen(new_screen); move_mouse_pointer_to_screen(new_screen);
arrange(prev_screen);
arrange(new_screen);
focus(sel, True, sel->screen); focus(sel, True, sel->screen);
/* drop EnterWindow event to keep focus */ /* drop EnterWindow event to keep focus */
XCheckMaskEvent(globalconf.display, EnterWindowMask, &event); XCheckMaskEvent(globalconf.display, EnterWindowMask, &event);

View File

@ -339,7 +339,7 @@ uicb_statusbar_toggle(int screen, char *arg)
for(sb = globalconf.screens[screen].statusbar; sb; sb = sb->next) for(sb = globalconf.screens[screen].statusbar; sb; sb = sb->next)
statusbar_toggle(sb); statusbar_toggle(sb);
arrange(screen); globalconf.screens[screen].need_arrange = True;
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -266,6 +266,8 @@ typedef struct
Bool new_get_focus; Bool new_get_focus;
/** True if new clients should become master */ /** True if new clients should become master */
Bool new_become_master; Bool new_become_master;
/** True if we need to arrange() */
Bool need_arrange;
/** Normal colors */ /** Normal colors */
XColor colors_normal[ColLast]; XColor colors_normal[ColLast];
/** Selected colors */ /** Selected colors */

28
tag.c
View File

@ -77,7 +77,9 @@ tag_client(Client *c, Tag *t)
tc->tag = t; tc->tag = t;
tag_client_node_list_push(&globalconf.tclink, tc); tag_client_node_list_push(&globalconf.tclink, tc);
client_saveprops(c);
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
globalconf.screens[c->screen].need_arrange = True;
} }
void void
@ -93,7 +95,9 @@ untag_client(Client *c, Tag *t)
break; break;
} }
client_saveprops(c);
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
globalconf.screens[c->screen].need_arrange = True;
} }
Bool Bool
@ -201,9 +205,6 @@ uicb_client_tag(int screen, char *arg)
else else
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag_client(sel, tag); tag_client(sel, tag);
client_saveprops(sel);
arrange(screen);
} }
/** Toggle a tag on client /** Toggle a tag on client
@ -247,9 +248,6 @@ uicb_client_toggletag(int screen, char *arg)
tag_client(sel, tag); tag_client(sel, tag);
else else
untag_client(sel, tag); untag_client(sel, tag);
client_saveprops(sel);
arrange(screen);
} }
/** Add a tag to viewed tags /** Add a tag to viewed tags
@ -270,21 +268,16 @@ uicb_tag_toggleview(int screen, char *arg)
target_tag = target_tag->next, i--); target_tag = target_tag->next, i--);
if(target_tag) if(target_tag)
target_tag->selected = !target_tag->selected; tag_view(target_tag, !target_tag->selected);
/* check that there's at least one tag selected */ /* check that there's at least one tag selected */
for(tag = globalconf.screens[screen].tags; tag && !tag->selected; tag = tag->next); for(tag = globalconf.screens[screen].tags; tag && !tag->selected; tag = tag->next);
if(!tag) if(!tag)
target_tag->selected = True; tag_view(target_tag, True);
} }
else else
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag->selected = !tag->selected; tag_view(tag, !tag->selected);
saveawesomeprops(screen);
arrange(screen);
ewmh_update_net_current_desktop(get_phys_screen(screen));
widget_invalidate_cache(screen, WIDGET_CACHE_TAGS);
} }
static void static void
@ -320,6 +313,7 @@ tag_view(Tag *tag, Bool view)
ewmh_update_net_current_desktop(get_phys_screen(tag->screen)); ewmh_update_net_current_desktop(get_phys_screen(tag->screen));
widget_invalidate_cache(tag->screen, WIDGET_CACHE_TAGS); widget_invalidate_cache(tag->screen, WIDGET_CACHE_TAGS);
saveawesomeprops(tag->screen); saveawesomeprops(tag->screen);
globalconf.screens[tag->screen].need_arrange = True;
} }
/** View tag /** View tag
@ -337,8 +331,6 @@ uicb_tag_view(int screen, char *arg)
else else
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
tag_view(tag, True); tag_view(tag, True);
arrange(screen);
} }
/** View previously selected tags /** View previously selected tags
@ -358,8 +350,6 @@ uicb_tag_prev_selected(int screen, char *arg __attribute__ ((unused)))
tag_view(tag, tag->was_selected); tag_view(tag, tag->was_selected);
tag->was_selected = t; tag->was_selected = t;
} }
arrange(screen);
} }
/** View next tag /** View next tag
@ -378,7 +368,6 @@ uicb_tag_viewnext(int screen, char *arg __attribute__ ((unused)))
tag_view(tag, True); tag_view(tag, True);
p_delete(&curtags); p_delete(&curtags);
arrange(screen);
} }
/** View previous tag /** View previous tag
@ -397,7 +386,6 @@ uicb_tag_viewprev(int screen, char *arg __attribute__ ((unused)))
tag_view(tag, True); tag_view(tag, True);
p_delete(&curtags); p_delete(&curtags);
arrange(screen);
} }
void void