When a window is moved but not resized, ensure the OS Window is re-rendered

This commit is contained in:
Kovid Goyal 2021-10-22 04:15:47 +05:30
parent b51be8382f
commit e18b0cd4c8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 16 additions and 1 deletions

View File

@ -1236,6 +1236,10 @@ class OSWindowSize(TypedDict):
cell_height: int cell_height: int
def mark_os_window_dirty(os_window_id: int) -> None:
pass
def get_os_window_size(os_window_id: int) -> Optional[OSWindowSize]: def get_os_window_size(os_window_id: int) -> Optional[OSWindowSize]:
pass pass

View File

@ -440,6 +440,12 @@ remove_os_window(id_type os_window_id) {
return found; return found;
} }
static void
mark_os_window_dirty(id_type os_window_id) {
WITH_OS_WINDOW(os_window_id)
os_window->needs_render = true;
END_WITH_OS_WINDOW
}
static void static void
set_active_tab(id_type os_window_id, unsigned int idx) { set_active_tab(id_type os_window_id, unsigned int idx) {
@ -573,6 +579,7 @@ send_pending_click_to_window_id(id_type timer_id UNUSED, void *data) {
#define TWO_ID(name) PYWRAP1(name) { id_type a, b; PA("KK", &a, &b); name(a, b); Py_RETURN_NONE; } #define TWO_ID(name) PYWRAP1(name) { id_type a, b; PA("KK", &a, &b); name(a, b); Py_RETURN_NONE; }
#define THREE_ID(name) PYWRAP1(name) { id_type a, b, c; PA("KKK", &a, &b, &c); name(a, b, c); Py_RETURN_NONE; } #define THREE_ID(name) PYWRAP1(name) { id_type a, b, c; PA("KKK", &a, &b, &c); name(a, b, c); Py_RETURN_NONE; }
#define THREE_ID_OBJ(name) PYWRAP1(name) { id_type a, b, c; PyObject *o; PA("KKKO", &a, &b, &c, &o); name(a, b, c, o); Py_RETURN_NONE; } #define THREE_ID_OBJ(name) PYWRAP1(name) { id_type a, b, c; PyObject *o; PA("KKKO", &a, &b, &c, &o); name(a, b, c, o); Py_RETURN_NONE; }
#define K(name) PYWRAP1(name) { id_type a; PA("K", &a); name(a); Py_RETURN_NONE; }
#define KI(name) PYWRAP1(name) { id_type a; unsigned int b; PA("KI", &a, &b); name(a, b); Py_RETURN_NONE; } #define KI(name) PYWRAP1(name) { id_type a; unsigned int b; PA("KI", &a, &b); name(a, b); Py_RETURN_NONE; }
#define KII(name) PYWRAP1(name) { id_type a; unsigned int b, c; PA("KII", &a, &b, &c); name(a, b, c); Py_RETURN_NONE; } #define KII(name) PYWRAP1(name) { id_type a; unsigned int b, c; PA("KII", &a, &b, &c); name(a, b, c); Py_RETURN_NONE; }
#define KKI(name) PYWRAP1(name) { id_type a, b; unsigned int c; PA("KKI", &a, &b, &c); name(a, b, c); Py_RETURN_NONE; } #define KKI(name) PYWRAP1(name) { id_type a, b; unsigned int c; PA("KKI", &a, &b, &c); name(a, b, c); Py_RETURN_NONE; }
@ -1078,6 +1085,7 @@ PYWRAP1(add_window) { PyObject *title; id_type a, b; PA("KKO", &a, &b, &title);
PYWRAP0(current_os_window) { OSWindow *w = current_os_window(); if (!w) Py_RETURN_NONE; return PyLong_FromUnsignedLongLong(w->id); } PYWRAP0(current_os_window) { OSWindow *w = current_os_window(); if (!w) Py_RETURN_NONE; return PyLong_FromUnsignedLongLong(w->id); }
TWO_ID(remove_tab) TWO_ID(remove_tab)
KI(set_active_tab) KI(set_active_tab)
K(mark_os_window_dirty)
KKK(set_active_window) KKK(set_active_window)
KII(swap_tabs) KII(swap_tabs)
KK5I(add_borders_rect) KK5I(add_borders_rect)
@ -1106,6 +1114,7 @@ static PyMethodDef module_methods[] = {
MW(detach_window, METH_VARARGS), MW(detach_window, METH_VARARGS),
MW(attach_window, METH_VARARGS), MW(attach_window, METH_VARARGS),
MW(set_active_tab, METH_VARARGS), MW(set_active_tab, METH_VARARGS),
MW(mark_os_window_dirty, METH_VARARGS),
MW(set_active_window, METH_VARARGS), MW(set_active_window, METH_VARARGS),
MW(swap_tabs, METH_VARARGS), MW(swap_tabs, METH_VARARGS),
MW(add_borders_rect, METH_VARARGS), MW(add_borders_rect, METH_VARARGS),

View File

@ -28,7 +28,7 @@ from .fast_data_types import (
SCROLL_PAGE, SEVEN_SEGMENT_PROGRAM, STRIKETHROUGH, TINT_PROGRAM, KeyEvent, SCROLL_PAGE, SEVEN_SEGMENT_PROGRAM, STRIKETHROUGH, TINT_PROGRAM, KeyEvent,
Screen, add_timer, add_window, cell_size_for_window, click_mouse_url, Screen, add_timer, add_window, cell_size_for_window, click_mouse_url,
compile_program, encode_key_for_tty, get_boss, get_clipboard_string, compile_program, encode_key_for_tty, get_boss, get_clipboard_string,
get_options, init_cell_program, mouse_selection, get_options, init_cell_program, mark_os_window_dirty, mouse_selection,
move_cursor_to_mouse_if_in_prompt, pt_to_px, set_clipboard_string, move_cursor_to_mouse_if_in_prompt, pt_to_px, set_clipboard_string,
set_titlebar_color, set_window_padding, set_window_render_data, set_titlebar_color, set_window_padding, set_window_render_data,
update_window_title, update_window_visibility, viewport_for_window update_window_title, update_window_visibility, viewport_for_window
@ -566,6 +566,8 @@ class Window:
self.pty_resized_once = True self.pty_resized_once = True
self.child.mark_terminal_ready() self.child.mark_terminal_ready()
self.last_reported_pty_size = current_pty_size self.last_reported_pty_size = current_pty_size
else:
mark_os_window_dirty(self.os_window_id)
self.geometry = g = new_geometry self.geometry = g = new_geometry
set_window_render_data(self.os_window_id, self.tab_id, self.id, sg.xstart, sg.ystart, sg.dx, sg.dy, self.screen, *g[:4]) set_window_render_data(self.os_window_id, self.tab_id, self.id, sg.xstart, sg.ystart, sg.dx, sg.dy, self.screen, *g[:4])