diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-10-10 15:11:42 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-23 13:31:33 +0200 |
commit | 03ee550bc147d9b02f55cd233c938b46b8598c7b (patch) | |
tree | d19f41f136da9e8bc7adcf9f5a1ccdaae64ea396 | |
parent | 1d63e8bf494af4a6c2f6c469802e8f4461914bbb (diff) | |
download | qtwebengine-chromium-03ee550bc147d9b02f55cd233c938b46b8598c7b.tar.gz |
Fix Chromium built with X11 running without
Handles cases where gfx::GetXDisplay() returns null at least for Qt.
Task-number: QTBUG-55384
Change-Id: Ie57c57d7189c279cb5c702325b450f9fb964ac60
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
9 files changed, 27 insertions, 15 deletions
diff --git a/chromium/content/browser/browser_main_loop.cc b/chromium/content/browser/browser_main_loop.cc index 60728faa5ad..4baaf2fcc57 100644 --- a/chromium/content/browser/browser_main_loop.cc +++ b/chromium/content/browser/browser_main_loop.cc @@ -423,7 +423,7 @@ class GpuDataManagerVisualProxy : public GpuDataManagerObserver { } void OnGpuInfoUpdate() override { - if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless)) + if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless) || !gfx::GetXDisplay()) return; gpu::GPUInfo gpu_info = gpu_data_manager_->GetGPUInfo(); if (!ui::XVisualManager::GetInstance()->OnGPUInfoChanged( @@ -550,7 +550,7 @@ int BrowserMainLoop::EarlyInitialization() { DCHECK(SandboxHostLinux::GetInstance()->IsInitialized()); #endif -#if defined(USE_X11) +#if defined(USE_X11) && !defined(TOOLKIT_QT) if (UsingInProcessGpu()) { if (!gfx::InitializeThreadedX11()) { LOG(ERROR) << "Failed to put Xlib into threaded mode."; @@ -1464,7 +1464,7 @@ bool BrowserMainLoop::InitializeToolkit() { #if defined(USE_AURA) -#if defined(USE_X11) +#if defined(USE_X11) && !defined(TOOLKIT_QT) if (!parsed_command_line_.HasSwitch(switches::kHeadless) && !gfx::GetXDisplay()) { LOG(ERROR) << "Unable to open X display."; diff --git a/chromium/content/browser/gpu/gpu_internals_ui.cc b/chromium/content/browser/gpu/gpu_internals_ui.cc index 210eb5fe2da..37e2a81ac26 100644 --- a/chromium/content/browser/gpu/gpu_internals_ui.cc +++ b/chromium/content/browser/gpu/gpu_internals_ui.cc @@ -227,9 +227,9 @@ std::unique_ptr<base::DictionaryValue> GpuInfoAsDictionaryValue() { basic_info->Append(NewDescriptionValuePair("Window system binding extensions", gpu_info.gl_ws_extensions)); #if defined(USE_X11) - basic_info->Append(NewDescriptionValuePair("Window manager", - ui::GuessWindowManagerName())); - { + if (gfx::GetXDisplay()) { + basic_info->Append(NewDescriptionValuePair("Window manager", + ui::GuessWindowManagerName())); std::unique_ptr<base::Environment> env(base::Environment::Create()); std::string value; const char kXDGCurrentDesktop[] = "XDG_CURRENT_DESKTOP"; @@ -266,10 +266,12 @@ std::unique_ptr<base::DictionaryValue> GpuInfoAsDictionaryValue() { #endif #if defined(USE_X11) - basic_info->Append(NewDescriptionValuePair( - "System visual ID", base::NumberToString(gpu_info.system_visual))); - basic_info->Append(NewDescriptionValuePair( - "RGBA visual ID", base::NumberToString(gpu_info.rgba_visual))); + if (gfx::GetXDisplay()) { + basic_info->Append(NewDescriptionValuePair( + "System visual ID", base::NumberToString(gpu_info.system_visual))); + basic_info->Append(NewDescriptionValuePair( + "RGBA visual ID", base::NumberToString(gpu_info.rgba_visual))); + } #endif info->Set("basic_info", std::move(basic_info)); diff --git a/chromium/content/gpu/gpu_main.cc b/chromium/content/gpu/gpu_main.cc index d9c8b6d8c61..a61e3779347 100644 --- a/chromium/content/gpu/gpu_main.cc +++ b/chromium/content/gpu/gpu_main.cc @@ -257,9 +257,11 @@ int GpuMain(const MainFunctionParams& parameters) { // We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX // and https://crbug.com/326995. +#if !defined(TOOLKIT_QT) ui::SetDefaultX11ErrorHandlers(); if (!gfx::GetXDisplay()) return RESULT_CODE_GPU_DEAD_ON_ARRIVAL; +#endif main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); event_source = ui::PlatformEventSource::CreateDefault(); #elif defined(USE_OZONE) diff --git a/chromium/services/device/wake_lock/power_save_blocker/power_save_blocker_x11.cc b/chromium/services/device/wake_lock/power_save_blocker/power_save_blocker_x11.cc index dc104b2f5dc..b19e363afea 100644 --- a/chromium/services/device/wake_lock/power_save_blocker/power_save_blocker_x11.cc +++ b/chromium/services/device/wake_lock/power_save_blocker/power_save_blocker_x11.cc @@ -434,6 +434,9 @@ bool PowerSaveBlocker::Delegate::XSSAvailable() { int major; int minor; + if (!display) + return false; + if (!XScreenSaverQueryExtension(display, &dummy, &dummy)) return false; diff --git a/chromium/third_party/angle/src/gpu_info_util/SystemInfo_x11.cpp b/chromium/third_party/angle/src/gpu_info_util/SystemInfo_x11.cpp index 3513309f36a..792305f5503 100644 --- a/chromium/third_party/angle/src/gpu_info_util/SystemInfo_x11.cpp +++ b/chromium/third_party/angle/src/gpu_info_util/SystemInfo_x11.cpp @@ -30,7 +30,7 @@ bool GetNvidiaDriverVersionWithXNVCtrl(std::string *version) Display *display = XOpenDisplay(nullptr); - if (XNVCTRLQueryExtension(display, &eventBase, &errorBase)) + if (display && XNVCTRLQueryExtension(display, &eventBase, &errorBase)) { int screenCount = ScreenCount(display); for (int screen = 0; screen < screenCount; ++screen) diff --git a/chromium/ui/base/x/x11_util.cc b/chromium/ui/base/x/x11_util.cc index 5be8a01f335..673d2090c65 100644 --- a/chromium/ui/base/x/x11_util.cc +++ b/chromium/ui/base/x/x11_util.cc @@ -142,6 +142,9 @@ bool SupportsEWMH() { bool GetWindowManagerName(std::string* wm_name) { DCHECK(wm_name); + if (!gfx::GetXDisplay()) + return false; + if (!SupportsEWMH()) return false; diff --git a/chromium/ui/display/util/x11/edid_parser_x11.cc b/chromium/ui/display/util/x11/edid_parser_x11.cc index 57baee9200c..e87c201c450 100644 --- a/chromium/ui/display/util/x11/edid_parser_x11.cc +++ b/chromium/ui/display/util/x11/edid_parser_x11.cc @@ -26,10 +26,12 @@ bool IsRandRAvailable() { // Returns true if EDID property is successfully obtained. Otherwise returns // false and does not touch |edid|. bool GetEDIDProperty(XID output, std::vector<uint8_t>* edid) { - if (!IsRandRAvailable()) + Display* display = gfx::GetXDisplay(); + if (!display) return false; - Display* display = gfx::GetXDisplay(); + if (!IsRandRAvailable()) + return false; Atom edid_property = gfx::GetAtom(RR_PROPERTY_RANDR_EDID); diff --git a/chromium/ui/events/platform/x11/x11_event_source_libevent.cc b/chromium/ui/events/platform/x11/x11_event_source_libevent.cc index c18ea6dc840..db14467eea4 100644 --- a/chromium/ui/events/platform/x11/x11_event_source_libevent.cc +++ b/chromium/ui/events/platform/x11/x11_event_source_libevent.cc @@ -255,7 +255,7 @@ void X11EventSourceLibevent::OnFileCanWriteWithoutBlocking(int fd) { NOTREACHED(); } -#if defined(USE_X11) +#if defined(USE_X11) && !defined(TOOLKIT_QT) std::unique_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() { return base::MakeUnique<X11EventSourceLibevent>(gfx::GetXDisplay()); } diff --git a/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.cc index 2822c8e41ef..346256c318d 100644 --- a/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.cc +++ b/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.cc @@ -42,7 +42,7 @@ namespace { // static gfx::ICCProfile GetICCProfileForMonitor(int monitor) { gfx::ICCProfile icc_profile; - if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless)) + if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless) || !gfx::GetXDisplay()) return icc_profile; std::string atom_name; if (monitor == 0) { |