Linux: cefclient: Fix GTK behavior with multi-threaded-message-loop (fixes issue #3087)

Switch to using g_main_context_default() in MainMessageLoopMultithreadedGtk. As of M86
(https://crrev.com/b960daf4e6) Chromium now creates its own context in MessagePumpGlib so
we can use the default context in cefclient. This is also more "correct" from a GTK usage
perspective. As part of this change all GTK dialogs and callbacks are now executed on the
main thread instead of the UI thread (note that these are the same thread when not using
multi-threaded-message-loop).
This commit is contained in:
Marshall Greenblatt
2021-02-12 11:46:38 -08:00
parent 7fe6a18f03
commit b3ad79e2c5
3 changed files with 23 additions and 33 deletions

View File

@ -78,10 +78,9 @@ MainMessageLoopMultithreadedGtk::~MainMessageLoopMultithreadedGtk() {
int MainMessageLoopMultithreadedGtk::Run() {
DCHECK(RunsTasksOnCurrentThread());
// Chromium uses the default GLib context so we create our own context and
// make it the default for this thread.
main_context_ = g_main_context_new();
g_main_context_push_thread_default(main_context_);
// We use the default Glib context and Chromium creates its own context in
// MessagePumpGlib (starting in M86).
main_context_ = g_main_context_default();
main_loop_ = g_main_loop_new(main_context_, TRUE);
@ -100,8 +99,6 @@ int MainMessageLoopMultithreadedGtk::Run() {
g_main_loop_unref(main_loop_);
main_loop_ = nullptr;
g_main_context_pop_thread_default(main_context_);
g_main_context_unref(main_context_);
main_context_ = nullptr;
return 0;