Fix rendering occasionally not occurring after input received
This commit is contained in:
parent
ee581ebdf4
commit
33f48e8268
@ -480,52 +480,52 @@ render_cursor(Window *w, double now) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline void
|
||||||
render(double now) {
|
render(double now) {
|
||||||
double time_since_last_render = now - last_render_at;
|
double time_since_last_render = now - last_render_at;
|
||||||
if (time_since_last_render > OPT(repaint_delay)) {
|
if (time_since_last_render < OPT(repaint_delay)) {
|
||||||
draw_borders();
|
set_maximum_wait(OPT(repaint_delay) - time_since_last_render);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw_borders();
|
||||||
#define TD global_state.tab_bar_render_data
|
#define TD global_state.tab_bar_render_data
|
||||||
if (TD.screen && global_state.num_tabs > 1) draw_cells(TD.vao_idx, TD.xstart, TD.ystart, TD.dx, TD.dy, TD.screen);
|
if (TD.screen && global_state.num_tabs > 1) draw_cells(TD.vao_idx, TD.xstart, TD.ystart, TD.dx, TD.dy, TD.screen);
|
||||||
#undef TD
|
#undef TD
|
||||||
if (global_state.num_tabs) {
|
if (global_state.num_tabs) {
|
||||||
Tab *tab = global_state.tabs + global_state.active_tab;
|
Tab *tab = global_state.tabs + global_state.active_tab;
|
||||||
for (size_t i = 0; i < tab->num_windows; i++) {
|
for (size_t i = 0; i < tab->num_windows; i++) {
|
||||||
Window *w = tab->windows + i;
|
Window *w = tab->windows + i;
|
||||||
#define WD w->render_data
|
#define WD w->render_data
|
||||||
if (w->visible && WD.screen) {
|
if (w->visible && WD.screen) {
|
||||||
if (w->last_drag_scroll_at > 0) {
|
if (w->last_drag_scroll_at > 0) {
|
||||||
if (now - w->last_drag_scroll_at >= 0.02) {
|
if (now - w->last_drag_scroll_at >= 0.02) {
|
||||||
if (drag_scroll(w)) {
|
if (drag_scroll(w)) {
|
||||||
w->last_drag_scroll_at = now;
|
w->last_drag_scroll_at = now;
|
||||||
set_maximum_wait(0.02);
|
set_maximum_wait(0.02);
|
||||||
} else w->last_drag_scroll_at = 0;
|
} else w->last_drag_scroll_at = 0;
|
||||||
} else set_maximum_wait(now - w->last_drag_scroll_at);
|
} else set_maximum_wait(now - w->last_drag_scroll_at);
|
||||||
}
|
}
|
||||||
draw_cells(WD.vao_idx, WD.xstart, WD.ystart, WD.dx, WD.dy, WD.screen);
|
draw_cells(WD.vao_idx, WD.xstart, WD.ystart, WD.dx, WD.dy, WD.screen);
|
||||||
if (WD.screen->start_visual_bell_at != 0) {
|
if (WD.screen->start_visual_bell_at != 0) {
|
||||||
double bell_left = global_state.opts.visual_bell_duration - (now - WD.screen->start_visual_bell_at);
|
double bell_left = global_state.opts.visual_bell_duration - (now - WD.screen->start_visual_bell_at);
|
||||||
set_maximum_wait(bell_left);
|
set_maximum_wait(bell_left);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Window *w = tab->windows + tab->active_window;
|
|
||||||
if (w->visible && WD.screen) render_cursor(w, now);
|
|
||||||
if (w->title && w->title != global_state.application_title) {
|
|
||||||
global_state.application_title = w->title;
|
|
||||||
glfwSetWindowTitle(glfw_window_id, PyUnicode_AsUTF8(w->title));
|
|
||||||
#ifdef __APPLE__
|
|
||||||
cocoa_update_title(w->title);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#undef WD
|
|
||||||
}
|
}
|
||||||
glfwSwapBuffers(glfw_window_id);
|
Window *w = tab->windows + tab->active_window;
|
||||||
last_render_at = now;
|
if (w->visible && WD.screen) render_cursor(w, now);
|
||||||
} else {
|
if (w->title && w->title != global_state.application_title) {
|
||||||
set_maximum_wait(OPT(repaint_delay) - time_since_last_render);
|
global_state.application_title = w->title;
|
||||||
|
glfwSetWindowTitle(glfw_window_id, PyUnicode_AsUTF8(w->title));
|
||||||
|
#ifdef __APPLE__
|
||||||
|
cocoa_update_title(w->title);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#undef WD
|
||||||
}
|
}
|
||||||
return true;
|
glfwSwapBuffers(glfw_window_id);
|
||||||
|
last_render_at = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct { int fd; uint8_t *buf; size_t sz; } ThreadWriteData;
|
typedef struct { int fd; uint8_t *buf; size_t sz; } ThreadWriteData;
|
||||||
@ -581,14 +581,14 @@ main_loop(ChildMonitor *self) {
|
|||||||
#define main_loop_doc "The main thread loop"
|
#define main_loop_doc "The main thread loop"
|
||||||
while (!glfwWindowShouldClose(glfw_window_id)) {
|
while (!glfwWindowShouldClose(glfw_window_id)) {
|
||||||
double now = monotonic();
|
double now = monotonic();
|
||||||
maximum_wait = -1;
|
render(now);
|
||||||
if (!render(now)) break;
|
|
||||||
if (global_state.mouse_visible && OPT(mouse_hide_wait) > 0 && now - global_state.last_mouse_activity_at > OPT(mouse_hide_wait)) {
|
if (global_state.mouse_visible && OPT(mouse_hide_wait) > 0 && now - global_state.last_mouse_activity_at > OPT(mouse_hide_wait)) {
|
||||||
glfwSetInputMode(glfw_window_id, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
glfwSetInputMode(glfw_window_id, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||||
global_state.mouse_visible = false;
|
global_state.mouse_visible = false;
|
||||||
}
|
}
|
||||||
if (maximum_wait < 0) glfwWaitEvents();
|
if (maximum_wait < 0) glfwWaitEvents();
|
||||||
else if (maximum_wait > 0) glfwWaitEventsTimeout(maximum_wait);
|
else if (maximum_wait > 0) glfwWaitEventsTimeout(maximum_wait);
|
||||||
|
maximum_wait = -1;
|
||||||
parse_input(self);
|
parse_input(self);
|
||||||
}
|
}
|
||||||
if (PyErr_Occurred()) return NULL;
|
if (PyErr_Occurred()) return NULL;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user