ui/gtk: Fix event handling on macOS hosts
PATCH 1/1 ui/gtk: Fix event handling on macOS hosts
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
--- ui/gtk.c | 9 +++++++++ 1 file changed, 9 insertions(+)
ui/gtk.c +9 -0
@@ -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); }
Signature · 1 line
2.39.5 (Apple Git-154)
Charalampos contacted me off-list with his original patch and I made a few suggestions after testing it. So I'm not sure the 'Co-developed-by' tag is warranted given I didn't write any code. In any case, this patch worked in the testing I did on macOS, and it looks to be near-zero risk on other platforms. I can't think of a simpler fix to the problem.
or
whichever is deemed appropriate in these circumstances.
Quoted 40 lines · Charalampos Mitrodimas
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 <[email protected]>Signed-off-by Charalampos Mitrodimas <[email protected]>--- ui/gtk.c | 9 +++++++++ 1 file changed, 9 insertions(+)ui/gtk.c +9
-1@@ -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)