aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUtkarsh Maheshwari <utkarshme96@gmail.com>2018-06-15 02:41:59 +0530
committerBjörn Linse <bjorn.linse@gmail.com>2018-12-31 12:44:22 +0100
commitd5754eae020d672b4f6c62b636a56e0d6d56b4dc (patch)
tree09800750e6876c47f1254b6fb7b4df684724401c /src
parent01555de2da79eaf6e569e5e6ee7244dbf5f709e5 (diff)
downloadrneovim-d5754eae020d672b4f6c62b636a56e0d6d56b4dc.tar.gz
rneovim-d5754eae020d672b4f6c62b636a56e0d6d56b4dc.tar.bz2
rneovim-d5754eae020d672b4f6c62b636a56e0d6d56b4dc.zip
multigrid: Add win_position event
Throttle win_position events
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/ui_events.in.h3
-rw-r--r--src/nvim/buffer_defs.h1
-rw-r--r--src/nvim/ui.c1
-rw-r--r--src/nvim/window.c30
4 files changed, 35 insertions, 0 deletions
diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h
index 5c48cb4804..8870f39721 100644
--- a/src/nvim/api/ui_events.in.h
+++ b/src/nvim/api/ui_events.in.h
@@ -83,6 +83,9 @@ void grid_scroll(Integer grid, Integer top, Integer bot,
FUNC_API_SINCE(5) FUNC_API_REMOTE_IMPL;
void grid_destroy(Integer grid)
FUNC_API_SINCE(5) FUNC_API_REMOTE_ONLY;
+void win_position(Integer win, Integer grid, Integer startrow,
+ Integer startcol, Integer width, Integer height)
+ FUNC_API_SINCE(4) FUNC_API_REMOTE_ONLY;
void popupmenu_show(Array items, Integer selected, Integer row, Integer col)
FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY;
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 01f3044332..ce83c4561d 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -1184,6 +1184,7 @@ struct window_S {
int w_tagstacklen; /* number of tags on stack */
ScreenGrid w_grid; // the grid specific to the window
+ bool w_pos_changed; // true if window position changed
/*
* w_fraction is the fractional row of the cursor within the window, from
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 968c3b7b16..24557c5d0b 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -377,6 +377,7 @@ int ui_current_col(void)
void ui_flush(void)
{
cmdline_ui_flush();
+ win_ui_flush();
if (pending_cursor_update) {
ui_call_grid_cursor_goto(cursor_grid_handle, row, col);
pending_cursor_update = false;
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 5153bfadda..ba44d7334f 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -997,6 +997,9 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir)
p_wh = i;
}
+ // Send the window positions to the UI
+ oldwin->w_pos_changed = true;
+
return OK;
}
@@ -1341,6 +1344,9 @@ static void win_rotate(int upwards, int count)
(void)win_comp_pos();
}
+ wp1->w_pos_changed = true;
+ wp2->w_pos_changed = true;
+
redraw_all_later(NOT_VALID);
}
@@ -1423,6 +1429,9 @@ void win_move_after(win_T *win1, win_T *win2)
redraw_later(NOT_VALID);
}
win_enter(win1, false);
+
+ win1->w_pos_changed = true;
+ win2->w_pos_changed = true;
}
/*
@@ -2059,6 +2068,7 @@ int win_close(win_T *win, bool free_buf)
if (help_window)
restore_snapshot(SNAP_HELP_IDX, close_curwin);
+ curwin->w_pos_changed = true;
redraw_all_later(NOT_VALID);
return OK;
}
@@ -4221,6 +4231,7 @@ static void frame_comp_pos(frame_T *topfrp, int *row, int *col)
wp->w_wincol = *col;
redraw_win_later(wp, NOT_VALID);
wp->w_redr_status = TRUE;
+ wp->w_pos_changed = true;
}
*row += wp->w_height + wp->w_status_height;
*col += wp->w_width + wp->w_vsep_width;
@@ -4886,6 +4897,8 @@ void win_new_height(win_T *wp, int height)
if (!exiting) {
scroll_to_fraction(wp, prev_height);
}
+
+ wp->w_pos_changed = true;
}
void scroll_to_fraction(win_T *wp, int prev_height)
@@ -5016,6 +5029,7 @@ void win_new_width(win_T *wp, int width)
0);
}
}
+ wp->w_pos_changed = true;
}
void win_comp_scroll(win_T *wp)
@@ -6051,3 +6065,19 @@ void win_findbuf(typval_T *argvars, list_T *list)
}
}
}
+
+void win_ui_flush(void)
+{
+ if (!ui_is_external(kUIMultigrid)) {
+ return;
+ }
+
+ FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
+ if(wp->w_pos_changed && wp->w_grid.ScreenLines != NULL) {
+ ui_call_win_position(wp->handle, wp->w_grid.handle, wp->w_winrow,
+ wp->w_wincol, wp->w_width, wp->w_height);
+ wp->w_pos_changed = false;
+ }
+ }
+
+}