From e18b0cd4c89f8ed9c0008ec4b392901985c08ee0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 22 Oct 2021 04:15:47 +0530 Subject: [PATCH] When a window is moved but not resized, ensure the OS Window is re-rendered --- kitty/fast_data_types.pyi | 4 ++++ kitty/state.c | 9 +++++++++ kitty/window.py | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index ee2313c44..3b55f6714 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -1236,6 +1236,10 @@ class OSWindowSize(TypedDict): 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]: pass diff --git a/kitty/state.c b/kitty/state.c index ac0372ccb..f0551e5d5 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -440,6 +440,12 @@ remove_os_window(id_type os_window_id) { 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 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 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 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 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; } @@ -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); } TWO_ID(remove_tab) KI(set_active_tab) +K(mark_os_window_dirty) KKK(set_active_window) KII(swap_tabs) KK5I(add_borders_rect) @@ -1106,6 +1114,7 @@ static PyMethodDef module_methods[] = { MW(detach_window, METH_VARARGS), MW(attach_window, METH_VARARGS), MW(set_active_tab, METH_VARARGS), + MW(mark_os_window_dirty, METH_VARARGS), MW(set_active_window, METH_VARARGS), MW(swap_tabs, METH_VARARGS), MW(add_borders_rect, METH_VARARGS), diff --git a/kitty/window.py b/kitty/window.py index 4e256a67f..24a9a366b 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -28,7 +28,7 @@ from .fast_data_types import ( SCROLL_PAGE, SEVEN_SEGMENT_PROGRAM, STRIKETHROUGH, TINT_PROGRAM, KeyEvent, Screen, add_timer, add_window, cell_size_for_window, click_mouse_url, 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, set_titlebar_color, set_window_padding, set_window_render_data, update_window_title, update_window_visibility, viewport_for_window @@ -566,6 +566,8 @@ class Window: self.pty_resized_once = True self.child.mark_terminal_ready() self.last_reported_pty_size = current_pty_size + else: + mark_os_window_dirty(self.os_window_id) 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])