macOS: Fix dragging kitty window tabs in traditional full screen mode causing crashes

Fixes #1296
Apparently, macOS reports NaN DPI values in this scenario.

I dont know enough about cocoa internals to understand why, or
what is actually supposed to happen in this scenario, but at least we
should not crash.
This commit is contained in:
Kovid Goyal 2019-01-11 11:09:34 +05:30
parent 8efbc479e1
commit 851885568f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 4 deletions

View File

@ -12,6 +12,9 @@ Changelog
- Fix a regression in the previous release that broke using ``background`` for
:opt:`cursor_text_color` (:iss:`1288`)
- macOS: Fix dragging kitty window tabs in traditional full screen mode causing
crashes (:iss:`1296`)
0.13.2 [2019-01-04]
------------------------------

View File

@ -35,8 +35,8 @@ update_os_window_viewport(OSWindow *window, bool notify_boss) {
}
window->viewport_width = fw; window->viewport_height = fh;
double xr = window->viewport_x_ratio, yr = window->viewport_y_ratio;
window->viewport_x_ratio = (double)window->viewport_width / (double)w;
window->viewport_y_ratio = (double)window->viewport_height / (double)h;
window->viewport_x_ratio = w > 0 ? (double)window->viewport_width / (double)w : xr;
window->viewport_y_ratio = h > 0 ? (double)window->viewport_height / (double)h : yr;
double xdpi = window->logical_dpi_x, ydpi = window->logical_dpi_y;
set_os_window_dpi(window);
bool dpi_changed = (xr != 0.0 && xr != window->viewport_x_ratio) || (yr != 0.0 && yr != window->viewport_y_ratio) || (xdpi != window->logical_dpi_x) || (ydpi != window->logical_dpi_y);
@ -352,8 +352,9 @@ get_window_dpi(GLFWwindow *w, double *x, double *y) {
float xscale = 1, yscale = 1;
if (w) glfwGetWindowContentScale(w, &xscale, &yscale);
else glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &xscale, &yscale);
if (!xscale) xscale = 1.0;
if (!yscale) yscale = 1.0;
// check for zero or NaN values of xscale/yscale
if (!xscale || xscale != xscale) xscale = 1.0;
if (!yscale || yscale != yscale) yscale = 1.0;
#ifdef __APPLE__
double factor = 72.0;
#else