Store last cursor render pos in the rendered info struct

This commit is contained in:
Kovid Goyal 2023-11-21 21:38:44 +05:30
parent be37a283d5
commit 391a43d967
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 8 additions and 9 deletions

View file

@ -652,7 +652,7 @@ pyset_iutf8(ChildMonitor *self, PyObject *args) {
static bool
cursor_needs_render(Window *w) {
return w->cursor_visible_at_last_render != w->render_data.screen->cursor_render_info.is_visible || w->last_cursor_x != w->render_data.screen->cursor_render_info.x || w->last_cursor_y != w->render_data.screen->cursor_render_info.y || w->last_cursor_shape != w->render_data.screen->cursor_render_info.shape;
return w->cursor_visible_at_last_render != w->render_data.screen->cursor_render_info.is_visible || w->render_data.screen->cursor_render_info.last.x != w->render_data.screen->cursor_render_info.x || w->render_data.screen->cursor_render_info.last.y != w->render_data.screen->cursor_render_info.y || w->last_cursor_shape != w->render_data.screen->cursor_render_info.shape;
}
static bool
@ -799,7 +799,7 @@ render_prepared_os_window(OSWindow *os_window, unsigned int active_window_id, co
if (WD.screen->start_visual_bell_at != 0) {
set_maximum_wait(OPT(repaint_delay));
}
w->cursor_visible_at_last_render = WD.screen->cursor_render_info.is_visible; w->last_cursor_x = WD.screen->cursor_render_info.x; w->last_cursor_y = WD.screen->cursor_render_info.y; w->last_cursor_shape = WD.screen->cursor_render_info.shape;
w->cursor_visible_at_last_render = WD.screen->cursor_render_info.is_visible; WD.screen->cursor_render_info.last.x = WD.screen->cursor_render_info.x; WD.screen->cursor_render_info.last.y = WD.screen->cursor_render_info.y; w->last_cursor_shape = WD.screen->cursor_render_info.shape;
}
}
if (os_window->live_resize.in_progress) draw_resizing_text(os_window);

View file

@ -303,6 +303,7 @@ typedef struct {
bool is_visible, is_focused, render_even_when_unfocused;
CursorShape shape;
unsigned int x, y;
struct { unsigned int x, y; } last;
} CursorRenderInfo;
typedef enum DynamicColorType {

View file

@ -56,7 +56,7 @@ def __call__(self, *a: Any) -> None:
for wid in s.window_ids:
qw = boss.window_id_map.get(wid)
if qw is not None:
qw.screen.render_unfocused_cursor = 0
qw.screen.render_unfocused_cursor = False
class FocusChangedSession(SessionAction):
@ -65,11 +65,10 @@ def __call__(self, window: Window, focused: bool) -> None:
s = sessions_map.get(self.sid)
if s is not None:
boss = get_boss()
val = int(focused)
for wid in s.window_ids:
qw = boss.window_id_map.get(wid)
if qw is not None:
qw.screen.render_unfocused_cursor = val
qw.screen.render_unfocused_cursor = focused
class SendText(RemoteCommand):
@ -217,7 +216,7 @@ def create_or_update_session() -> Session:
if session == 'end':
s = create_or_update_session()
for w in actual_windows:
w.screen.render_unfocused_cursor = 0
w.screen.render_unfocused_cursor = False
s.window_ids.discard(w.id)
ClearSession(sid)()
elif session == 'start':
@ -232,7 +231,7 @@ def is_ok(x: Any) -> bool:
window.actions_on_removal.append(ClearSession(sid))
window.actions_on_focus_change.append(FocusChangedSession(sid))
for w in actual_windows:
w.screen.render_unfocused_cursor = 1
w.screen.render_unfocused_cursor = True
s.window_ids.add(w.id)
else:
bp = payload_get('bracketed_paste')
@ -240,7 +239,7 @@ def is_ok(x: Any) -> bool:
s = create_or_update_session()
for w in actual_windows:
if sid:
w.screen.render_unfocused_cursor = 1
w.screen.render_unfocused_cursor = True
s.window_ids.add(w.id)
if isinstance(data, WindowSystemKeyEvent):
kdata = w.encoded_key(data)

View file

@ -151,7 +151,6 @@ typedef struct WindowBarData {
typedef struct {
id_type id;
bool visible, cursor_visible_at_last_render;
unsigned int last_cursor_x, last_cursor_y;
CursorShape last_cursor_shape;
PyObject *title;
WindowRenderData render_data;