Workaround for window managers like xmonad that in some circumstances set window size to zero. Fixes #1910

This commit is contained in:
Kovid Goyal 2019-08-17 18:02:29 +05:30
parent c5cb24378f
commit 77054f688d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 14 additions and 4 deletions

View File

@ -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) {
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);
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;
}
window->viewport_updated_at_least_once = true;
window->viewport_width = fw; window->viewport_height = fh;
double xr = window->viewport_x_ratio, yr = window->viewport_y_ratio;
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_width = MAX(window->viewport_width, min_width);
window->viewport_height = MAX(window->viewport_height, min_height);
window->window_width = MAX(w, 100);
window->window_height = MAX(h, 100);
window->window_width = MAX(w, min_width);
window->window_height = MAX(h, min_height);
if (notify_boss) {
call_boss(on_window_resize, "KiiO", window->id, window->viewport_width, window->viewport_height, dpi_changed ? Py_True : Py_False);
}

View File

@ -140,7 +140,7 @@ typedef struct {
bool mouse_button_pressed[20];
PyObject *window_title;
bool is_key_pressed[MAX_KEY_COUNT];
bool viewport_size_dirty;
bool viewport_size_dirty, viewport_updated_at_least_once;
LiveResizeInfo live_resize;
bool has_pending_resizes, is_semi_transparent, shown_once, is_damaged;
uint32_t offscreen_texture_id;