From ea75558ac2c0e357b96caa38a9835e2d1e86893c Mon Sep 17 00:00:00 2001 From: o9000 Date: Sun, 21 Jun 2015 15:00:01 +0200 Subject: [PATCH] systray: reduce icon flicker by painting on buffer instead of directly on window --- src/systray/systraybar.c | 2 +- src/tint.c | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/systray/systraybar.c b/src/systray/systraybar.c index 57f33f7..da3c9fa 100644 --- a/src/systray/systraybar.c +++ b/src/systray/systraybar.c @@ -923,7 +923,7 @@ void systray_render_icon_composited(void* t) imlib_image_put_back_data(data); XCopyArea(server.dsp, render_background, systray.area.pix, server.gc, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height, traywin->x-systray.area.posx, traywin->y-systray.area.posy); render_image(systray.area.pix, traywin->x-systray.area.posx, traywin->y-systray.area.posy); - XCopyArea(server.dsp, systray.area.pix, panel->main_win, server.gc, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height, traywin->x, traywin->y); + XCopyArea(server.dsp, systray.area.pix, panel->temp_pmap, server.gc, traywin->x-systray.area.posx, traywin->y-systray.area.posy, traywin->width, traywin->height, traywin->x, traywin->y); imlib_free_image_and_decache(); XFreePixmap(server.dsp, tmp_pmap); imlib_context_set_visual(server.visual); diff --git a/src/tint.c b/src/tint.c index 455a3fa..692dd53 100644 --- a/src/tint.c +++ b/src/tint.c @@ -1133,29 +1133,27 @@ start: fprintf(stderr, BLUE "[%f] %s:%d redrawing panel\n" RESET, profiling_get_time(), __FUNCTION__, __LINE__); panel_refresh = 0; - for (i=0 ; i < nb_panel ; i++) { + for (i = 0; i < nb_panel ;i++) { panel = &panel1[i]; if (panel->is_hidden) { XCopyArea(server.dsp, panel->hidden_pixmap, panel->main_win, server.gc, 0, 0, panel->hidden_width, panel->hidden_height, 0, 0); XSetWindowBackgroundPixmap(server.dsp, panel->main_win, panel->hidden_pixmap); - } - else { - if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap); + } else { + if (panel->temp_pmap) + XFreePixmap(server.dsp, panel->temp_pmap); panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth); rendering(panel); + if (panel == (Panel*)systray.area.panel) { + if (refresh_systray && panel && !panel->is_hidden) { + refresh_systray = 0; + XSetWindowBackgroundPixmap(server.dsp, panel->main_win, panel->temp_pmap); + refresh_systray_icons(); + } + } XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0); } } - - panel = (Panel*)systray.area.panel; - if (refresh_systray && panel && !panel->is_hidden) { - refresh_systray = 0; - // tint2 doen't draw systray icons. it just redraw background. - XSetWindowBackgroundPixmap(server.dsp, panel->main_win, panel->temp_pmap); - // force icon's refresh - refresh_systray_icons(); - } XFlush(server.dsp); }