fix: add Wayland support (#26022)

This commit is contained in:
Valentin Hăloiu 2020-10-20 20:24:52 +02:00 committed by GitHub
parent d38c47e748
commit c4525b4ea6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 272 additions and 159 deletions

View file

@ -59,20 +59,32 @@
#include "ui/wm/core/wm_state.h"
#endif
#if defined(USE_X11)
#if defined(OS_LINUX)
#include "base/environment.h"
#include "base/nix/xdg_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/gtk/gtk_ui.h"
#include "ui/gtk/gtk_ui_delegate.h"
#include "ui/gtk/gtk_util.h"
#include "ui/views/linux_ui/linux_ui.h"
#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#endif
#if defined(USE_X11)
#include "ui/base/x/x11_util.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto_util.h"
#include "ui/gtk/gtk_ui.h"
#include "ui/gtk/gtk_ui_delegate.h"
#include "ui/gtk/gtk_util.h"
#include "ui/gtk/x/gtk_ui_delegate_x11.h"
#include "ui/views/linux_ui/linux_ui.h"
#endif
#if defined(USE_OZONE) || defined(USE_X11)
#include "ui/base/ui_base_features.h"
#endif
#endif
#if defined(OS_WIN)
@ -336,11 +348,15 @@ void ElectronBrowserMainParts::PostDestroyThreads() {
void ElectronBrowserMainParts::ToolkitInitialized() {
#if defined(USE_X11)
// In Aura/X11, Gtk-based LinuxUI implementation is used.
gtk_ui_delegate_ =
std::make_unique<ui::GtkUiDelegateX11>(x11::Connection::Get());
ui::GtkUiDelegate::SetInstance(gtk_ui_delegate_.get());
views::LinuxUI* linux_ui = BuildGtkUi(gtk_ui_delegate_.get());
if (!features::IsUsingOzonePlatform()) {
// In Aura/X11, Gtk-based LinuxUI implementation is used.
gtk_ui_delegate_ =
std::make_unique<ui::GtkUiDelegateX11>(x11::Connection::Get());
ui::GtkUiDelegate::SetInstance(gtk_ui_delegate_.get());
}
#endif
#if defined(OS_LINUX)
views::LinuxUI* linux_ui = BuildGtkUi(ui::GtkUiDelegate::instance());
views::LinuxUI::SetInstance(linux_ui);
linux_ui->Initialize();
@ -402,7 +418,8 @@ void ElectronBrowserMainParts::PreMainMessageLoopRun() {
#endif
#if defined(USE_X11)
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
if (!features::IsUsingOzonePlatform())
ui::TouchFactory::SetTouchDeviceListFromCommandLine();
#endif
content::WebUIControllerFactory::RegisterFactory(
@ -439,6 +456,14 @@ void ElectronBrowserMainParts::PreDefaultMainMessageLoopRun(
}
void ElectronBrowserMainParts::PostMainMessageLoopStart() {
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
auto shutdown_cb =
base::BindOnce(base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
ui::OzonePlatform::GetInstance()->PostMainMessageLoopStart(
std::move(shutdown_cb));
}
#endif
#if defined(OS_LINUX)
bluez::DBusBluezManagerWrapperLinux::Initialize();
#endif