@@ -129,6 +129,7 @@ typedef struct {
129
129
} TUIData ;
130
130
131
131
static bool volatile got_winch = false;
132
+ static bool did_user_set_dimensions = false;
132
133
static bool cursor_style_enabled = false;
133
134
134
135
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -338,7 +339,7 @@ static void tui_terminal_start(UI *ui)
338
339
data -> print_attr_id = -1 ;
339
340
ugrid_init (& data -> grid );
340
341
terminfo_start (ui );
341
- update_size (ui );
342
+ tui_guess_size (ui );
342
343
signal_watcher_start (& data -> winch_handle , sigwinch_cb , SIGWINCH );
343
344
term_input_start (& data -> input );
344
345
}
@@ -465,7 +466,7 @@ static void sigwinch_cb(SignalWatcher *watcher, int signum, void *data)
465
466
return ;
466
467
}
467
468
468
- update_size (ui );
469
+ tui_guess_size (ui );
469
470
ui_schedule_refresh ();
470
471
}
471
472
@@ -889,7 +890,8 @@ static void tui_grid_resize(UI *ui, Integer g, Integer width, Integer height)
889
890
r -> right = MIN (r -> right , grid -> width );
890
891
}
891
892
892
- if (!got_winch ) { // Try to resize the terminal window.
893
+ if (!got_winch && (!starting || did_user_set_dimensions )) {
894
+ // Resize the _host_ terminal.
893
895
UNIBI_SET_NUM_VAR (data -> params [0 ], (int )height );
894
896
UNIBI_SET_NUM_VAR (data -> params [1 ], (int )width );
895
897
unibi_out_ext (ui , data -> unibi_ext .resize_screen );
@@ -1347,13 +1349,16 @@ static void invalidate(UI *ui, int top, int bot, int left, int right)
1347
1349
}
1348
1350
}
1349
1351
1350
- static void update_size (UI * ui )
1352
+ /// Tries to get the user's wanted dimensions (columns and rows) for the entire
1353
+ /// application (i.e., the host terminal).
1354
+ static void tui_guess_size (UI * ui )
1351
1355
{
1352
1356
TUIData * data = ui -> data ;
1353
1357
int width = 0 , height = 0 ;
1354
1358
1355
1359
// 1 - look for non-default 'columns' and 'lines' options during startup
1356
- if (starting != 0 && (Columns != DFLT_COLS || Rows != DFLT_ROWS )) {
1360
+ if (starting && (Columns != DFLT_COLS || Rows != DFLT_ROWS )) {
1361
+ did_user_set_dimensions = true;
1357
1362
assert (Columns >= INT_MIN && Columns <= INT_MAX );
1358
1363
assert (Rows >= INT_MIN && Rows <= INT_MAX );
1359
1364
width = (int )Columns ;
0 commit comments