diff --git a/src/compton.c b/src/compton.c index 7ac5daa6..f086eb5b 100644 --- a/src/compton.c +++ b/src/compton.c @@ -4016,7 +4016,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) { ps->o.wintype_shadow[WINTYPE_DND] = false; if (fading_enable) wintype_arr_enable(ps->o.wintype_fade); - if (!isnan(cfgtmp.menu_opacity)) { + if (!safe_isnan(cfgtmp.menu_opacity)) { ps->o.wintype_opacity[WINTYPE_DROPDOWN_MENU] = cfgtmp.menu_opacity; ps->o.wintype_opacity[WINTYPE_POPUP_MENU] = cfgtmp.menu_opacity; } diff --git a/src/utils.h b/src/utils.h index 5f033f0e..fbb88b2d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -4,6 +4,17 @@ #include #include #include +#include + +#ifdef __FAST_MATH__ +#warning Use of -ffast-math can cause rendering error or artifacts, \ + therefore it is not recommended. +#endif + +__attribute__((optimize("-fno-fast-math"))) +static inline bool safe_isnan(double a) { + return isnan(a); +} /** * Normalize an int value to a specific range. diff --git a/src/win.c b/src/win.c index a1e3d098..b778b28f 100644 --- a/src/win.c +++ b/src/win.c @@ -324,7 +324,7 @@ void win_calc_opacity(session_t *ps, win *w) { // Try obeying opacity property and window type opacity firstly if (w->has_opacity_prop) opacity = w->opacity_prop; - else if (!isnan(ps->o.wintype_opacity[w->window_type])) + else if (!safe_isnan(ps->o.wintype_opacity[w->window_type])) opacity = ps->o.wintype_opacity[w->window_type] * OPAQUE; else { // Respect active_opacity only when the window is physically focused