titlebar: use need_update system (like statusbar, …)

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-07-31 14:10:54 +02:00
parent 18fab522f9
commit 063bf2083d
6 changed files with 30 additions and 8 deletions

View File

@ -169,12 +169,14 @@ a_xcb_check_cb(EV_P_ ev_check *w, int revents)
layout_refresh(); layout_refresh();
statusbar_refresh(); statusbar_refresh();
titlebar_refresh();
/* need to resync */ /* need to resync */
xcb_aux_sync(globalconf.connection); xcb_aux_sync(globalconf.connection);
} }
layout_refresh(); layout_refresh();
statusbar_refresh(); statusbar_refresh();
titlebar_refresh();
xcb_aux_sync(globalconf.connection); xcb_aux_sync(globalconf.connection);
} }
@ -465,6 +467,7 @@ main(int argc, char **argv)
/* refresh everything before waiting events */ /* refresh everything before waiting events */
layout_refresh(); layout_refresh();
statusbar_refresh(); statusbar_refresh();
titlebar_refresh();
/* main event loop */ /* main event loop */
ev_loop(globalconf.loop, 0); ev_loop(globalconf.loop, 0);

View File

@ -686,6 +686,8 @@ mouse_client_resize_floating(client_t *c, corner_t corner, bool infobox)
/* resize the client */ /* resize the client */
client_resize(c, geo, false); client_resize(c, geo, false);
/* redaw titlebar live */
titlebar_draw(c);
/* draw the infobox */ /* draw the infobox */
if(sw) if(sw)

View File

@ -182,6 +182,8 @@ struct titlebar_t
xcolor_t color; xcolor_t color;
int width; int width;
} border; } border;
/** Need update */
bool need_update;
}; };
/** Delete a titlebar structure. /** Delete a titlebar structure.

View File

@ -138,6 +138,20 @@ titlebar_draw(client_t *c)
simplewindow_refresh_pixmap(c->titlebar->sw); simplewindow_refresh_pixmap(c->titlebar->sw);
draw_context_delete(&ctx); 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 void
@ -280,7 +294,7 @@ titlebar_init(client_t *c)
if(client_isvisible(c, c->screen)) if(client_isvisible(c, c->screen))
globalconf.screens[c->screen].need_arrange = true; globalconf.screens[c->screen].need_arrange = true;
titlebar_draw(c); c->titlebar->need_update = true;
} }
/** Create a new titlebar. /** Create a new titlebar.
@ -365,7 +379,7 @@ luaA_titlebar_widget_add(lua_State *L)
widget_node_list_append(&(*tb)->widgets, w); widget_node_list_append(&(*tb)->widgets, w);
widget_ref(widget); widget_ref(widget);
titlebar_draw(client_getbytitlebar(*tb)); (*tb)->need_update = true;
return 0; return 0;
} }
@ -394,7 +408,7 @@ luaA_titlebar_widget_remove(lua_State *L)
widget_unref(widget); widget_unref(widget);
widget_node_list_detach(&(*tb)->widgets, w); widget_node_list_detach(&(*tb)->widgets, w);
p_delete(&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((buf = luaL_checklstring(L, 3, &len)))
if(xcolor_init(&(*titlebar)->colors.fg, globalconf.connection, if(xcolor_init(&(*titlebar)->colors.fg, globalconf.connection,
globalconf.default_screen, buf, len)) globalconf.default_screen, buf, len))
titlebar_draw(client_getbytitlebar(*titlebar)); (*titlebar)->need_update = true;
return 0; return 0;
case A_TK_BG: case A_TK_BG:
if((buf = luaL_checklstring(L, 3, &len))) if((buf = luaL_checklstring(L, 3, &len)))
if(xcolor_init(&(*titlebar)->colors.bg, globalconf.connection, if(xcolor_init(&(*titlebar)->colors.bg, globalconf.connection,
globalconf.default_screen, buf, len)) globalconf.default_screen, buf, len))
titlebar_draw(client_getbytitlebar(*titlebar)); (*titlebar)->need_update = true;
return 0; return 0;
default: default:
return 0; return 0;

View File

@ -29,6 +29,7 @@ client_t * client_getbytitlebarwin(xcb_window_t);
void titlebar_geometry_compute(client_t *, area_t, area_t *); void titlebar_geometry_compute(client_t *, area_t, area_t *);
void titlebar_draw(client_t *); void titlebar_draw(client_t *);
void titlebar_init(client_t *); void titlebar_init(client_t *);
void titlebar_refresh(void);
int luaA_titlebar_userdata_new(lua_State *, titlebar_t *); 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); titlebar_geometry_compute(c, c->geometry, &geom);
simplewindow_moveresize(c->titlebar->sw, geom.x, geom.y, geom.width, geom.height); 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. /** 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); titlebar_geometry_compute(c, geometry, &geom);
simplewindow_moveresize(c->titlebar->sw, geom.x, geom.y, geom.width, geom.height); simplewindow_moveresize(c->titlebar->sw, geom.x, geom.y, geom.width, geom.height);
titlebar_draw(c); c->titlebar->need_update = true;
} }
#endif #endif

View File

@ -245,7 +245,7 @@ widget_invalidate_bywidget(widget_t *widget)
if(c->titlebar) if(c->titlebar)
for(witer = c->titlebar->widgets; witer; witer = witer->next) for(witer = c->titlebar->widgets; witer; witer = witer->next)
if(witer->widget == widget) if(witer->widget == widget)
titlebar_draw(c); c->titlebar->need_update = true;
} }
/** Create a new widget. /** Create a new widget.