From db09ca01a05644d45eaeb7158c0eeb810d81fb5f Mon Sep 17 00:00:00 2001
From: Andreas Mohr <and@gmx.li>
Date: Thu, 7 Jan 2016 15:25:27 +0000
Subject: [PATCH] #3161 listbox.c remember focus state
when listbox is updated, e.g. new file match add MSG_DRAW event is triggered
but currently listbox re-draw has no knowledge about right focus state
fix it by remember current focus state and resolve #3161
(patch can be simplify but I unsure about lib api function change)
Signed-off-by: Andreas Mohr <and@gmx.li>
---
lib/widget/listbox.c | 11 ++++++++++-
lib/widget/listbox.h | 1 +
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/widget/listbox.c b/lib/widget/listbox.c
index 7668ee3..d391668 100644
a
|
b
|
listbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void |
449 | 449 | return MSG_HANDLED; |
450 | 450 | |
451 | 451 | case MSG_FOCUS: |
| 452 | l->hasfocus = TRUE; |
| 453 | listbox_draw (l, l->hasfocus); |
| 454 | return MSG_HANDLED; |
| 455 | |
452 | 456 | case MSG_UNFOCUS: |
| 457 | l->hasfocus = FALSE; |
| 458 | listbox_draw (l, l->hasfocus); |
| 459 | return MSG_HANDLED; |
| 460 | |
453 | 461 | case MSG_DRAW: |
454 | | listbox_draw (l, msg != MSG_UNFOCUS); |
| 462 | listbox_draw (l, l->hasfocus); |
455 | 463 | return MSG_HANDLED; |
456 | 464 | |
457 | 465 | case MSG_DESTROY: |
… |
… |
listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn |
559 | 567 | l->callback = callback; |
560 | 568 | l->allow_duplicates = TRUE; |
561 | 569 | l->scrollbar = !mc_global.tty.slow_terminal; |
| 570 | l->hasfocus = FALSE; |
562 | 571 | widget_want_hotkey (w, TRUE); |
563 | 572 | widget_want_cursor (w, FALSE); |
564 | 573 | |
diff --git a/lib/widget/listbox.h b/lib/widget/listbox.h
index 6bb5269..ae73313 100644
a
|
b
|
typedef struct WListbox |
52 | 52 | gboolean allow_duplicates; /* Do we allow duplicates on the list? */ |
53 | 53 | gboolean scrollbar; /* Draw a scrollbar? */ |
54 | 54 | gboolean deletable; /* Can list entries be deleted? */ |
| 55 | gboolean hasfocus; /* Has listbox a focus */ |
55 | 56 | lcback_fn callback; /* The callback function */ |
56 | 57 | int cursor_x, cursor_y; /* Cache the values */ |
57 | 58 | } WListbox; |