Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1864)

Unified Diff: ui/ozone/platform/x11/ozone_platform_x11.cc

Issue 2773503003: Change Ozone X11 PlatformEventSource initialization. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/x11/ozone_platform_x11.cc
diff --git a/ui/ozone/platform/x11/ozone_platform_x11.cc b/ui/ozone/platform/x11/ozone_platform_x11.cc
index 03ac7cc92662e59bd09d6440cc84658e83e0ba6d..9f515aca5da86dce3ec2a4d61e06b9a75d3d72a0 100644
--- a/ui/ozone/platform/x11/ozone_platform_x11.cc
+++ b/ui/ozone/platform/x11/ozone_platform_x11.cc
@@ -86,10 +86,11 @@ class OzonePlatformX11 : public OzonePlatform {
void InitializeUI(const InitParams& params) override {
InitializeCommon(params);
- window_manager_.reset(new X11WindowManagerOzone);
- overlay_manager_.reset(new StubOverlayManager());
+ CreatePlatformEventSource();
+ window_manager_ = base::MakeUnique<X11WindowManagerOzone>();
+ overlay_manager_ = base::MakeUnique<StubOverlayManager>();
input_controller_ = CreateStubInputController();
- cursor_factory_ozone_.reset(new X11CursorFactoryOzone());
+ cursor_factory_ozone_ = base::MakeUnique<X11CursorFactoryOzone>();
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
}
@@ -97,7 +98,13 @@ class OzonePlatformX11 : public OzonePlatform {
void InitializeGPU(const InitParams& params) override {
InitializeCommon(params);
- surface_factory_ozone_.reset(new X11SurfaceFactory());
+
+ // In single process mode either the UI thread will create an event source
+ // or it's a test and an event source isn't desired.
+ if (!params.single_process && !RunningInsideMus())
+ CreatePlatformEventSource();
+
+ surface_factory_ozone_ = base::MakeUnique<X11SurfaceFactory>();
}
void InitializeGPU() override { NOTREACHED(); }
@@ -116,17 +123,24 @@ class OzonePlatformX11 : public OzonePlatform {
if (common_initialized_)
return;
- // If both UI and GPU are running in the same process then XInitThreads()
- // must be the first Xlib call.
+ // In single process mode XInitThreads() must be the first Xlib call.
if (params.single_process || RunningInsideMus())
XInitThreads();
ui::SetDefaultX11ErrorHandlers();
- event_source_.reset(new X11EventSourceLibevent(gfx::GetXDisplay()));
common_initialized_ = true;
}
+ // Creates |event_source_| if it doesn't already exist.
+ void CreatePlatformEventSource() {
+ if (event_source_)
+ return;
+
+ XDisplay* display = gfx::GetXDisplay();
+ event_source_ = base::MakeUnique<X11EventSourceLibevent>(display);
+ }
+
bool common_initialized_ = false;
// Objects in the UI process.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698