Don't reallocate the backbuffer on every refresh (thx sECuRE)
This commit is contained in:
parent
9bcdd2f614
commit
fea94757cd
|
@ -56,6 +56,12 @@ void get_atoms();
|
||||||
*/
|
*/
|
||||||
void destroy_window(i3_output *output);
|
void destroy_window(i3_output *output);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reallocate the statusline-buffer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void realloc_sl_buffer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reconfigure all bars and create new for newly activated outputs
|
* Reconfigure all bars and create new for newly activated outputs
|
||||||
*
|
*
|
||||||
|
|
|
@ -93,6 +93,7 @@ void got_output_reply(char *reply) {
|
||||||
DLOG("Parsing Outputs-JSON...\n");
|
DLOG("Parsing Outputs-JSON...\n");
|
||||||
parse_outputs_json(reply);
|
parse_outputs_json(reply);
|
||||||
DLOG("Reconfiguring Windows...\n");
|
DLOG("Reconfiguring Windows...\n");
|
||||||
|
realloc_sl_buffer();
|
||||||
reconfig_windows();
|
reconfig_windows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,22 +186,10 @@ void refresh_statusline() {
|
||||||
xcb_char2b_t *text = (xcb_char2b_t*) convert_utf8_to_ucs2(statusline, &glyph_count);
|
xcb_char2b_t *text = (xcb_char2b_t*) convert_utf8_to_ucs2(statusline, &glyph_count);
|
||||||
statusline_width = predict_text_extents(text, glyph_count);
|
statusline_width = predict_text_extents(text, glyph_count);
|
||||||
|
|
||||||
xcb_free_pixmap(xcb_connection, statusline_pm);
|
xcb_clear_area(xcb_connection, 0, statusline_pm, 0, 0, xcb_screen->width_in_pixels, font_height);
|
||||||
statusline_pm = xcb_generate_id(xcb_connection);
|
|
||||||
xcb_void_cookie_t sl_pm_cookie = xcb_create_pixmap_checked(xcb_connection,
|
|
||||||
xcb_screen->root_depth,
|
|
||||||
statusline_pm,
|
|
||||||
xcb_root,
|
|
||||||
statusline_width,
|
|
||||||
font_height);
|
|
||||||
|
|
||||||
draw_text(statusline_pm, statusline_ctx, 0, 0, text, glyph_count);
|
draw_text(statusline_pm, statusline_ctx, 0, 0, text, glyph_count);
|
||||||
|
|
||||||
FREE(text);
|
FREE(text);
|
||||||
|
|
||||||
if (xcb_request_failed(sl_pm_cookie, "Could not allocate statusline-buffer")) {
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -531,9 +519,14 @@ void init_xcb(char *fontname) {
|
||||||
mask,
|
mask,
|
||||||
vals);
|
vals);
|
||||||
|
|
||||||
/* We only generate an id for the pixmap, because the width of it is dependent on the
|
|
||||||
* input we get */
|
|
||||||
statusline_pm = xcb_generate_id(xcb_connection);
|
statusline_pm = xcb_generate_id(xcb_connection);
|
||||||
|
xcb_void_cookie_t sl_pm_cookie = xcb_create_pixmap_checked(xcb_connection,
|
||||||
|
xcb_screen->root_depth,
|
||||||
|
statusline_pm,
|
||||||
|
xcb_root,
|
||||||
|
xcb_screen->width_in_pixels,
|
||||||
|
xcb_screen->height_in_pixels);
|
||||||
|
|
||||||
|
|
||||||
/* The varios Watchers to communicate with xcb */
|
/* The varios Watchers to communicate with xcb */
|
||||||
xcb_io = malloc(sizeof(ev_io));
|
xcb_io = malloc(sizeof(ev_io));
|
||||||
|
@ -570,6 +563,10 @@ void init_xcb(char *fontname) {
|
||||||
|
|
||||||
DLOG("Calculated Font-height: %d\n", font_height);
|
DLOG("Calculated Font-height: %d\n", font_height);
|
||||||
|
|
||||||
|
if (xcb_request_failed(sl_pm_cookie, "Could not allocate statusline-buffer")) {
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
if (xcb_request_failed(sl_ctx_cookie, "Could not create context for statusline")) {
|
if (xcb_request_failed(sl_ctx_cookie, "Could not create context for statusline")) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -636,6 +633,25 @@ void destroy_window(i3_output *output) {
|
||||||
output->bar = XCB_NONE;
|
output->bar = XCB_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reallocate the statusline-buffer
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void realloc_sl_buffer() {
|
||||||
|
xcb_free_pixmap(xcb_connection, statusline_pm);
|
||||||
|
statusline_pm = xcb_generate_id(xcb_connection);
|
||||||
|
xcb_void_cookie_t sl_pm_cookie = xcb_create_pixmap_checked(xcb_connection,
|
||||||
|
xcb_screen->root_depth,
|
||||||
|
statusline_pm,
|
||||||
|
xcb_root,
|
||||||
|
xcb_screen->width_in_pixels,
|
||||||
|
xcb_screen->height_in_pixels);
|
||||||
|
if (xcb_request_failed(sl_pm_cookie, "Could not allocate statusline-buffer")) {
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reconfigure all bars and create new for newly activated outputs
|
* Reconfigure all bars and create new for newly activated outputs
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue