diff options
Diffstat (limited to 'ui/gtk.c')
-rw-r--r-- | ui/gtk.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -749,10 +749,10 @@ static void gd_resize_event(GtkGLArea *area, #endif /* - * If available, return the refresh rate of the display in milli-Hertz, - * else return 0. + * If available, return the update interval of the monitor in ms, + * else return 0 (the default update interval). */ -static int gd_refresh_rate_millihz(GtkWidget *widget) +static int gd_monitor_update_interval(GtkWidget *widget) { #ifdef GDK_VERSION_3_22 GdkWindow *win = gtk_widget_get_window(widget); @@ -760,8 +760,13 @@ static int gd_refresh_rate_millihz(GtkWidget *widget) if (win) { GdkDisplay *dpy = gtk_widget_get_display(widget); GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win); + int refresh_rate = gdk_monitor_get_refresh_rate(monitor); /* [mHz] */ - return gdk_monitor_get_refresh_rate(monitor); + if (refresh_rate) { + /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */ + return MIN(1000 * 1000 / refresh_rate, + GUI_REFRESH_INTERVAL_DEFAULT); + } } #endif return 0; @@ -774,7 +779,6 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque) int mx, my; int ww, wh; int fbw, fbh; - int refresh_rate_millihz; #if defined(CONFIG_OPENGL) if (vc->gfx.gls) { @@ -795,12 +799,8 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque) return FALSE; } - refresh_rate_millihz = gd_refresh_rate_millihz(vc->window ? - vc->window : s->window); - if (refresh_rate_millihz) { - /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */ - vc->gfx.dcl.update_interval = 1000 * 1000 / refresh_rate_millihz; - } + vc->gfx.dcl.update_interval = + gd_monitor_update_interval(vc->window ? vc->window : s->window); fbw = surface_width(vc->gfx.ds); fbh = surface_height(vc->gfx.ds); |