From 206baa8b9a00a2da8cb914fb2164419a860f5968 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Fri, 30 Sep 2016 10:50:19 +0300 Subject: [PATCH] (widget_is_active): support groups. --- lib/widget/widget-common.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/widget/widget-common.c b/lib/widget/widget-common.c index 25fe7e02a..a5636af0e 100644 --- a/lib/widget/widget-common.c +++ b/lib/widget/widget-common.c @@ -503,6 +503,8 @@ widget_erase (Widget * w) /* --------------------------------------------------------------------------------------------- */ /** * Check whether widget is active or not. + * Widget is active if it's current in the its owner and each owner in the chain is current too. + * * @param w the widget * * @return TRUE if the widget is active, FALSE otherwise @@ -511,7 +513,22 @@ widget_erase (Widget * w) gboolean widget_is_active (const void *w) { - return (w == CONST_WIDGET (w)->owner->current->data); + const WGroup *owner; + + /* Is group top? */ + if (w == top_dlg->data) + return TRUE; + + owner = CONST_WIDGET (w)->owner; + + /* Is widget in any group? */ + if (owner == NULL) + return FALSE; + + if (w != owner->current->data) + return FALSE; + + return widget_is_active (owner); } /* --------------------------------------------------------------------------------------------- */