Commit 37fdac8f authored by Findit's avatar Findit Committed by Maksim Sisov

Revert "X11 and Ozone: Move initialization to DWTHPlatform"

This reverts commit 543a7657.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 693093 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzU0M2E3NjU3MDA4ODVkMmRiMzU4NzgzOWRjZmZjNGVjOGFhZTI5ODYM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.linux/fuchsia-x64-cast/51291

Sample Failed Step: compile

Original change's description:
> X11 and Ozone: Move initialization to DWTHPlatform
> 
> This CL moves the initialization of the X11Window aka PlatformWindow
> to the DWTHPlatform and let the WTHPlatform to own the window instead.
> 
> Also, instead of storing of XID in open_windows_, we store
> AcceleratedWidget now, which is ok as XID and AcceleratedWidget
> have the same type and it has already been used around the code.
> 
> In the follow up CLs, I will start moving all the other codes from
> DWTHX11 and add extend the existing PlatformWindow interface in
> order to be able stop accessing the XWindow directly from the
> DWTHX11.
> 
> Also, AdjustSize and GetRootTransform have been moved to DWTHPlatform
> and declared as protected so that DWTHX11 could access them. What is
> more, the ToPixelRect and ToDIPRect have been removed from DWTHX11 as
> the DWTHPlatform has already had those methods.
> 
> Bug: 990756
> Change-Id: I077773fe3154d12696dcbfb606bb3eb3122c0936
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769442
> Commit-Queue: Maksim Sisov <msisov@igalia.com>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#693093}


