Finish implementing resize by increment

This commit is contained in:
Luflosi 2019-11-24 18:17:47 +01:00 committed by Anders Eurenius
parent 4619259e26
commit c28ff5259a
5 changed files with 14 additions and 1 deletions

View File

@ -16,6 +16,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Fix :opt:`background_opacity` incorrectly applying to selected text and - Fix :opt:`background_opacity` incorrectly applying to selected text and
reverse video text (:iss:`2177`) 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] 0.15.0 [2019-11-27]
-------------------- --------------------

View File

@ -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. 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') # {{{ g('tabbar') # {{{

View File

@ -625,7 +625,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
w->fonts_data = fonts_data; w->fonts_data = fonts_data;
w->shown_once = true; w->shown_once = true;
w->last_focused_counter = ++focus_counter; 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__ #ifdef __APPLE__
if (OPT(macos_option_as_alt)) glfwSetCocoaTextInputFilter(glfw_window, filter_option); if (OPT(macos_option_as_alt)) glfwSetCocoaTextInputFilter(glfw_window, filter_option);
glfwSetCocoaToggleFullscreenIntercept(glfw_window, intercept_cocoa_fullscreen); glfwSetCocoaToggleFullscreenIntercept(glfw_window, intercept_cocoa_fullscreen);

View File

@ -522,6 +522,7 @@ PYWRAP1(set_options) {
S(tab_bar_min_tabs, PyLong_AsUnsignedLong); S(tab_bar_min_tabs, PyLong_AsUnsignedLong);
S(disable_ligatures, PyLong_AsLong); S(disable_ligatures, PyLong_AsLong);
S(resize_draw_strategy, PyLong_AsLong); S(resize_draw_strategy, PyLong_AsLong);
S(resize_in_steps, PyObject_IsTrue);
S(pointer_shape_when_grabbed, pointer_shape); S(pointer_shape_when_grabbed, pointer_shape);
GA(tab_bar_style); GA(tab_bar_style);
@ -781,6 +782,7 @@ PYWRAP1(os_window_font_size) {
resize_screen(os_window, w->render_data.screen, true); 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); return Py_BuildValue("d", os_window->font_sz_in_pts);
END_WITH_OS_WINDOW END_WITH_OS_WINDOW

View File

@ -42,6 +42,7 @@ typedef struct {
unsigned long tab_bar_min_tabs; unsigned long tab_bar_min_tabs;
DisableLigature disable_ligatures; DisableLigature disable_ligatures;
ResizeDrawStrategy resize_draw_strategy; ResizeDrawStrategy resize_draw_strategy;
bool resize_in_steps;
bool sync_to_monitor; bool sync_to_monitor;
bool close_on_child_death; bool close_on_child_death;
bool window_alert_on_bell; bool window_alert_on_bell;