From 942cadd4a7d09d5ae5ca46c776870eec667cb010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=89=AC=E6=96=8C?= Date: Wed, 4 Dec 2024 19:12:35 +0800 Subject: [PATCH] GTK: When using CEF and yield, process CEF pending events. We should process CEF pending events when yield, it is essential for clipboard interection to use the same event loop weaved for two literally indenpendent applications(our own app and CEF). --- src/gtk/evtloop.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gtk/evtloop.cpp b/src/gtk/evtloop.cpp index fce31f5c3737..798d0df5480e 100644 --- a/src/gtk/evtloop.cpp +++ b/src/gtk/evtloop.cpp @@ -26,6 +26,7 @@ #ifndef WX_PRECOMP #include "wx/app.h" #include "wx/log.h" + #include "wx/event.h" #endif // WX_PRECOMP #include "wx/private/eventloopsourcesmanager.h" @@ -411,8 +412,17 @@ void wxGUIEventLoop::DoYieldFor(long eventsToProcess) wxgtk_main_do_event(gdk_event_, this); gdk_event_free(gdk_event_); } - else + else { + // while no local gdk events pending, + // we should schedule one time trigger to allow events for CEF + // to be handled, this is essential to unblock us from clipboard + // interaction with CEF. + // this bogus event will let the DoMessageLoopWork() kick in. + wxCommandEvent cef_jobs_trigger{}; + if (wxTheApp) + wxTheApp->ProcessEvent(dynamic_cast(cef_jobs_trigger)); break; + } } } else {