Change-Id: I1312146ae26ae17fed7985bba81ee81ad055ae32
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 990756
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1783522
Cr-Commit-Position: refs/heads/master@{#693104}
parent 03441a1e
...@@ -119,7 +119,7 @@ class DemoWindow : public ui::PlatformWindowDelegate { ...@@ -119,7 +119,7 @@ class DemoWindow : public ui::PlatformWindowDelegate {
#elif defined(OS_WIN) #elif defined(OS_WIN)
return std::make_unique<ui::WinWindow>(this, props.bounds); return std::make_unique<ui::WinWindow>(this, props.bounds);
#elif defined(USE_X11) #elif defined(USE_X11)
auto x11_window = std::make_unique<ui::X11Window>(this); auto x11_window = std::make_unique<ui::X11Window>(this, nullptr);
x11_window->Initialize(std::move(props)); x11_window->Initialize(std::move(props));
return x11_window; return x11_window;
#else #else
......
...@@ -44,7 +44,7 @@ void VulkanDemo::Initialize() { ...@@ -44,7 +44,7 @@ void VulkanDemo::Initialize() {
ui::PlatformWindowInitProperties properties; ui::PlatformWindowInitProperties properties;
properties.bounds = gfx::Rect(100, 100, 800, 600); properties.bounds = gfx::Rect(100, 100, 800, 600);
auto x11_window = std::make_unique<ui::X11Window>(this); auto x11_window = std::make_unique<ui::X11Window>(this, nullptr);
x11_window->Initialize(std::move(properties)); x11_window->Initialize(std::move(properties));
window_ = std::move(x11_window); window_ = std::move(x11_window);
......
...@@ -74,7 +74,7 @@ void WindowTreeHostPlatform::CreateAndSetPlatformWindow( ...@@ -74,7 +74,7 @@ void WindowTreeHostPlatform::CreateAndSetPlatformWindow(
#elif defined(OS_WIN) #elif defined(OS_WIN)
platform_window_.reset(new ui::WinWindow(this, properties.bounds)); platform_window_.reset(new ui::WinWindow(this, properties.bounds));
#elif defined(USE_X11) #elif defined(USE_X11)
auto x11_window = std::make_unique<ui::X11Window>(this); auto x11_window = std::make_unique<ui::X11Window>(this, nullptr);
x11_window->Initialize(std::move(properties)); x11_window->Initialize(std::move(properties));
SetPlatformWindow(std::move(x11_window)); SetPlatformWindow(std::move(x11_window));
#else #else
......
...@@ -25,7 +25,7 @@ namespace ui { ...@@ -25,7 +25,7 @@ namespace ui {
X11WindowOzone::X11WindowOzone(PlatformWindowDelegate* delegate, X11WindowOzone::X11WindowOzone(PlatformWindowDelegate* delegate,
X11WindowManagerOzone* window_manager) X11WindowManagerOzone* window_manager)
: X11Window(delegate), window_manager_(window_manager) { : X11Window(delegate, nullptr), window_manager_(window_manager) {
DCHECK(window_manager_); DCHECK(window_manager_);
// Set a class property key, which allows |this| to be used for interactive // Set a class property key, which allows |this| to be used for interactive
......
...@@ -73,18 +73,18 @@ struct PlatformWindowInitProperties { ...@@ -73,18 +73,18 @@ struct PlatformWindowInitProperties {
bool remove_standard_frame = false; bool remove_standard_frame = false;
std::string workspace; std::string workspace;
#if defined(OS_LINUX) #if defined(USE_X11)
// Only used by X11:
bool prefer_dark_theme = false; bool prefer_dark_theme = false;
gfx::ImageSkia* icon = nullptr; gfx::ImageSkia* icon = nullptr;
base::Optional<int> background_color; base::Optional<int> background_color;
#endif
// Specifies the res_name and res_class fields, // Specifies the res_name and res_class fields,
// respectively, of the WM_CLASS window property. Controls window grouping // respectively, of the WM_CLASS window property. Controls window grouping
// and desktop file matching in Linux window managers. // and desktop file matching in Linux window managers.
std::string wm_role_name; std::string wm_role_name;
std::string wm_class_name; std::string wm_class_name;
std::string wm_class_class; std::string wm_class_class;
#endif
}; };
} // namespace ui } // namespace ui
......
...@@ -71,8 +71,10 @@ ui::XWindow::Configuration ConvertInitPropertiesToXWindowConfig( ...@@ -71,8 +71,10 @@ ui::XWindow::Configuration ConvertInitPropertiesToXWindowConfig(
} // namespace } // namespace
X11Window::X11Window(PlatformWindowDelegateLinux* platform_window_delegate) X11Window::X11Window(PlatformWindowDelegateLinux* platform_window_delegate,
: platform_window_delegate_(platform_window_delegate) {} XEventDelegate* x_event_delegate)
: platform_window_delegate_(platform_window_delegate),
x_event_delegate_(x_event_delegate) {}
X11Window::~X11Window() { X11Window::~X11Window() {
PrepareForShutdown(); PrepareForShutdown();
...@@ -85,11 +87,6 @@ void X11Window::Initialize(PlatformWindowInitProperties properties) { ...@@ -85,11 +87,6 @@ void X11Window::Initialize(PlatformWindowInitProperties properties) {
Init(config); Init(config);
} }
void X11Window::SetXEventDelegate(XEventDelegate* delegate) {
DCHECK(!x_event_delegate_);
x_event_delegate_ = delegate;
}
void X11Window::Show() { void X11Window::Show() {
// TODO(msisov): pass inactivity to PlatformWindow::Show. // TODO(msisov): pass inactivity to PlatformWindow::Show.
XWindow::Map(false /* inactive */); XWindow::Map(false /* inactive */);
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
namespace ui { namespace ui {
class PlatformWindowDelegateLinux;
// Delegate interface used to communicate the X11PlatformWindow API client about // Delegate interface used to communicate the X11PlatformWindow API client about
// XEvents of interest. // XEvents of interest.
class X11_WINDOW_EXPORT XEventDelegate { class X11_WINDOW_EXPORT XEventDelegate {
...@@ -36,13 +38,12 @@ class X11_WINDOW_EXPORT X11Window : public PlatformWindow, ...@@ -36,13 +38,12 @@ class X11_WINDOW_EXPORT X11Window : public PlatformWindow,
public XWindow, public XWindow,
public PlatformEventDispatcher { public PlatformEventDispatcher {
public: public:
explicit X11Window(PlatformWindowDelegateLinux* platform_window_delegate); X11Window(PlatformWindowDelegateLinux* platform_window_delegate,
XEventDelegate* x_event_delegate);
~X11Window() override; ~X11Window() override;
void Initialize(PlatformWindowInitProperties properties); void Initialize(PlatformWindowInitProperties properties);
void SetXEventDelegate(XEventDelegate* delegate);
// PlatformWindow: // PlatformWindow:
void Show() override; void Show() override;
void Hide() override; void Hide() override;
...@@ -109,7 +110,7 @@ class X11_WINDOW_EXPORT X11Window : public PlatformWindow, ...@@ -109,7 +110,7 @@ class X11_WINDOW_EXPORT X11Window : public PlatformWindow,
PlatformWindowDelegateLinux* const platform_window_delegate_; PlatformWindowDelegateLinux* const platform_window_delegate_;
XEventDelegate* x_event_delegate_ = nullptr; XEventDelegate* const x_event_delegate_;
// Tells if the window got a ::Close call. // Tells if the window got a ::Close call.
bool is_shutting_down_ = false; bool is_shutting_down_ = false;
......
...@@ -756,10 +756,8 @@ jumbo_component("views") { ...@@ -756,10 +756,8 @@ jumbo_component("views") {
] ]
} }
if (is_linux) { if (is_linux) {
public += [ "widget/desktop_aura/desktop_window_tree_host_linux.h" ]
sources += [ sources += [
"style/platform_style_linux.cc", "style/platform_style_linux.cc",
"widget/desktop_aura/desktop_window_tree_host_linux.cc",
"widget/desktop_aura/window_event_filter.cc", "widget/desktop_aura/window_event_filter.cc",
"widget/desktop_aura/window_event_filter.h", "widget/desktop_aura/window_event_filter.h",
] ]
......
...@@ -19,13 +19,13 @@ class Window; ...@@ -19,13 +19,13 @@ class Window;
namespace client { namespace client {
class DragDropClient; class DragDropClient;
class ScreenPositionClient; class ScreenPositionClient;
} // namespace client }
} // namespace aura } // namespace aura
namespace gfx { namespace gfx {
class ImageSkia; class ImageSkia;
class Rect; class Rect;
} // namespace gfx }
namespace views { namespace views {
namespace corewm { namespace corewm {
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/platform_window/platform_window_init_properties.h"
#include "ui/views/linux_ui/linux_ui.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/widget.h"
namespace views {
DesktopWindowTreeHostLinux::DesktopWindowTreeHostLinux(
internal::NativeWidgetDelegate* native_widget_delegate,
DesktopNativeWidgetAura* desktop_native_widget_aura)
: DesktopWindowTreeHostPlatform(native_widget_delegate,
desktop_native_widget_aura) {}
DesktopWindowTreeHostLinux::~DesktopWindowTreeHostLinux() = default;
gfx::Size DesktopWindowTreeHostLinux::AdjustSizeForDisplay(
const gfx::Size& requested_size_in_pixels) {
std::vector<display::Display> displays =
display::Screen::GetScreen()->GetAllDisplays();
// Compare against all monitor sizes. The window manager can move the window
// to whichever monitor it wants.
for (const auto& display : displays) {
if (requested_size_in_pixels == display.GetSizeInPixel()) {
return gfx::Size(requested_size_in_pixels.width() - 1,
requested_size_in_pixels.height() - 1);
}
}
// Do not request a 0x0 window size. It causes an XError.
gfx::Size size_in_pixels = requested_size_in_pixels;
size_in_pixels.SetToMax(gfx::Size(1, 1));
return size_in_pixels;
}
void DesktopWindowTreeHostLinux::AddAdditionalInitProperties(
ui::PlatformWindowInitProperties* properties) {
// Calculate initial bounds
gfx::Rect bounds_in_pixels = ToPixelRect(properties->bounds);
gfx::Size adjusted_size = AdjustSizeForDisplay(bounds_in_pixels.size());
bounds_in_pixels.set_size(adjusted_size);
properties->bounds = bounds_in_pixels;
// Set the background color on startup to make the initial flickering
// happening between the XWindow is mapped and the first expose event
// is completely handled less annoying. If possible, we use the content
// window's background color, otherwise we fallback to white.
base::Optional<int> background_color;
const views::LinuxUI* linux_ui = views::LinuxUI::instance();
if (linux_ui && content_window()) {
ui::NativeTheme::ColorId target_color;
switch (properties->type) {
case ui::PlatformWindowType::kBubble:
target_color = ui::NativeTheme::kColorId_BubbleBackground;
break;
case ui::PlatformWindowType::kTooltip:
target_color = ui::NativeTheme::kColorId_TooltipBackground;
break;
default:
target_color = ui::NativeTheme::kColorId_WindowBackground;
break;
}
ui::NativeTheme* theme = linux_ui->GetNativeTheme(content_window());
background_color = theme->GetSystemColor(target_color);
}
properties->prefer_dark_theme = linux_ui && linux_ui->PreferDarkTheme();
properties->background_color = background_color;
properties->icon = ViewsDelegate::GetInstance()->GetDefaultWindowIcon();
}
} // namespace views
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_LINUX_H_
#define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_LINUX_H_
#include "base/macros.h"
#include "ui/views/views_export.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h"
namespace views {
// Contains Linux specific implementation.
class VIEWS_EXPORT DesktopWindowTreeHostLinux
: public DesktopWindowTreeHostPlatform {
public:
DesktopWindowTreeHostLinux(
internal::NativeWidgetDelegate* native_widget_delegate,
DesktopNativeWidgetAura* desktop_native_widget_aura);
~DesktopWindowTreeHostLinux() override;
protected:
// Adjusts |requested_size| to avoid the WM "feature" where setting the
// window size to the monitor size causes the WM to set the EWMH for
// fullscreen.
//
// TODO(https://crbug.com/990756)): this method is mainly for X11
// impl (Wayland does not need this workaround). Move this to X11Window
// instead. We can't do it now as there are some methods that depend on this.
gfx::Size AdjustSizeForDisplay(const gfx::Size& requested_size_in_pixels);
private:
// DesktopWindowTreeHostPlatform overrides:
void AddAdditionalInitProperties(
ui::PlatformWindowInitProperties* properties) override;
DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostLinux);
};
} // namespace views
#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_LINUX_H_
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/drag_drop_client.h" #include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/client/transient_window_client.h" #include "ui/aura/client/transient_window_client.h"
#include "ui/base/hit_test.h" #include "ui/base/hit_test.h"
...@@ -27,71 +26,6 @@ ...@@ -27,71 +26,6 @@
namespace views { namespace views {
namespace {
ui::PlatformWindowInitProperties ConvertWidgetInitParamsToInitProperties(
const Widget::InitParams& params) {
ui::PlatformWindowInitProperties properties;
switch (params.type) {
case Widget::InitParams::TYPE_WINDOW:
properties.type = ui::PlatformWindowType::kWindow;
break;
case Widget::InitParams::TYPE_MENU:
properties.type = ui::PlatformWindowType::kMenu;
break;
case Widget::InitParams::TYPE_TOOLTIP:
properties.type = ui::PlatformWindowType::kTooltip;
break;
case Widget::InitParams::TYPE_DRAG:
properties.type = ui::PlatformWindowType::kDrag;
break;
case Widget::InitParams::TYPE_BUBBLE:
properties.type = ui::PlatformWindowType::kBubble;
break;
default:
properties.type = ui::PlatformWindowType::kPopup;
break;
}
properties.bounds = params.bounds;
properties.activatable =
params.activatable == Widget::InitParams::ACTIVATABLE_YES;
properties.force_show_in_taskbar = params.force_show_in_taskbar;
properties.keep_on_top =
params.EffectiveZOrderLevel() != ui::ZOrderLevel::kNormal;
properties.visible_on_all_workspaces = params.visible_on_all_workspaces;
properties.remove_standard_frame = params.remove_standard_frame;
properties.workspace = params.workspace;
properties.wm_class_name = params.wm_class_name;
properties.wm_class_class = params.wm_class_class;
properties.wm_role_name = params.wm_role_name;
if (params.parent && params.parent->GetHost())
properties.parent_widget = params.parent->GetHost()->GetAcceleratedWidget();
switch (params.opacity) {
case Widget::InitParams::WindowOpacity::INFER_OPACITY:
properties.opacity = ui::PlatformWindowOpacity::kInferOpacity;
break;
case Widget::InitParams::WindowOpacity::OPAQUE_WINDOW:
properties.opacity = ui::PlatformWindowOpacity::kOpaqueWindow;
break;
case Widget::InitParams::WindowOpacity::TRANSLUCENT_WINDOW:
properties.opacity = ui::PlatformWindowOpacity::kTranslucentWindow;
break;
}
return properties;
}
} // namespace
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHostPlatform: // DesktopWindowTreeHostPlatform:
...@@ -112,22 +46,15 @@ DesktopWindowTreeHostPlatform::~DesktopWindowTreeHostPlatform() { ...@@ -112,22 +46,15 @@ DesktopWindowTreeHostPlatform::~DesktopWindowTreeHostPlatform() {
} }
void DesktopWindowTreeHostPlatform::Init(const Widget::InitParams& params) { void DesktopWindowTreeHostPlatform::Init(const Widget::InitParams& params) {
if (params.type == Widget::InitParams::TYPE_WINDOW)
content_window()->SetProperty(aura::client::kAnimationsDisabledKey, true);
ui::PlatformWindowInitProperties properties = ui::PlatformWindowInitProperties properties =
ConvertWidgetInitParamsToInitProperties(params); ConvertWidgetInitParamsToInitProperties(params);
AddAdditionalInitProperties(&properties);
CreateAndSetPlatformWindow(std::move(properties)); CreateAndSetPlatformWindow(std::move(properties));
// Disable compositing on tooltips as a workaround for CreateCompositor(viz::FrameSinkId(), params.force_software_compositing);
// https://crbug.com/442111. aura::WindowTreeHost::OnAcceleratedWidgetAvailable();
CreateCompositor(viz::FrameSinkId(),
params.force_software_compositing ||
params.type == Widget::InitParams::TYPE_TOOLTIP);
WindowTreeHost::OnAcceleratedWidgetAvailable();
InitHost(); InitHost();
if (!params.bounds.IsEmpty())
SetBoundsInDIP(params.bounds);
window()->Show(); window()->Show();
} }
...@@ -159,6 +86,18 @@ void DesktopWindowTreeHostPlatform::OnWidgetInitDone() {} ...@@ -159,6 +86,18 @@ void DesktopWindowTreeHostPlatform::OnWidgetInitDone() {}
void DesktopWindowTreeHostPlatform::OnActiveWindowChanged(bool active) {} void DesktopWindowTreeHostPlatform::OnActiveWindowChanged(bool active) {}
base::Optional<gfx::Size>
DesktopWindowTreeHostPlatform::GetMinimumSizeForWindow() {
return ToPixelRect(gfx::Rect(native_widget_delegate()->GetMinimumSize()))
.size();
}
base::Optional<gfx::Size>
DesktopWindowTreeHostPlatform::GetMaximumSizeForWindow() {
return ToPixelRect(gfx::Rect(native_widget_delegate()->GetMaximumSize()))
.size();
}
std::unique_ptr<corewm::Tooltip> std::unique_ptr<corewm::Tooltip>
DesktopWindowTreeHostPlatform::CreateTooltip() { DesktopWindowTreeHostPlatform::CreateTooltip() {
return std::make_unique<corewm::TooltipAura>(); return std::make_unique<corewm::TooltipAura>();
...@@ -540,19 +479,6 @@ bool DesktopWindowTreeHostPlatform::ShouldCreateVisibilityController() const { ...@@ -540,19 +479,6 @@ bool DesktopWindowTreeHostPlatform::ShouldCreateVisibilityController() const {
return true; return true;
} }
gfx::Transform DesktopWindowTreeHostPlatform::GetRootTransform() const {
display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
if (IsVisible()) {
display = display::Screen::GetScreen()->GetDisplayNearestWindow(
GetWidget()->GetNativeWindow());
}
float scale = display.device_scale_factor();
gfx::Transform transform;
transform.Scale(scale, scale);
return transform;
}
void DesktopWindowTreeHostPlatform::DispatchEvent(ui::Event* event) { void DesktopWindowTreeHostPlatform::DispatchEvent(ui::Event* event) {
#if defined(USE_OZONE) #if defined(USE_OZONE)
// Make sure the |event| is marked as a non-client if it's a non-client // Make sure the |event| is marked as a non-client if it's a non-client
...@@ -611,34 +537,70 @@ void DesktopWindowTreeHostPlatform::OnActivationChanged(bool active) { ...@@ -611,34 +537,70 @@ void DesktopWindowTreeHostPlatform::OnActivationChanged(bool active) {
desktop_native_widget_aura_->HandleActivationChanged(active); desktop_native_widget_aura_->HandleActivationChanged(active);
} }
base::Optional<gfx::Size> ui::PlatformWindowInitProperties
DesktopWindowTreeHostPlatform::GetMinimumSizeForWindow() { DesktopWindowTreeHostPlatform::ConvertWidgetInitParamsToInitProperties(
return ToPixelRect(gfx::Rect(native_widget_delegate()->GetMinimumSize())) const Widget::InitParams& params) {
.size(); ui::PlatformWindowInitProperties properties;
}
base::Optional<gfx::Size> switch (params.type) {
DesktopWindowTreeHostPlatform::GetMaximumSizeForWindow() { case Widget::InitParams::TYPE_WINDOW:
return ToPixelRect(gfx::Rect(native_widget_delegate()->GetMaximumSize())) properties.type = ui::PlatformWindowType::kWindow;
.size(); break;
}
aura::Window* DesktopWindowTreeHostPlatform::content_window() { case Widget::InitParams::TYPE_MENU:
return desktop_native_widget_aura_->content_window(); properties.type = ui::PlatformWindowType::kMenu;
} break;
gfx::Rect DesktopWindowTreeHostPlatform::ToDIPRect( case Widget::InitParams::TYPE_TOOLTIP:
const gfx::Rect& rect_in_pixels) const { properties.type = ui::PlatformWindowType::kTooltip;
gfx::RectF rect_in_dip = gfx::RectF(rect_in_pixels); break;
GetRootTransform().TransformRectReverse(&rect_in_dip);
return gfx::ToEnclosingRect(rect_in_dip); case Widget::InitParams::TYPE_DRAG:
properties.type = ui::PlatformWindowType::kDrag;
break;
case Widget::InitParams::TYPE_BUBBLE:
properties.type = ui::PlatformWindowType::kBubble;
break;
default:
properties.type = ui::PlatformWindowType::kPopup;
break;
}
properties.bounds = params.bounds;
properties.activatable =
params.activatable == Widget::InitParams::ACTIVATABLE_YES;
properties.force_show_in_taskbar = params.force_show_in_taskbar;
properties.keep_on_top =
params.EffectiveZOrderLevel() != ui::ZOrderLevel::kNormal;
properties.visible_on_all_workspaces = params.visible_on_all_workspaces;
properties.remove_standard_frame = params.remove_standard_frame;
properties.workspace = params.workspace;
properties.wm_class_name = params.wm_class_name;
properties.wm_class_class = params.wm_class_class;
properties.wm_role_name = params.wm_role_name;
if (params.parent && params.parent->GetHost())
properties.parent_widget = params.parent->GetHost()->GetAcceleratedWidget();
switch (params.opacity) {
case Widget::InitParams::WindowOpacity::INFER_OPACITY:
properties.opacity = ui::PlatformWindowOpacity::kInferOpacity;
break;
case Widget::InitParams::WindowOpacity::OPAQUE_WINDOW:
properties.opacity = ui::PlatformWindowOpacity::kOpaqueWindow;
break;
case Widget::InitParams::WindowOpacity::TRANSLUCENT_WINDOW:
properties.opacity = ui::PlatformWindowOpacity::kTranslucentWindow;
break;
}
return properties;
} }
gfx::Rect DesktopWindowTreeHostPlatform::ToPixelRect( aura::Window* DesktopWindowTreeHostPlatform::content_window() {
const gfx::Rect& rect_in_dip) const { return desktop_native_widget_aura_->content_window();
gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip);
GetRootTransform().TransformRect(&rect_in_pixels);
return gfx::ToEnclosingRect(rect_in_pixels);
} }
void DesktopWindowTreeHostPlatform::Relayout() { void DesktopWindowTreeHostPlatform::Relayout() {
...@@ -665,12 +627,19 @@ Widget* DesktopWindowTreeHostPlatform::GetWidget() { ...@@ -665,12 +627,19 @@ Widget* DesktopWindowTreeHostPlatform::GetWidget() {
return native_widget_delegate_->AsWidget(); return native_widget_delegate_->AsWidget();
} }
const Widget* DesktopWindowTreeHostPlatform::GetWidget() const { gfx::Rect DesktopWindowTreeHostPlatform::ToDIPRect(
return native_widget_delegate_->AsWidget(); const gfx::Rect& rect_in_pixels) const {
gfx::RectF rect_in_dip = gfx::RectF(rect_in_pixels);
GetRootTransform().TransformRectReverse(&rect_in_dip);
return gfx::ToEnclosingRect(rect_in_dip);
} }
void DesktopWindowTreeHostPlatform::AddAdditionalInitProperties( gfx::Rect DesktopWindowTreeHostPlatform::ToPixelRect(
ui::PlatformWindowInitProperties* properties) {} const gfx::Rect& rect_in_dip) const {
gfx::RectF rect_in_pixels = gfx::RectF(rect_in_dip);
GetRootTransform().TransformRect(&rect_in_pixels);
return gfx::ToEnclosingRect(rect_in_pixels);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHost: // DesktopWindowTreeHost:
......
...@@ -90,9 +90,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform ...@@ -90,9 +90,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform
bool ShouldUseDesktopNativeCursorManager() const override; bool ShouldUseDesktopNativeCursorManager() const override;
bool ShouldCreateVisibilityController() const override; bool ShouldCreateVisibilityController() const override;
// WindowTreeHost:
gfx::Transform GetRootTransform() const override;
// PlatformWindowDelegateBase: // PlatformWindowDelegateBase:
void DispatchEvent(ui::Event* event) override; void DispatchEvent(ui::Event* event) override;
void OnClosed() override; void OnClosed() override;
...@@ -103,8 +100,11 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform ...@@ -103,8 +100,11 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform
base::Optional<gfx::Size> GetMaximumSizeForWindow() override; base::Optional<gfx::Size> GetMaximumSizeForWindow() override;
protected: protected:
// TODO(https://crbug.com/990756): move these methods back to private // TODO(https://crbug.com/990756): move this back to unnamed namespace, when
// once DWTHX11 stops using them. // DWTHX11 stops initialization of the PlatformWindow. Also, remove these
// accessor methods.
ui::PlatformWindowInitProperties ConvertWidgetInitParamsToInitProperties(
const Widget::InitParams& params);
internal::NativeWidgetDelegate* native_widget_delegate() { internal::NativeWidgetDelegate* native_widget_delegate() {
return native_widget_delegate_; return native_widget_delegate_;
} }
...@@ -114,11 +114,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform ...@@ -114,11 +114,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform
// Accessor for DesktopNativeWidgetAura::content_window(). // Accessor for DesktopNativeWidgetAura::content_window().
aura::Window* content_window(); aura::Window* content_window();
// These are not general purpose methods and must be used with care. Please
// make sure you understand the rounding direction before using.
gfx::Rect ToDIPRect(const gfx::Rect& rect_in_pixels) const;
gfx::Rect ToPixelRect(const gfx::Rect& rect_in_dip) const;
private: private:
FRIEND_TEST_ALL_PREFIXES(DesktopWindowTreeHostPlatformTest, HitTest); FRIEND_TEST_ALL_PREFIXES(DesktopWindowTreeHostPlatformTest, HitTest);
...@@ -127,11 +122,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform ...@@ -127,11 +122,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform
void RemoveNonClientEventFilter(); void RemoveNonClientEventFilter();
Widget* GetWidget(); Widget* GetWidget();
const Widget* GetWidget() const;
// There are platform specific properties that Linux may want to add. gfx::Rect ToDIPRect(const gfx::Rect& rect_in_pixels) const;
virtual void AddAdditionalInitProperties( gfx::Rect ToPixelRect(const gfx::Rect& rect_in_dip) const;
ui::PlatformWindowInitProperties* properties);
internal::NativeWidgetDelegate* const native_widget_delegate_; internal::NativeWidgetDelegate* const native_widget_delegate_;
DesktopNativeWidgetAura* const desktop_native_widget_aura_; DesktopNativeWidgetAura* const desktop_native_widget_aura_;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "ui/aura/scoped_window_targeter.h" #include "ui/aura/scoped_window_targeter.h"
#include "ui/aura/window_tree_host.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "ui/gfx/x/x11_types.h" #include "ui/gfx/x/x11_types.h"
...@@ -26,7 +27,7 @@ ...@@ -26,7 +27,7 @@
#include "ui/platform_window/platform_window_handler/wm_move_resize_handler.h" #include "ui/platform_window/platform_window_handler/wm_move_resize_handler.h"
#include "ui/platform_window/x11/x11_window.h" #include "ui/platform_window/x11/x11_window.h"
#include "ui/views/views_export.h" #include "ui/views/views_export.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h"
namespace gfx { namespace gfx {
class ImageSkia; class ImageSkia;
...@@ -48,9 +49,10 @@ class NonClientFrameView; ...@@ -48,9 +49,10 @@ class NonClientFrameView;
class X11DesktopWindowMoveClient; class X11DesktopWindowMoveClient;
class WindowEventFilter; class WindowEventFilter;
class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux, class VIEWS_EXPORT DesktopWindowTreeHostX11
public ui::WmMoveResizeHandler, : public DesktopWindowTreeHostPlatform,
public ui::XEventDelegate { public ui::WmMoveResizeHandler,
public ui::XEventDelegate {
public: public:
DesktopWindowTreeHostX11( DesktopWindowTreeHostX11(
internal::NativeWidgetDelegate* native_widget_delegate, internal::NativeWidgetDelegate* native_widget_delegate,
...@@ -168,7 +170,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux, ...@@ -168,7 +170,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
bool ShouldCreateVisibilityController() const override; bool ShouldCreateVisibilityController() const override;
// Overridden from aura::WindowTreeHost: // Overridden from aura::WindowTreeHost:
gfx::Transform GetRootTransform() const override;
ui::EventSource* GetEventSource() override; ui::EventSource* GetEventSource() override;
gfx::AcceleratedWidget GetAcceleratedWidget() override;
void ShowImpl() override; void ShowImpl() override;
void HideImpl() override; void HideImpl() override;
gfx::Rect GetBoundsInPixels() const override; gfx::Rect GetBoundsInPixels() const override;
...@@ -205,6 +209,11 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux, ...@@ -205,6 +209,11 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
// along with all aura client objects that direct behavior. // along with all aura client objects that direct behavior.
aura::WindowEventDispatcher* InitDispatcher(const Widget::InitParams& params); aura::WindowEventDispatcher* InitDispatcher(const Widget::InitParams& params);
// Adjusts |requested_size| to avoid the WM "feature" where setting the
// window size to the monitor size causes the WM to set the EWMH for
// fullscreen.
gfx::Size AdjustSize(const gfx::Size& requested_size);
// Sets whether the window's borders are provided by the window manager. // Sets whether the window's borders are provided by the window manager.
void SetUseNativeFrame(bool use_native_frame); void SetUseNativeFrame(bool use_native_frame);
...@@ -237,6 +246,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux, ...@@ -237,6 +246,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
void DelayedChangeFrameType(Widget::FrameType new_type); void DelayedChangeFrameType(Widget::FrameType new_type);
gfx::Rect ToDIPRect(const gfx::Rect& rect_in_pixels) const;
gfx::Rect ToPixelRect(const gfx::Rect& rect_in_dip) const;
// Enables event listening after closing |dialog|. // Enables event listening after closing |dialog|.
void EnableEventListening(); void EnableEventListening();
...@@ -268,13 +280,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux, ...@@ -268,13 +280,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
void OnXWindowDragDropEvent(XEvent* xev) override; void OnXWindowDragDropEvent(XEvent* xev) override;
void OnXWindowRawKeyEvent(XEvent* xev) override; void OnXWindowRawKeyEvent(XEvent* xev) override;
// Casts PlatformWindow into XWindow and returns the result. This is a temp
// solution to access XWindow, which is subclassed by the X11Window, which is
// PlatformWindow. This will be removed once we no longer to access XWindow
// directly. See https://crbug.com/990756.
ui::XWindow* GetXWindow();
const ui::XWindow* GetXWindow() const;
// The bounds of our window before we were maximized. // The bounds of our window before we were maximized.
gfx::Rect restored_bounds_in_pixels_; gfx::Rect restored_bounds_in_pixels_;
...@@ -304,7 +309,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux, ...@@ -304,7 +309,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
// A list of all (top-level) windows that have been created but not yet // A list of all (top-level) windows that have been created but not yet
// destroyed. // destroyed.
static std::list<gfx::AcceleratedWidget>* open_windows_; static std::list<XID>* open_windows_;
// Cached value for SetVisible. Not the same as the IsVisible public API. // Cached value for SetVisible. Not the same as the IsVisible public API.
bool is_compositor_set_visible_ = false; bool is_compositor_set_visible_ = false;
...@@ -318,6 +323,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux, ...@@ -318,6 +323,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
std::unique_ptr<CompositorObserver> compositor_observer_; std::unique_ptr<CompositorObserver> compositor_observer_;
std::unique_ptr<ui::X11Window> x11_window_;
// The display and the native X window hosting the root window. // The display and the native X window hosting the root window.
base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_{this}; base::WeakPtrFactory<DesktopWindowTreeHostX11> close_widget_factory_{this};
base::WeakPtrFactory<DesktopWindowTreeHostX11> weak_factory_{this}; base::WeakPtrFactory<DesktopWindowTreeHostX11> weak_factory_{this};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment