mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 07:55:10 +02:00
Workaround for window managers like xmonad that in some circumstances set window size to zero. Fixes #1910
This commit is contained in:
16
kitty/glfw.c
16
kitty/glfw.c
@@ -44,10 +44,20 @@ 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) {
|
if (fw == window->viewport_width && fh == window->viewport_height && w == window->window_width && h == window->window_height) {
|
||||||
return; // no change, ignore
|
return; // no change, ignore
|
||||||
}
|
}
|
||||||
if (fw / w > 5 || fh / h > 5 || fw < min_width || fh < min_height || fw < w || fh < h) {
|
if (w <= 0 || h <= 0 || fw / w > 5 || fh / h > 5 || 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);
|
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;
|
||||||
|
window->window_width = min_width; window->window_height = min_height;
|
||||||
|
window->viewport_x_ratio = 1; window->viewport_y_ratio = 1;
|
||||||
|
window->viewport_size_dirty = true;
|
||||||
|
if (notify_boss) {
|
||||||
|
call_boss(on_window_resize, "KiiO", window->id, window->viewport_width, window->viewport_height, Py_False);
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
window->viewport_updated_at_least_once = true;
|
||||||
window->viewport_width = fw; window->viewport_height = fh;
|
window->viewport_width = fw; window->viewport_height = fh;
|
||||||
double xr = window->viewport_x_ratio, yr = window->viewport_y_ratio;
|
double xr = window->viewport_x_ratio, yr = window->viewport_y_ratio;
|
||||||
window->viewport_x_ratio = w > 0 ? (double)window->viewport_width / (double)w : xr;
|
window->viewport_x_ratio = w > 0 ? (double)window->viewport_width / (double)w : xr;
|
||||||
@@ -59,8 +69,8 @@ update_os_window_viewport(OSWindow *window, bool notify_boss) {
|
|||||||
window->viewport_size_dirty = true;
|
window->viewport_size_dirty = true;
|
||||||
window->viewport_width = MAX(window->viewport_width, min_width);
|
window->viewport_width = MAX(window->viewport_width, min_width);
|
||||||
window->viewport_height = MAX(window->viewport_height, min_height);
|
window->viewport_height = MAX(window->viewport_height, min_height);
|
||||||
window->window_width = MAX(w, 100);
|
window->window_width = MAX(w, min_width);
|
||||||
window->window_height = MAX(h, 100);
|
window->window_height = MAX(h, min_height);
|
||||||
if (notify_boss) {
|
if (notify_boss) {
|
||||||
call_boss(on_window_resize, "KiiO", window->id, window->viewport_width, window->viewport_height, dpi_changed ? Py_True : Py_False);
|
call_boss(on_window_resize, "KiiO", window->id, window->viewport_width, window->viewport_height, dpi_changed ? Py_True : Py_False);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ typedef struct {
|
|||||||
bool mouse_button_pressed[20];
|
bool mouse_button_pressed[20];
|
||||||
PyObject *window_title;
|
PyObject *window_title;
|
||||||
bool is_key_pressed[MAX_KEY_COUNT];
|
bool is_key_pressed[MAX_KEY_COUNT];
|
||||||
bool viewport_size_dirty;
|
bool viewport_size_dirty, viewport_updated_at_least_once;
|
||||||
LiveResizeInfo live_resize;
|
LiveResizeInfo live_resize;
|
||||||
bool has_pending_resizes, is_semi_transparent, shown_once, is_damaged;
|
bool has_pending_resizes, is_semi_transparent, shown_once, is_damaged;
|
||||||
uint32_t offscreen_texture_id;
|
uint32_t offscreen_texture_id;
|
||||||
|
|||||||
Reference in New Issue
Block a user