Merge pull request #14020 from chentau/float_resize

Update lines after shrinking floating window
This commit is contained in:
Björn Linse
2021-03-14 08:35:48 +01:00
committed by GitHub
5 changed files with 174 additions and 5 deletions

View File

@@ -76,6 +76,12 @@ typedef struct {
int comp_row;
int comp_col;
// Requested width and height of the grid upon resize. Used by
// `ui_compositor` to correctly determine which regions need to
// be redrawn.
int comp_width;
int comp_height;
// z-index of the grid. Grids with higher index is draw on top.
// default_grid.comp_index is always zero.
size_t comp_index;
@@ -86,6 +92,6 @@ typedef struct {
} ScreenGrid;
#define SCREEN_GRID_INIT { 0, NULL, NULL, NULL, NULL, NULL, 0, 0, false, \
false, 0, 0, false, true, 0, 0, 0, false }
false, 0, 0, false, true, 0, 0, 0, 0, 0, false }
#endif // NVIM_GRID_DEFS_H

View File

@@ -6274,6 +6274,9 @@ retry:
tab_page_click_defs = new_tab_page_click_defs;
tab_page_click_defs_size = Columns;
default_grid.comp_height = Rows;
default_grid.comp_width = Columns;
default_grid.row_offset = 0;
default_grid.col_offset = 0;
default_grid.handle = DEFAULT_GRID_HANDLE;

View File

@@ -127,6 +127,9 @@ bool ui_comp_put_grid(ScreenGrid *grid, int row, int col, int height, int width,
bool valid, bool on_top)
{
bool moved;
grid->comp_height = height;
grid->comp_width = width;
if (grid->comp_index != 0) {
moved = (row != grid->comp_row) || (col != grid->comp_col);
if (ui_comp_should_draw()) {
@@ -334,17 +337,25 @@ static void compose_line(Integer row, Integer startcol, Integer endcol,
sattr_T *bg_attrs = &default_grid.attrs[default_grid.line_offset[row]
+(size_t)startcol];
int grid_width, grid_height;
while (col < endcol) {
int until = 0;
for (size_t i = 0; i < kv_size(layers); i++) {
ScreenGrid *g = kv_A(layers, i);
if (g->comp_row > row || row >= g->comp_row + g->Rows
// compose_line may have been called after a shrinking operation but
// before the resize has actually been applied. Therefore, we need to
// first check to see if any grids have pending updates to width/height,
// to ensure that we don't accidentally put any characters into `linebuf`
// that have been invalidated.
grid_width = MIN(g->Columns, g->comp_width);
grid_height = MIN(g->Rows, g->comp_height);
if (g->comp_row > row || row >= g->comp_row + grid_height
|| g->comp_disabled) {
continue;
}
if (g->comp_col <= col && col < g->comp_col+g->Columns) {
if (g->comp_col <= col && col < g->comp_col + grid_width) {
grid = g;
until = g->comp_col+g->Columns;
until = g->comp_col + grid_width;
} else if (g->comp_col > col) {
until = MIN(until, g->comp_col);
}

View File

@@ -710,7 +710,7 @@ int win_fdccol_count(win_T *wp)
}
static void ui_ext_win_position(win_T *wp)
void ui_ext_win_position(win_T *wp)
{
if (!wp->w_floating) {
ui_call_win_pos(wp->w_grid.handle, wp->handle, wp->w_winrow,