diff --git a/docs/changelog.rst b/docs/changelog.rst index 7fb9904fd..ba14ee572 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -16,6 +16,9 @@ To update |kitty|, :doc:`follow the instructions `. - Fix :opt:`background_opacity` incorrectly applying to selected text and reverse video text (:iss:`2177`) +- Add a :opt:`resize_in_steps` option that can be used resize the OS window + in steps as large as the cells (:pull:`2131`) + 0.15.0 [2019-11-27] -------------------- diff --git a/kitty/config_data.py b/kitty/config_data.py index 9218621ec..ac16db8c1 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -649,6 +649,13 @@ A value of :code:`blank` means draw a blank window. A value of :code:`size` means show the window size in cells. ''')) +o('resize_in_steps', False, long_text=_(''' +Resize the OS window in steps as large as the cells, instead of with the usual pixel accuracy. +Combined with an :opt:`initial_window_width` and :opt:`initial_window_height` in number of cells, +this option can be used to keep the margins as small as possible when resizing the OS window. +Note that this does not currently work on Wayland. +''')) + # }}} g('tabbar') # {{{ diff --git a/kitty/glfw.c b/kitty/glfw.c index da7c39ae5..c3baf4063 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -625,7 +625,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args) { w->fonts_data = fonts_data; w->shown_once = true; w->last_focused_counter = ++focus_counter; - glfwSetWindowSizeIncrements(glfw_window, fonts_data->cell_width, fonts_data->cell_height); + if (OPT(resize_in_steps)) glfwSetWindowSizeIncrements(glfw_window, fonts_data->cell_width, fonts_data->cell_height); #ifdef __APPLE__ if (OPT(macos_option_as_alt)) glfwSetCocoaTextInputFilter(glfw_window, filter_option); glfwSetCocoaToggleFullscreenIntercept(glfw_window, intercept_cocoa_fullscreen); diff --git a/kitty/state.c b/kitty/state.c index e100b0313..5f4a6b2e4 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -522,6 +522,7 @@ PYWRAP1(set_options) { S(tab_bar_min_tabs, PyLong_AsUnsignedLong); S(disable_ligatures, PyLong_AsLong); S(resize_draw_strategy, PyLong_AsLong); + S(resize_in_steps, PyObject_IsTrue); S(pointer_shape_when_grabbed, pointer_shape); GA(tab_bar_style); @@ -781,6 +782,7 @@ PYWRAP1(os_window_font_size) { resize_screen(os_window, w->render_data.screen, true); } } + if (OPT(resize_in_steps)) glfwSetWindowSizeIncrements(os_window->handle, os_window->fonts_data->cell_width, os_window->fonts_data->cell_height); } return Py_BuildValue("d", os_window->font_sz_in_pts); END_WITH_OS_WINDOW diff --git a/kitty/state.h b/kitty/state.h index cfec69314..1e8c0406f 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -42,6 +42,7 @@ typedef struct { unsigned long tab_bar_min_tabs; DisableLigature disable_ligatures; ResizeDrawStrategy resize_draw_strategy; + bool resize_in_steps; bool sync_to_monitor; bool close_on_child_death; bool window_alert_on_bell;