mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Linux: Add support for ozone builds (fixes issue #2296).
Ozone builds can run with different platform backends (Wayland, X11, etc). Usage of the Views framework is required, and the cefclient sample application is not supported. Example usage: $ export GN_DEFINES="use_ozone=true" $ cd /path/to/chromium/src/cef $ ./cef_create_projects.sh $ cd /path/to/chromium/src $ ninja -C out/Release_GN_x64 cefsimple $ ./out/Release_GN_x64/cefsimple --use-views --ozone-platform=wayland Binary distributions can be created by passing the `--ozone` flag to make_distrib.py.
This commit is contained in:
committed by
Marshall Greenblatt
parent
07863c0d46
commit
491253fa03
@@ -10,7 +10,6 @@
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/native/menu_runner_linux.h"
|
||||
#include "libcef/browser/native/window_delegate_view.h"
|
||||
#include "libcef/browser/native/window_x11.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include "base/no_destructor.h"
|
||||
@@ -23,10 +22,14 @@
|
||||
#include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
|
||||
#include "ui/events/keycodes/keysym_to_unicode.h"
|
||||
#include "ui/gfx/font_render_params.h"
|
||||
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
#include "third_party/blink/public/mojom/renderer_preferences.mojom.h"
|
||||
|
||||
#if defined(USE_X11)
|
||||
#include "libcef/browser/native/window_x11.h"
|
||||
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// Returns the number of seconds since system boot.
|
||||
@@ -48,8 +51,7 @@ CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux(
|
||||
false,
|
||||
use_external_begin_frame),
|
||||
host_window_created_(false),
|
||||
window_widget_(nullptr),
|
||||
window_x11_(nullptr) {}
|
||||
window_widget_(nullptr) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
|
||||
CefBrowserHostImpl* browser) {
|
||||
@@ -62,7 +64,6 @@ void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
|
||||
}
|
||||
|
||||
bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
DCHECK(!window_x11_);
|
||||
DCHECK(!window_widget_);
|
||||
|
||||
if (window_info_.width == 0)
|
||||
@@ -73,6 +74,8 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
gfx::Rect rect(window_info_.x, window_info_.y, window_info_.width,
|
||||
window_info_.height);
|
||||
|
||||
#if defined(USE_X11)
|
||||
DCHECK(!window_x11_);
|
||||
// Create a new window object. It will delete itself when the associated X11
|
||||
// window is destroyed.
|
||||
window_x11_ = new CefWindowX11(browser_, window_info_.parent_window, rect,
|
||||
@@ -93,6 +96,7 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
window_widget_->Show();
|
||||
|
||||
window_x11_->Show();
|
||||
#endif // defined(USE_X11)
|
||||
|
||||
// As an additional requirement on Linux, we must set the colors for the
|
||||
// render widgets in webkit.
|
||||
@@ -121,8 +125,10 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::CloseHostWindow() {
|
||||
#if defined(USE_X11)
|
||||
if (window_x11_)
|
||||
window_x11_->Close();
|
||||
#endif
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserPlatformDelegateNativeLinux::GetHostWindowHandle()
|
||||
@@ -146,18 +152,21 @@ void CefBrowserPlatformDelegateNativeLinux::SendFocusEvent(bool setFocus) {
|
||||
browser_->web_contents()->Focus();
|
||||
}
|
||||
|
||||
#if defined(USE_X11)
|
||||
if (window_x11_) {
|
||||
// Give native focus to the DesktopNativeWidgetAura for the root window.
|
||||
// Needs to be done via the ::Window so that keyboard focus is assigned
|
||||
// correctly.
|
||||
window_x11_->Focus();
|
||||
}
|
||||
#endif // defined(USE_X11)
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
|
||||
// Call the parent method to dismiss any existing popups.
|
||||
CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted();
|
||||
|
||||
#if defined(USE_X11)
|
||||
if (!window_x11_)
|
||||
return;
|
||||
|
||||
@@ -175,13 +184,16 @@ void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
|
||||
content::RenderWidgetHostImpl::From(
|
||||
browser_->web_contents()->GetRenderViewHost()->GetWidget())
|
||||
->SendScreenRects();
|
||||
#endif // defined(USE_X11)
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::SizeTo(int width, int height) {
|
||||
#if defined(USE_X11)
|
||||
if (window_x11_) {
|
||||
window_x11_->SetBounds(
|
||||
gfx::Rect(window_x11_->bounds().origin(), gfx::Size(width, height)));
|
||||
}
|
||||
#endif // defined(USE_X11)
|
||||
}
|
||||
|
||||
gfx::Point CefBrowserPlatformDelegateNativeLinux::GetScreenPoint(
|
||||
@@ -189,6 +201,7 @@ gfx::Point CefBrowserPlatformDelegateNativeLinux::GetScreenPoint(
|
||||
if (windowless_handler_)
|
||||
return windowless_handler_->GetParentScreenPoint(view);
|
||||
|
||||
#if defined(USE_X11)
|
||||
if (!window_x11_)
|
||||
return view;
|
||||
|
||||
@@ -198,6 +211,8 @@ gfx::Point CefBrowserPlatformDelegateNativeLinux::GetScreenPoint(
|
||||
const gfx::Rect& bounds_in_screen = window_x11_->GetBoundsInScreen();
|
||||
return gfx::Point(bounds_in_screen.x() + view.x(),
|
||||
bounds_in_screen.y() + view.y());
|
||||
#endif // defined(USE_X11)
|
||||
return gfx::Point();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::ViewText(const std::string& text) {
|
||||
@@ -260,6 +275,7 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
#if defined(USE_X11)
|
||||
// Populate DOM values that will be passed to JavaScript handlers via
|
||||
// KeyboardEvent.
|
||||
result.dom_code = static_cast<int>(
|
||||
@@ -275,6 +291,7 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
|
||||
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(key_event.modifiers));
|
||||
#endif // defined(USE_X11)
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::TranslateClickEvent(
|
||||
@@ -363,7 +380,8 @@ CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const {
|
||||
if (!event.os_event)
|
||||
return NULL;
|
||||
return const_cast<CefEventHandle>(event.os_event->native_event());
|
||||
return const_cast<CefEventHandle>(
|
||||
static_cast<CefEventHandle>(event.os_event->native_event()));
|
||||
}
|
||||
|
||||
std::unique_ptr<CefMenuRunner>
|
||||
|
Reference in New Issue
Block a user