The GTK+ UI was not properly handling events on macOS due to missing
event loop polling in the Cocoa backend. Add polling of the GLib main
context during display refresh to ensure UI events are processed.

This fixes UI responsiveness issues when running QEMU with the GTK
display (--display gtk) on macOS hosts.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2676

Co-developed-by: Phil Dennis-Jordan <p...@philjordan.eu>
Signed-off-by: Charalampos Mitrodimas <charmi...@posteo.net>
---
 ui/gtk.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ui/gtk.c b/ui/gtk.c
index bf9d3dd679..979210255f 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -437,6 +437,15 @@ static void gd_update(DisplayChangeListener *dcl,
 
 static void gd_refresh(DisplayChangeListener *dcl)
 {
+#ifdef GDK_WINDOWING_QUARTZ
+    GMainContext *context;
+    if (GDK_IS_QUARTZ_DISPLAY(gdk_display_get_default())) {
+        context = g_main_context_default();
+        while (g_main_context_pending(context)) {
+            g_main_context_iteration(context, FALSE);
+        }
+    }
+#endif
     graphic_hw_update(dcl->con);
 }
 
-- 
2.39.5 (Apple Git-154)


Reply via email to