Commit c697a54a authored by Olivier Fourdan's avatar Olivier Fourdan 🛠

common: Avoid zero refresh rate for monitor

The function gdk_monitor_get_refresh_rate() can return 0 if there is no
real monitor attached (as with Xephyr or VNC for example).

The compositor use the value as a divisor to compute the frequency of
refresh when zooming, and if the value is 0, xfwm4 will crash with a
floating point exception (division by zero error).

Make sure we return something even if gdk_monitor_get_refresh_rate()
cannot get us a real refresh rate.
Signed-off-by: Olivier Fourdan's avatarOlivier Fourdan <>
parent 98abe925
Pipeline #4992 passed with stages
in 2 minutes and 59 seconds
......@@ -22,7 +22,7 @@
#include <gdk/gdkx.h>
#include "xfwm-common.h"
......@@ -140,11 +140,19 @@ xfwm_get_primary_refresh_rate (GdkScreen *screen)
GdkDisplay *display;
GdkMonitor *monitor;
int refresh_rate;
display = gdk_screen_get_display (screen);
monitor = gdk_display_get_primary_monitor (display);
refresh_rate = 0;
if (monitor)
refresh_rate = gdk_monitor_get_refresh_rate (monitor) / 1000;
if (refresh_rate)
return refresh_rate;
return gdk_monitor_get_refresh_rate (monitor) / 1000;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment