Ticket #3173: fix location of popup windows upon screen resize.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2014-02-22 14:56:35 +04:00
parent 8ee4732bd5
commit be6b3889af
1 changed files with 19 additions and 19 deletions

View File

@ -61,8 +61,9 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
{
const int space = 4;
int xpos, ypos;
int xpos = 0, ypos = 0;
Listbox *listbox;
dlg_flags_t dlg_flags = DLG_TRYUP;
/* Adjust sizes */
lines = min (lines, LINES - 6);
@ -79,34 +80,33 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
/* adjust position */
if ((center_y < 0) || (center_x < 0))
{
ypos = LINES / 2;
xpos = COLS / 2;
}
dlg_flags |= DLG_CENTER;
else
{
/* Actually, this this is not used in MC. */
ypos = center_y;
xpos = center_x;
ypos -= lines / 2;
xpos -= cols / 2;
if (ypos + lines >= LINES)
ypos = LINES - lines - space;
if (ypos < 0)
ypos = 0;
if (xpos + cols >= COLS)
xpos = COLS - cols - space;
if (xpos < 0)
xpos = 0;
}
ypos -= lines / 2;
xpos -= cols / 2;
if (ypos + lines >= LINES)
ypos = LINES - lines - space;
if (ypos < 0)
ypos = 0;
if (xpos + cols >= COLS)
xpos = COLS - cols - space;
if (xpos < 0)
xpos = 0;
listbox = g_new (Listbox, 1);
listbox->dlg =
dlg_create (TRUE, ypos, xpos, lines + space, cols + space,
listbox_colors, NULL, NULL, help, title, DLG_TRYUP);
listbox_colors, NULL, NULL, help, title, dlg_flags);
listbox->list = listbox_new (2, 2, lines, cols, FALSE, NULL);
add_widget (listbox->dlg, listbox->list);