From 0cc16e7d2784d3946c2da6cb83c78abe8dbc975c Mon Sep 17 00:00:00 2001 From: Dennis van der Schagt Date: Tue, 14 Apr 2020 16:39:34 +0200 Subject: [PATCH] list widget: Update "pos_name" attribute after every change to "pos" --- widgets/wt_list.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/widgets/wt_list.c b/widgets/wt_list.c index 9fec07e..9ec9e7d 100644 --- a/widgets/wt_list.c +++ b/widgets/wt_list.c @@ -71,10 +71,12 @@ static void fix_offset_pos(struct stfl_widget *w) int i; int maxpos = -1; struct stfl_widget *c; + struct stfl_widget *latest_widget = NULL; for (i=0, c=w->first_child; c; i++, c=c->next_sibling) { if (stfl_widget_getkv_int(c, L"can_focus", 1) && - stfl_widget_getkv_int(c, L".display", 1)) + stfl_widget_getkv_int(c, L".display", 1)) maxpos= i; + latest_widget = c; if(maxpos == pos) break; } @@ -88,8 +90,8 @@ static void fix_offset_pos(struct stfl_widget *w) if (pos != orig_pos) stfl_widget_setkv_int(w, L"pos", pos); - if (c) - stfl_widget_setkv_str(w, L"pos_name", c->name ? c->name : L""); + if (latest_widget) + stfl_widget_setkv_str(w, L"pos_name", latest_widget->name ? latest_widget->name : L""); } static void stfl_focus_prev_pos(struct stfl_widget *w)