summaryrefslogtreecommitdiff
path: root/src/charts.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2021-08-26 02:33:32 -0700
committerVito Caputo <vcaputo@pengaru.com>2021-08-26 02:33:32 -0700
commit9d4d28e099fb8e462a36151551d6a8db1263bdd5 (patch)
tree1d3963b7c1bf07946f28489f877362b5166be962 /src/charts.c
parent38ea6aa681cd7c0652ffc56f6976d069ef683229 (diff)
charts: add name to charts overlay
Currently only vmon wires this up to --name, but vwm could get the window title of the window being overlayed and pass that in if set...
Diffstat (limited to 'src/charts.c')
-rw-r--r--src/charts.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/charts.c b/src/charts.c
index fddef35..b25f548 100644
--- a/src/charts.c
+++ b/src/charts.c
@@ -91,6 +91,7 @@ typedef struct _vwm_chart_t {
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...) */
+ char *name; /* name if provided, included in chart by the \/\/\ */
} vwm_chart_t;
/* space we need for every process being monitored */
@@ -852,7 +853,10 @@ static void draw_chart(vwm_charts_t *charts, vwm_chart_t *chart, vmon_proc_t *pr
/* only draw the \/\/\ and HZ if necessary */
if (chart->redraw_needed || charts->prev_sampling_interval != charts->sampling_interval) {
- str_len = snpf(str, sizeof(str), "\\/\\/\\ %2uHz ", interval_as_hz(charts));
+ str_len = snpf(str, sizeof(str), "\\/\\/\\%s%s @ %2uHz ",
+ chart->name ? " # " : "",
+ chart->name ? chart->name : "",
+ interval_as_hz(charts));
XRenderFillRectangle(xserver->display, PictOpSrc, chart->text_picture, &chart_trans_color,
0, 0, /* dst x, y */
chart->visible_width, CHART_ROW_HEIGHT); /* dst w, h */
@@ -1036,7 +1040,7 @@ int vwm_chart_set_visible_size(vwm_charts_t *charts, vwm_chart_t *chart, int wid
/* create an chart and start monitoring for the supplied pid */
-vwm_chart_t * vwm_chart_create(vwm_charts_t *charts, int pid, int width, int height)
+vwm_chart_t * vwm_chart_create(vwm_charts_t *charts, int pid, int width, int height, const char *name)
{
vwm_chart_t *chart;
@@ -1046,6 +1050,14 @@ vwm_chart_t * vwm_chart_create(vwm_charts_t *charts, int pid, int width, int hei
goto _err;
}
+ if (name) {
+ chart->name = strdup(name);
+ if (!chart->name) {
+ VWM_PERROR("Unable to allocate name");
+ goto _err_free;
+ }
+ }
+
/* add the client process to the monitoring heirarchy */
/* XXX note libvmon here maintains a unique callback for each unique callback+xwin pair, so multi-window processes work */
chart->monitor = vmon_proc_monitor(&charts->vmon, NULL, pid, VMON_WANT_PROC_INHERIT, (void (*)(vmon_t *, void *, vmon_proc_t *, void *))proc_sample_callback, chart);
@@ -1070,6 +1082,7 @@ _err_unmonitor:
vmon_proc_unmonitor(&charts->vmon, chart->monitor, (void (*)(vmon_t *, void *, vmon_proc_t *, void *))proc_sample_callback, chart);
_err_free:
+ free(chart->name);
free(chart);
_err:
return NULL;
© All Rights Reserved