From 9b740849edd7786de88e5996a341b4ed3789ca94 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 11 May 2019 15:49:11 +0530 Subject: [PATCH] Allow the user to control the draw strategy during OS window resizes Changed the default to scaled which matches current macOS behavior. Fixes #1591 --- docs/changelog.rst | 5 +++-- kitty/child-monitor.c | 6 +++--- kitty/config_data.py | 14 ++++++++++++++ kitty/state.c | 1 + kitty/state.h | 2 ++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 6868d231f..eaeaa8e37 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -34,8 +34,9 @@ To update |kitty|, :doc:`follow the instructions `. - Allow specifying a value of ``none`` for the :opt:`selection_foreground` which will cause kitty to not change text color in selections (:iss:`1358`) -- Make live resizing of OS windows smoother and show the size in cells - while the resize is in progress. +- Make live resizing of OS windows smoother and add an option + :opt:`resize_draw_strategy` to control what is drawn while a + resize is in progress. - macOS: Improve handling of IME extended input. Compose characters are now highlighted and the IME panel moves along with the text diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index e5f0a2eb7..f7fbd0a6a 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -684,14 +684,14 @@ render(double now) { continue; } make_os_window_context_current(w); - if (w->live_resize.in_progress) { + if (OPT(resize_draw_strategy) != RESIZE_DRAW_SCALED && w->live_resize.in_progress) { blank_os_window(w); - draw_resizing_text(w); + if (OPT(resize_draw_strategy) == RESIZE_DRAW_SIZE) draw_resizing_text(w); swap_window_buffers(w); if (USE_RENDER_FRAMES) request_frame_render(w); continue; } - bool needs_render = w->is_damaged; + bool needs_render = w->is_damaged || w->live_resize.in_progress; if (w->viewport_size_dirty) { w->clear_count = 0; update_surface_size(w->viewport_width, w->viewport_height, w->offscreen_texture_id); diff --git a/kitty/config_data.py b/kitty/config_data.py index a0235a53d..7698e603f 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -609,6 +609,20 @@ def to_layout_names(raw): resize event is received. On platforms such as macOS, where the operating system sends event corresponding to the start and end of a resize, this number is ignored.''')) + + +def resize_draw_strategy(x): + cmap = {'scale': 0, 'blank': 1, 'size': 2} + return cmap.get(x.lower(), 0) + + +o('resize_draw_strategy', 'scale', option_type=resize_draw_strategy, long_text=_(''' +Choose how kitty draws a window while a resize is in progress. A +value of :code:`scale` means draw the current window contents scaled. +A value of :code:`blank` means draw a blank window. +A value of :code:`size` means show the window size in cells. +''')) + # }}} g('tabbar') # {{{ diff --git a/kitty/state.c b/kitty/state.c index 66b48b202..1102fd8f5 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -410,6 +410,7 @@ PYWRAP1(set_options) { S(macos_thicken_font, PyFloat_AsDouble); S(tab_bar_min_tabs, PyLong_AsUnsignedLong); S(disable_ligatures, PyLong_AsLong); + S(resize_draw_strategy, PyLong_AsLong); GA(tab_bar_style); global_state.tab_bar_hidden = PyUnicode_CompareWithASCIIString(ret, "hidden") == 0 ? true: false; diff --git a/kitty/state.h b/kitty/state.h index b58a5020f..b10b597e4 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -11,6 +11,7 @@ #define OPT(name) global_state.opts.name typedef enum { LEFT_EDGE, TOP_EDGE, RIGHT_EDGE, BOTTOM_EDGE } Edge; +typedef enum { RESIZE_DRAW_SCALED, RESIZE_DRAW_BLANK, RESIZE_DRAW_SIZE } ResizeDrawStrategy; typedef struct { double visual_bell_duration, cursor_blink_interval, cursor_stop_blinking_after, mouse_hide_wait, click_interval, wheel_scroll_multiplier, touch_scroll_multiplier; @@ -36,6 +37,7 @@ typedef struct { Edge tab_bar_edge; unsigned long tab_bar_min_tabs; DisableLigature disable_ligatures; + ResizeDrawStrategy resize_draw_strategy; bool sync_to_monitor; bool close_on_child_death; bool window_alert_on_bell;