Fix multiple popup windows

The window was not deleted if an "already in use"-key was detected,
and a new one was created as the loop was reentered.

Create/delete of the popup are moved outside the loop.
A redrawwin() call is needed to have the window displayed again.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen 2017-10-27 08:17:57 +02:00 committed by Lukas Fleischer
parent e9bddf38e8
commit 012a0e6670
3 changed files with 19 additions and 11 deletions

View File

@ -1216,6 +1216,7 @@ void wins_calendar_cleanup(void *);
int wins_refresh(void); int wins_refresh(void);
int wins_wrefresh(WINDOW *); int wins_wrefresh(WINDOW *);
int wins_doupdate(void); int wins_doupdate(void);
int wins_redrawwin(WINDOW *);
int wins_layout(void); int wins_layout(void);
void wins_set_layout(int); void wins_set_layout(int);
unsigned wins_sbar_width(void); unsigned wins_sbar_width(void);

View File

@ -988,21 +988,16 @@ void custom_keys_config(void)
case KEY_ADD_ITEM: case KEY_ADD_ITEM:
#define WINROW 10 #define WINROW 10
#define WINCOL 50 #define WINCOL 50
for (;;) { grabwin = popup(WINROW, WINCOL,
grabwin = (row - WINROW) / 2, (col - WINCOL) / 2,
popup(WINROW, WINCOL,
(row - WINROW) / 2,
(col - WINCOL) / 2,
_("Press the key you want to assign to:"), _("Press the key you want to assign to:"),
keys_get_label(selrow), 0); keys_get_label(selrow), 0);
for (;;) {
ch = keys_wgetch(grabwin); ch = keys_wgetch(grabwin);
enum key action = keys_get_action(ch); enum key action = keys_get_action(ch);
/* Is the key already used by this action? */ /* Is the key already used by this action? */
if (action == selrow) { if (action == selrow)
delwin(grabwin);
break; break;
}
/* Is the key used by another action? */ /* Is the key used by another action? */
if (keys_assign_binding(ch, selrow)) { if (keys_assign_binding(ch, selrow)) {
char *keystr = keys_int2str(ch); char *keystr = keys_int2str(ch);
@ -1018,13 +1013,14 @@ void custom_keys_config(void)
selelm, selelm,
LINESPERKEY); LINESPERKEY);
wins_scrollwin_display(&kwin); wins_scrollwin_display(&kwin);
wins_redrawwin(grabwin);
continue; continue;
} }
nbrowelm++; nbrowelm++;
selelm = nbrowelm - 1; selelm = nbrowelm - 1;
delwin(grabwin);
break; break;
} }
delwin(grabwin);
#undef WINROW #undef WINROW
#undef WINCOL #undef WINCOL
break; break;

View File

@ -163,6 +163,17 @@ int wins_doupdate(void)
return rc; return rc;
} }
int wins_redrawwin(WINDOW *win)
{
int rc;
SCREEN_ACQUIRE;
rc = redrawwin(win);
SCREEN_RELEASE;
return rc;
}
/* Get the current layout. */ /* Get the current layout. */
int wins_layout(void) int wins_layout(void)
{ {