Allow resizing of OS Window framebuffers to a single cell
This is much smaller than before and essentially works around the issue of the text being scaled when the window is resized to small sizes. Also has the nice side effect of making the code simpler for the panel kitten. Fixes #3307
This commit is contained in:
parent
015fe9054e
commit
fbcdf352ac
@ -62,6 +62,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
|
||||
- Fix window icon not working on X11 with 64bits (:iss:`3260`)
|
||||
|
||||
- Fix OS window sizes under 100px resulting in scaled display (:iss:`3307`)
|
||||
|
||||
|
||||
0.19.3 [2020-12-19]
|
||||
-------------------
|
||||
|
||||
@ -121,19 +121,17 @@ def setup_x11_window(win_id: int) -> None:
|
||||
|
||||
|
||||
def initial_window_size_func(opts: WindowSizeData, cached_values: Dict) -> Callable[[int, int, float, float, float, float], Tuple[int, int]]:
|
||||
from kitty.fast_data_types import glfw_primary_monitor_size, set_smallest_allowed_resize
|
||||
from kitty.fast_data_types import glfw_primary_monitor_size
|
||||
|
||||
def initial_window_size(cell_width: int, cell_height: int, dpi_x: float, dpi_y: float, xscale: float, yscale: float) -> Tuple[int, int]:
|
||||
global window_width, window_height
|
||||
monitor_width, monitor_height = glfw_primary_monitor_size()
|
||||
if args.edge in {'top', 'bottom'}:
|
||||
h = window_height = cell_height * args.lines + 1
|
||||
window_height = cell_height * args.lines + 1
|
||||
window_width = monitor_width
|
||||
set_smallest_allowed_resize(100, h)
|
||||
else:
|
||||
w = window_width = cell_width * args.columns + 1
|
||||
window_width = cell_width * args.columns + 1
|
||||
window_height = monitor_height
|
||||
set_smallest_allowed_resize(w, 100)
|
||||
return window_width, window_height
|
||||
|
||||
return initial_window_size
|
||||
|
||||
@ -521,10 +521,6 @@ def glfw_primary_monitor_size() -> Tuple[int, int]:
|
||||
pass
|
||||
|
||||
|
||||
def set_smallest_allowed_resize(width: int, height: int) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def set_default_window_icon(path: str) -> None:
|
||||
pass
|
||||
|
||||
|
||||
18
kitty/glfw.c
18
kitty/glfw.c
@ -33,7 +33,12 @@ request_tick_callback(void) {
|
||||
glfwPostEmptyEvent();
|
||||
}
|
||||
|
||||
static int min_width = 100, min_height = 100;
|
||||
static inline void
|
||||
min_size_for_os_window(OSWindow *window, int *min_width, int *min_height) {
|
||||
*min_width = MAX(8u, window->fonts_data->cell_width + 1);
|
||||
*min_height = MAX(8u, window->fonts_data->cell_height + 1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
update_os_window_viewport(OSWindow *window, bool notify_boss) {
|
||||
@ -46,7 +51,8 @@ update_os_window_viewport(OSWindow *window, bool notify_boss) {
|
||||
if (fw == window->viewport_width && fh == window->viewport_height && w == window->window_width && h == window->window_height && xdpi == window->logical_dpi_x && ydpi == window->logical_dpi_y) {
|
||||
return; // no change, ignore
|
||||
}
|
||||
if (w <= 0 || h <= 0 || fw / w > 5 || fh / h > 5 || fw < min_width || fh < min_height || fw < w || fh < h) {
|
||||
int min_width, min_height; min_size_for_os_window(window, &min_width, &min_height);
|
||||
if (w <= 0 || h <= 0 || fw < min_width || fh < min_height || fw < w || fh < h) {
|
||||
log_error("Invalid geometry ignored: framebuffer: %dx%d window: %dx%d\n", fw, fh, w, h);
|
||||
if (!window->viewport_updated_at_least_once) {
|
||||
window->viewport_width = min_width; window->viewport_height = min_height;
|
||||
@ -191,6 +197,7 @@ live_resize_callback(GLFWwindow *w, bool started) {
|
||||
static void
|
||||
framebuffer_size_callback(GLFWwindow *w, int width, int height) {
|
||||
if (!set_callback_window(w)) return;
|
||||
int min_width, min_height; min_size_for_os_window(global_state.callback_os_window, &min_width, &min_height);
|
||||
if (width >= min_width && height >= min_height) {
|
||||
OSWindow *window = global_state.callback_os_window;
|
||||
global_state.has_pending_resizes = true;
|
||||
@ -1202,12 +1209,6 @@ set_primary_selection(PyObject UNUSED *self, PyObject *args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
set_smallest_allowed_resize(PyObject *self UNUSED, PyObject *args) {
|
||||
if (!PyArg_ParseTuple(args, "ii", &min_width, &min_height)) return NULL;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
set_custom_cursor(PyObject *self UNUSED, PyObject *args) {
|
||||
int shape;
|
||||
@ -1345,7 +1346,6 @@ stop_main_loop(void) {
|
||||
|
||||
static PyMethodDef module_methods[] = {
|
||||
METHODB(set_custom_cursor, METH_VARARGS),
|
||||
METHODB(set_smallest_allowed_resize, METH_VARARGS),
|
||||
METHODB(create_os_window, METH_VARARGS),
|
||||
METHODB(set_default_window_icon, METH_VARARGS),
|
||||
METHODB(get_clipboard_string, METH_NOARGS),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user