From 063bf2083dea113d4e664da27aeb693407cf4b1d Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 31 Jul 2008 14:10:54 +0200 Subject: [PATCH] =?UTF-8?q?titlebar:=20use=20need=5Fupdate=20system=20(lik?= =?UTF-8?q?e=20statusbar,=20=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julien Danjou --- awesome.c | 3 +++ mouse.c | 2 ++ structs.h | 2 ++ titlebar.c | 24 +++++++++++++++++++----- titlebar.h | 5 +++-- widget.c | 2 +- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/awesome.c b/awesome.c index af5c2446..e6358b4e 100644 --- a/awesome.c +++ b/awesome.c @@ -169,12 +169,14 @@ a_xcb_check_cb(EV_P_ ev_check *w, int revents) layout_refresh(); statusbar_refresh(); + titlebar_refresh(); /* need to resync */ xcb_aux_sync(globalconf.connection); } layout_refresh(); statusbar_refresh(); + titlebar_refresh(); xcb_aux_sync(globalconf.connection); } @@ -465,6 +467,7 @@ main(int argc, char **argv) /* refresh everything before waiting events */ layout_refresh(); statusbar_refresh(); + titlebar_refresh(); /* main event loop */ ev_loop(globalconf.loop, 0); diff --git a/mouse.c b/mouse.c index 11cad9c8..67d11db7 100644 --- a/mouse.c +++ b/mouse.c @@ -686,6 +686,8 @@ mouse_client_resize_floating(client_t *c, corner_t corner, bool infobox) /* resize the client */ client_resize(c, geo, false); + /* redaw titlebar live */ + titlebar_draw(c); /* draw the infobox */ if(sw) diff --git a/structs.h b/structs.h index e0e1a7d7..839d799f 100644 --- a/structs.h +++ b/structs.h @@ -182,6 +182,8 @@ struct titlebar_t xcolor_t color; int width; } border; + /** Need update */ + bool need_update; }; /** Delete a titlebar structure. diff --git a/titlebar.c b/titlebar.c index 433007c8..ec3e176f 100644 --- a/titlebar.c +++ b/titlebar.c @@ -138,6 +138,20 @@ titlebar_draw(client_t *c) simplewindow_refresh_pixmap(c->titlebar->sw); draw_context_delete(&ctx); + + c->titlebar->need_update = false; +} + +/** Titlebar refresh function. + */ +void +titlebar_refresh(void) +{ + client_t *c; + + for(c = globalconf.clients; c; c = c->next) + if(c->titlebar && c->titlebar->need_update) + titlebar_draw(c); } void @@ -280,7 +294,7 @@ titlebar_init(client_t *c) if(client_isvisible(c, c->screen)) globalconf.screens[c->screen].need_arrange = true; - titlebar_draw(c); + c->titlebar->need_update = true; } /** Create a new titlebar. @@ -365,7 +379,7 @@ luaA_titlebar_widget_add(lua_State *L) widget_node_list_append(&(*tb)->widgets, w); widget_ref(widget); - titlebar_draw(client_getbytitlebar(*tb)); + (*tb)->need_update = true; return 0; } @@ -394,7 +408,7 @@ luaA_titlebar_widget_remove(lua_State *L) widget_unref(widget); widget_node_list_detach(&(*tb)->widgets, w); p_delete(&w); - titlebar_draw(client_getbytitlebar(*tb)); + (*tb)->need_update = true; } } @@ -488,13 +502,13 @@ luaA_titlebar_newindex(lua_State *L) if((buf = luaL_checklstring(L, 3, &len))) if(xcolor_init(&(*titlebar)->colors.fg, globalconf.connection, globalconf.default_screen, buf, len)) - titlebar_draw(client_getbytitlebar(*titlebar)); + (*titlebar)->need_update = true; return 0; case A_TK_BG: if((buf = luaL_checklstring(L, 3, &len))) if(xcolor_init(&(*titlebar)->colors.bg, globalconf.connection, globalconf.default_screen, buf, len)) - titlebar_draw(client_getbytitlebar(*titlebar)); + (*titlebar)->need_update = true; return 0; default: return 0; diff --git a/titlebar.h b/titlebar.h index 106b6493..28ac222c 100644 --- a/titlebar.h +++ b/titlebar.h @@ -29,6 +29,7 @@ client_t * client_getbytitlebarwin(xcb_window_t); void titlebar_geometry_compute(client_t *, area_t, area_t *); void titlebar_draw(client_t *); void titlebar_init(client_t *); +void titlebar_refresh(void); int luaA_titlebar_userdata_new(lua_State *, titlebar_t *); @@ -111,7 +112,7 @@ titlebar_update_geometry_floating(client_t *c) titlebar_geometry_compute(c, c->geometry, &geom); simplewindow_moveresize(c->titlebar->sw, geom.x, geom.y, geom.width, geom.height); - titlebar_draw(c); + c->titlebar->need_update = true; } /** Update the titlebar geometry for a tiled client. @@ -128,7 +129,7 @@ titlebar_update_geometry_tiled(client_t *c, area_t geometry) titlebar_geometry_compute(c, geometry, &geom); simplewindow_moveresize(c->titlebar->sw, geom.x, geom.y, geom.width, geom.height); - titlebar_draw(c); + c->titlebar->need_update = true; } #endif diff --git a/widget.c b/widget.c index 8425b942..41c7ccb7 100644 --- a/widget.c +++ b/widget.c @@ -245,7 +245,7 @@ widget_invalidate_bywidget(widget_t *widget) if(c->titlebar) for(witer = c->titlebar->widgets; witer; witer = witer->next) if(witer->widget == widget) - titlebar_draw(c); + c->titlebar->need_update = true; } /** Create a new widget.