diff options
author | Vito Caputo <vcaputo@gnugeneration.com> | 2016-09-08 10:27:29 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@gnugeneration.com> | 2016-09-09 14:17:08 -0700 |
commit | 7a5e600e8f67f6fa170d3bd27de7e28150c2dca5 (patch) | |
tree | 733ece0d586adab2dc266d3d099261d79efadc8f | |
parent | 7f8473326aaff2381f9ed012f6fb54b2691526f1 (diff) |
overlay: introduce overlay.redraw_needed
Set on window resize, clear on draw_overlay() return.
Used in combination with sample_interval check to gate HZ redraw.
Will be used to gate redraw of process monitors heirarchy as well,
in a subsequent commit.
-rw-r--r-- | src/overlay.c | 12 | ||||
-rw-r--r-- | src/overlay.h | 27 |
2 files changed, 20 insertions, 19 deletions
diff --git a/src/overlay.c b/src/overlay.c index e223d08..d53a864 100644 --- a/src/overlay.c +++ b/src/overlay.c @@ -542,13 +542,9 @@ static void draw_overlay(vwm_t *vwm, vwm_xwindow_t *xwin, vmon_proc_t *proc, int /* IOWait and Idle % @ row 0 */ draw_bars(vwm, xwin, *row, iowait_delta, total_delta, idle_delta, total_delta); - /* here's where the Idle/IOWait row drawing concludes */ - if (1 /* FIXME TODO compositing_mode*/) { + /* only draw the \/\/\ and HZ if necessary */ + if (xwin->overlay.redraw_needed || prev_sampling_interval != sampling_interval) { snprintf(str, sizeof(str), "\\/\\/\\ %2iHz %n", (int)(sampling_interval < 0 ? 0 : 1 / sampling_intervals[sampling_interval]), &str_len); - /* TODO: I clear and redraw this row every time, which is unnecessary, small optimization would be to only do so when: - * - overlay resized, and then constrain the clear to the affected width - * - Hz changed - */ XRenderFillRectangle(vwm->display, PictOpSrc, xwin->overlay.text_picture, &overlay_trans_color, 0, 0, /* dst x, y */ xwin->attrs.width, OVERLAY_ROW_HEIGHT); /* dst w, h */ @@ -562,6 +558,8 @@ static void draw_overlay(vwm_t *vwm, vwm_xwindow_t *xwin, vmon_proc_t *proc, int draw_overlay_rest(vwm, xwin, proc, depth, row); + xwin->overlay.redraw_needed = 0; + return; } @@ -585,6 +583,8 @@ static void maintain_overlay(vwm_t *vwm, vwm_xwindow_t *xwin) * For now, the monitors will just be a little latent in window resizes which is pretty harmless artifact. */ + if (xwin->attrs.width != xwin->overlay.width || xwin->attrs.height != xwin->overlay.height) xwin->overlay.redraw_needed = 1; + /* if the window is larger than the overlays currently are, enlarge them */ if (xwin->attrs.width > xwin->overlay.width || xwin->attrs.height > xwin->overlay.height) { vwm_overlay_t existing; diff --git a/src/overlay.h b/src/overlay.h index 94e2dca..dd60319 100644 --- a/src/overlay.h +++ b/src/overlay.h @@ -9,19 +9,20 @@ typedef struct _vwm_xwindow_t vwm_xwindow_t; /* everything needed by the per-window overlay's context */ typedef struct _vwm_overlay_t { - Pixmap text_pixmap; /* pixmap for overlayed text (kept around for XDrawText usage) */ - Picture text_picture; /* picture representation of text_pixmap */ - Picture shadow_picture; /* text shadow layer */ - Picture grapha_picture; /* graph A layer */ - Picture graphb_picture; /* graph B layer */ - Picture tmp_picture; /* 1 row worth of temporary picture space */ - Picture picture; /* overlay picture derived from the pixmap, for render compositing */ - int width; /* current width of the overlay */ - int height; /* current height of the overlay */ - int phase; /* current position within the (horizontally scrolling) graphs */ - int heirarchy_end; /* row where the process heirarchy currently ends */ - int snowflakes_cnt; /* count of snowflaked rows (reset to zero to truncate snowflakes display) */ - int gen_last_composed; /* the last composed vmon generation */ + Pixmap text_pixmap; /* pixmap for overlayed text (kept around for XDrawText usage) */ + Picture text_picture; /* picture representation of text_pixmap */ + Picture shadow_picture; /* text shadow layer */ + Picture grapha_picture; /* graph A layer */ + Picture graphb_picture; /* graph B layer */ + Picture tmp_picture; /* 1 row worth of temporary picture space */ + Picture picture; /* overlay picture derived from the pixmap, for render compositing */ + int width; /* current width of the overlay */ + int height; /* current height of the overlay */ + int phase; /* current position within the (horizontally scrolling) graphs */ + int heirarchy_end; /* row where the process heirarchy currently ends */ + int snowflakes_cnt; /* count of snowflaked rows (reset to zero to truncate snowflakes display) */ + int gen_last_composed; /* the last composed vmon generation */ + int redraw_needed; /* if a redraw is required (like when the window is resized...) */ } vwm_overlay_t; int vwm_overlay_xwin_composed_height(vwm_t *vwm, vwm_xwindow_t *xwin); |