mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Move rendering of resize banner into the tick callback
Unifies all rendering in one place. And possibly fixes issues with rendering in a resize callback on sway.
This commit is contained in:
@@ -652,6 +652,18 @@ update_os_window_title(OSWindow *os_window) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_resizing_text(OSWindow *w) {
|
||||
char text[32] = {0};
|
||||
unsigned int width = w->live_resize.width, height = w->live_resize.height;
|
||||
snprintf(text, sizeof(text), "%u x %u cells", width / w->fonts_data->cell_width, height / w->fonts_data->cell_height);
|
||||
StringCanvas rendered = render_simple_text(w->fonts_data, text);
|
||||
if (rendered.canvas) {
|
||||
draw_centered_alpha_mask(w->gvao_idx, width, height, rendered.width, rendered.height, rendered.canvas);
|
||||
free(rendered.canvas);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
render(double now) {
|
||||
double time_since_last_render = now - last_render_at;
|
||||
@@ -663,7 +675,7 @@ render(double now) {
|
||||
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
||||
OSWindow *w = global_state.os_windows + i;
|
||||
if (!w->num_tabs) continue;
|
||||
if ((w->live_resize.in_progress && (now - w->live_resize.last_resize_event_at) < 1) || !should_os_window_be_rendered(w)) {
|
||||
if (!should_os_window_be_rendered(w)) {
|
||||
update_os_window_title(w);
|
||||
continue;
|
||||
}
|
||||
@@ -671,8 +683,15 @@ render(double now) {
|
||||
if (w->render_state == RENDER_FRAME_NOT_REQUESTED) request_frame_render(w);
|
||||
continue;
|
||||
}
|
||||
bool needs_render = w->is_damaged;
|
||||
make_os_window_context_current(w);
|
||||
if (w->live_resize.in_progress) {
|
||||
blank_os_window(w);
|
||||
draw_resizing_text(w);
|
||||
swap_window_buffers(w);
|
||||
if (USE_RENDER_FRAMES) request_frame_render(w);
|
||||
continue;
|
||||
}
|
||||
bool needs_render = w->is_damaged;
|
||||
if (w->viewport_size_dirty) {
|
||||
w->clear_count = 0;
|
||||
update_surface_size(w->viewport_width, w->viewport_height, w->offscreen_texture_id);
|
||||
|
||||
18
kitty/glfw.c
18
kitty/glfw.c
@@ -53,17 +53,6 @@ update_os_window_viewport(OSWindow *window, bool notify_boss) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_resizing_text(OSWindow *w, unsigned int width, unsigned int height) {
|
||||
char text[32] = {0};
|
||||
snprintf(text, sizeof(text), "%u x %u cells", width / w->fonts_data->cell_width, height / w->fonts_data->cell_height);
|
||||
StringCanvas rendered = render_simple_text(w->fonts_data, text);
|
||||
if (rendered.canvas) {
|
||||
draw_centered_alpha_mask(w->gvao_idx, width, height, rendered.width, rendered.height, rendered.canvas);
|
||||
free(rendered.canvas);
|
||||
}
|
||||
}
|
||||
|
||||
// callbacks {{{
|
||||
|
||||
void
|
||||
@@ -161,14 +150,9 @@ framebuffer_size_callback(GLFWwindow *w, int width, int height) {
|
||||
global_state.has_pending_resizes = true;
|
||||
window->live_resize.in_progress = true;
|
||||
window->live_resize.last_resize_event_at = monotonic();
|
||||
// render OS window as blank. On cocoa this is needed for semi-transparent windows,
|
||||
// otherwise you get burn in of the previous frame. On Linux this is needed as otherwise
|
||||
// you get partially rendered windows.
|
||||
window->live_resize.width = MAX(0, width); window->live_resize.height = MAX(0, height);
|
||||
make_os_window_context_current(window);
|
||||
update_surface_size(width, height, window->offscreen_texture_id);
|
||||
blank_os_window(window);
|
||||
draw_resizing_text(window, MAX(0, width), MAX(0, height));
|
||||
swap_window_buffers(window);
|
||||
request_tick_callback();
|
||||
} else log_error("Ignoring resize request for tiny size: %dx%d", width, height);
|
||||
global_state.callback_os_window = NULL;
|
||||
|
||||
@@ -112,6 +112,7 @@ typedef struct {
|
||||
bool in_progress;
|
||||
bool from_os_notification;
|
||||
bool os_says_resize_complete;
|
||||
unsigned int width, height;
|
||||
} LiveResizeInfo;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user