From 6f05c9d3273b1f2fddf52c56dd15c816dfa11fbb Mon Sep 17 00:00:00 2001 From: o9000 Date: Tue, 20 Jun 2017 12:57:35 +0200 Subject: [PATCH] Hide executor if output is empty (issue #648) --- src/execplugin/execplugin.c | 43 ++++++++++++++++++++++++------------- src/execplugin/execplugin.h | 3 +++ src/tint.c | 3 +-- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/execplugin/execplugin.c b/src/execplugin/execplugin.c index ae19473..e0724a0 100644 --- a/src/execplugin/execplugin.c +++ b/src/execplugin/execplugin.c @@ -188,6 +188,8 @@ void init_execp_panel(void *p) if (!execp->backend->timer) execp->backend->timer = add_timeout(10, 0, execp_timer_callback, execp, &execp->backend->timer); + + execp_update_post_read(execp); } } @@ -321,21 +323,6 @@ void execp_compute_icon_text_geometry(Execp *execp, *icon_w = *icon_h = 0; } - if ((*icon_h == 0 || *icon_w == 0) && execp->backend->text[0] == 0) { - *new_size = 0; - *txt_height_ink = 0; - *txt_height = 0; - *txt_width = 0; - if (panel_horizontal) { - if (area->width) - *resized = TRUE; - } else { - if (area->height) - *resized = TRUE; - } - return; - } - *text_next_line = !panel_horizontal && *icon_w > area->width / 2; int available_w, available_h; @@ -850,3 +837,29 @@ char *execp_get_tooltip(void *obj) } return strdup(execp->backend->tooltip_text); } + +void execp_update_post_read(Execp *execp) +{ + int icon_h, icon_w; + if (reload_icon(execp)) { + if (execp->backend->icon) { + imlib_context_set_image(execp->backend->icon); + icon_w = imlib_image_get_width(); + icon_h = imlib_image_get_height(); + } else { + icon_w = icon_h = 0; + } + } else { + icon_w = icon_h = 0; + } + + if ((icon_h == 0 || icon_w == 0) && execp->backend->text[0] == 0) { + if (execp->area.on_screen) + hide(&execp->area); + } else { + if (!execp->area.on_screen) + show(&execp->area); + execp->area.resize_needed = TRUE; + schedule_panel_redraw(); + } +} diff --git a/src/execplugin/execplugin.h b/src/execplugin/execplugin.h index 23cb4aa..18432f7 100644 --- a/src/execplugin/execplugin.h +++ b/src/execplugin/execplugin.h @@ -138,6 +138,9 @@ void execp_cmd_completed(Execp *obj, pid_t pid); // Returns 1 if the output has been updated and a redraw is needed. gboolean read_execp(void *obj); +// Called for Execp front elements when the command output has changed. +void execp_update_post_read(Execp *execp); + void execp_default_font_changed(); #endif // EXECPLUGIN_H diff --git a/src/tint.c b/src/tint.c index 8da8350..9ca555d 100644 --- a/src/tint.c +++ b/src/tint.c @@ -1865,8 +1865,7 @@ start: GList *l_instance; for (l_instance = execp->backend->instances; l_instance; l_instance = l_instance->next) { Execp *instance = l_instance->data; - instance->area.resize_needed = TRUE; - schedule_panel_redraw(); + execp_update_post_read(instance); } } }