Fwd: [PATCH] ui/gtk: Update refresh rate for EGL as well

Nikola Pavlica posted 1 patch 3 years, 4 months ago
Failed in applying to current master (apply log)
include/ui/gtk.h | 1 +
ui/gtk-egl.c     | 8 ++++++++
ui/gtk.c         | 2 +-
3 files changed, 10 insertions(+), 1 deletion(-)
Fwd: [PATCH] ui/gtk: Update refresh rate for EGL as well
Posted by Nikola Pavlica 3 years, 4 months ago
I guess "git send-email" didn't do much, so I'm just forwarding the 
email now.

---------- Forwarded message ----------
 From: Nikola Pavlica <pavlica.nikola@gmail.com>
Subject: [PATCH] ui/gtk: Update refresh rate for EGL as well
Date: 2020-12-10T13:40:06+0100
To: qemu-devel@nongnu.com
Cc: Nikola Pavlica <pavlica.nikola@gmail.com>

---
 include/ui/gtk.h | 1 +
 ui/gtk-egl.c     | 8 ++++++++
 ui/gtk.c         | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/ui/gtk.h b/include/ui/gtk.h
index eaeb450f91..6025a4f030 100644
--- a/include/ui/gtk.h
+++ b/include/ui/gtk.h
@@ -88,6 +88,7 @@ extern bool gtk_use_gl_area;

 /* ui/gtk.c */
 void gd_update_windowsize(VirtualConsole *vc);
+int gd_refresh_rate_millihz(GtkWidget *window);

 /* ui/gtk-egl.c */
 void gd_egl_init(VirtualConsole *vc);
diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c
index 99231a3597..a9131783f0 100644
--- a/ui/gtk-egl.c
+++ b/ui/gtk-egl.c
@@ -112,6 +112,14 @@ void gd_egl_update(DisplayChangeListener *dcl,
 void gd_egl_refresh(DisplayChangeListener *dcl)
 {
     VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
+    int refresh_rate_millihz;
+
+    refresh_rate_millihz = gd_refresh_rate_millihz(vc->window ? 
vc->window :
+                                                   
vc->gfx.drawing_area);
+    if (refresh_rate_millihz) {
+        vc->gfx.dcl.update_interval = MILLISEC_PER_SEC / 
refresh_rate_millihz;
+    }
+

     if (!vc->gfx.esurface) {
         gd_egl_init(vc);
diff --git a/ui/gtk.c b/ui/gtk.c
index a752aa22be..3b8755b746 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -752,7 +752,7 @@ static void gd_resize_event(GtkGLArea *area,
  * If available, return the refresh rate of the display in milli-Hertz,
  * else return 0.
  */
-static int gd_refresh_rate_millihz(GtkWidget *window)
+int gd_refresh_rate_millihz(GtkWidget *window)
 {
 #ifdef GDK_VERSION_3_22
     GdkWindow *win = gtk_widget_get_window(window);
-- 
2.29.2