Commit 3fac40ef authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

DesktopWindowTreeHostPlatform: minor changes

Fixes Init() and ShowWindowWithState() to do the right thing. This
better matches with what the other implementations do.

BUG=none
TEST=none

Change-Id: I67d3bbfe0844286631a5612d5740463ec9498480
Reviewed-on: https://chromium-review.googlesource.com/994454
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548477}
parent 83d4fd3a
...@@ -44,18 +44,7 @@ WindowTreeHostPlatform::WindowTreeHostPlatform(const gfx::Rect& bounds) ...@@ -44,18 +44,7 @@ WindowTreeHostPlatform::WindowTreeHostPlatform(const gfx::Rect& bounds)
: WindowTreeHostPlatform() { : WindowTreeHostPlatform() {
bounds_ = bounds; bounds_ = bounds;
CreateCompositor(); CreateCompositor();
#if defined(USE_OZONE) CreateAndSetDefaultPlatformWindow();
platform_window_ =
ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds);
#elif defined(OS_WIN)
platform_window_.reset(new ui::WinWindow(this, bounds));
#elif defined(OS_ANDROID)
platform_window_.reset(new ui::PlatformWindowAndroid(this));
#elif defined(USE_X11)
platform_window_.reset(new ui::X11Window(this, bounds));
#else
NOTIMPLEMENTED();
#endif
} }
WindowTreeHostPlatform::WindowTreeHostPlatform() WindowTreeHostPlatform::WindowTreeHostPlatform()
...@@ -67,6 +56,21 @@ WindowTreeHostPlatform::WindowTreeHostPlatform( ...@@ -67,6 +56,21 @@ WindowTreeHostPlatform::WindowTreeHostPlatform(
widget_(gfx::kNullAcceleratedWidget), widget_(gfx::kNullAcceleratedWidget),
current_cursor_(ui::CursorType::kNull) {} current_cursor_(ui::CursorType::kNull) {}
void WindowTreeHostPlatform::CreateAndSetDefaultPlatformWindow() {
#if defined(USE_OZONE)
platform_window_ =
ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds_);
#elif defined(OS_WIN)
platform_window_.reset(new ui::WinWindow(this, bounds_));
#elif defined(OS_ANDROID)
platform_window_.reset(new ui::PlatformWindowAndroid(this));
#elif defined(USE_X11)
platform_window_.reset(new ui::X11Window(this, bounds_));
#else
NOTIMPLEMENTED();
#endif
}
void WindowTreeHostPlatform::SetPlatformWindow( void WindowTreeHostPlatform::SetPlatformWindow(
std::unique_ptr<ui::PlatformWindow> window) { std::unique_ptr<ui::PlatformWindow> window) {
platform_window_ = std::move(window); platform_window_ = std::move(window);
...@@ -149,12 +153,10 @@ void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) { ...@@ -149,12 +153,10 @@ void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) {
float new_scale = ui::GetScaleFactorForNativeView(window()); float new_scale = ui::GetScaleFactorForNativeView(window());
gfx::Rect old_bounds = bounds_; gfx::Rect old_bounds = bounds_;
bounds_ = new_bounds; bounds_ = new_bounds;
if (bounds_.origin() != old_bounds.origin()) { if (bounds_.origin() != old_bounds.origin())
OnHostMovedInPixels(bounds_.origin()); OnHostMovedInPixels(bounds_.origin());
} if (bounds_.size() != old_bounds.size() || current_scale != new_scale)
if (bounds_.size() != old_bounds.size() || current_scale != new_scale) {
OnHostResizedInPixels(bounds_.size()); OnHostResizedInPixels(bounds_.size());
}
} }
void WindowTreeHostPlatform::OnDamageRect(const gfx::Rect& damage_rect) { void WindowTreeHostPlatform::OnDamageRect(const gfx::Rect& damage_rect) {
...@@ -190,6 +192,8 @@ void WindowTreeHostPlatform::OnAcceleratedWidgetAvailable( ...@@ -190,6 +192,8 @@ void WindowTreeHostPlatform::OnAcceleratedWidgetAvailable(
gfx::AcceleratedWidget widget, gfx::AcceleratedWidget widget,
float device_pixel_ratio) { float device_pixel_ratio) {
widget_ = widget; widget_ = widget;
// This may be called before the Compositor has been created.
if (compositor())
WindowTreeHost::OnAcceleratedWidgetAvailable(); WindowTreeHost::OnAcceleratedWidgetAvailable();
} }
......
...@@ -48,6 +48,10 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost, ...@@ -48,6 +48,10 @@ class AURA_EXPORT WindowTreeHostPlatform : public WindowTreeHost,
WindowTreeHostPlatform(); WindowTreeHostPlatform();
explicit WindowTreeHostPlatform(std::unique_ptr<WindowPort> window_port); explicit WindowTreeHostPlatform(std::unique_ptr<WindowPort> window_port);
// Creates a ui::PlatformWindow appropriate for the current platform and
// installs it at as the PlatformWindow for this WindowTreeHostPlatform.
void CreateAndSetDefaultPlatformWindow();
void SetPlatformWindow(std::unique_ptr<ui::PlatformWindow> window); void SetPlatformWindow(std::unique_ptr<ui::PlatformWindow> window);
ui::PlatformWindow* platform_window() { return platform_window_.get(); } ui::PlatformWindow* platform_window() { return platform_window_.get(); }
......
...@@ -31,14 +31,22 @@ DesktopWindowTreeHostPlatform::~DesktopWindowTreeHostPlatform() { ...@@ -31,14 +31,22 @@ DesktopWindowTreeHostPlatform::~DesktopWindowTreeHostPlatform() {
void DesktopWindowTreeHostPlatform::SetBoundsInDIP( void DesktopWindowTreeHostPlatform::SetBoundsInDIP(
const gfx::Rect& bounds_in_dip) { const gfx::Rect& bounds_in_dip) {
DCHECK_NE(0, device_scale_factor());
SetBoundsInPixels( SetBoundsInPixels(
gfx::ConvertRectToPixel(device_scale_factor(), bounds_in_dip)); gfx::ConvertRectToPixel(device_scale_factor(), bounds_in_dip));
} }
void DesktopWindowTreeHostPlatform::Init(const Widget::InitParams& params) { void DesktopWindowTreeHostPlatform::Init(const Widget::InitParams& params) {
CreateAndSetDefaultPlatformWindow();
// TODO(sky): this should be |params.force_software_compositing|, figure out
// why it has to be true now.
const bool use_software_compositing = true;
CreateCompositor(viz::FrameSinkId(), use_software_compositing);
aura::WindowTreeHost::OnAcceleratedWidgetAvailable();
InitHost();
if (!params.bounds.IsEmpty()) if (!params.bounds.IsEmpty())
SetBoundsInDIP(params.bounds); SetBoundsInDIP(params.bounds);
InitHost(); window()->Show();
} }
void DesktopWindowTreeHostPlatform::OnNativeWidgetCreated( void DesktopWindowTreeHostPlatform::OnNativeWidgetCreated(
...@@ -59,7 +67,7 @@ std::unique_ptr<aura::client::DragDropClient> ...@@ -59,7 +67,7 @@ std::unique_ptr<aura::client::DragDropClient>
DesktopWindowTreeHostPlatform::CreateDragDropClient( DesktopWindowTreeHostPlatform::CreateDragDropClient(
DesktopNativeCursorManager* cursor_manager) { DesktopNativeCursorManager* cursor_manager) {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return nullptr; return nullptr;
} }
...@@ -94,8 +102,10 @@ aura::WindowTreeHost* DesktopWindowTreeHostPlatform::AsWindowTreeHost() { ...@@ -94,8 +102,10 @@ aura::WindowTreeHost* DesktopWindowTreeHostPlatform::AsWindowTreeHost() {
void DesktopWindowTreeHostPlatform::ShowWindowWithState( void DesktopWindowTreeHostPlatform::ShowWindowWithState(
ui::WindowShowState show_state) { ui::WindowShowState show_state) {
if (compositor()) if (compositor()) {
platform_window()->Show(); platform_window()->Show();
compositor()->SetVisible(true);
}
switch (show_state) { switch (show_state) {
case ui::SHOW_STATE_MAXIMIZED: case ui::SHOW_STATE_MAXIMIZED:
...@@ -137,7 +147,7 @@ void DesktopWindowTreeHostPlatform::ShowMaximizedWithBounds( ...@@ -137,7 +147,7 @@ void DesktopWindowTreeHostPlatform::ShowMaximizedWithBounds(
bool DesktopWindowTreeHostPlatform::IsVisible() const { bool DesktopWindowTreeHostPlatform::IsVisible() const {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return true; return true;
} }
...@@ -149,11 +159,11 @@ void DesktopWindowTreeHostPlatform::SetSize(const gfx::Size& size) { ...@@ -149,11 +159,11 @@ void DesktopWindowTreeHostPlatform::SetSize(const gfx::Size& size) {
} }
void DesktopWindowTreeHostPlatform::StackAbove(aura::Window* window) { void DesktopWindowTreeHostPlatform::StackAbove(aura::Window* window) {
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
void DesktopWindowTreeHostPlatform::StackAtTop() { void DesktopWindowTreeHostPlatform::StackAtTop() {
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
void DesktopWindowTreeHostPlatform::CenterWindow(const gfx::Size& size) { void DesktopWindowTreeHostPlatform::CenterWindow(const gfx::Size& size) {
...@@ -178,7 +188,7 @@ void DesktopWindowTreeHostPlatform::CenterWindow(const gfx::Size& size) { ...@@ -178,7 +188,7 @@ void DesktopWindowTreeHostPlatform::CenterWindow(const gfx::Size& size) {
void DesktopWindowTreeHostPlatform::GetWindowPlacement( void DesktopWindowTreeHostPlatform::GetWindowPlacement(
gfx::Rect* bounds, gfx::Rect* bounds,
ui::WindowShowState* show_state) const { ui::WindowShowState* show_state) const {
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
*bounds = gfx::Rect(0, 0, 640, 840); *bounds = gfx::Rect(0, 0, 640, 840);
*show_state = ui::SHOW_STATE_NORMAL; *show_state = ui::SHOW_STATE_NORMAL;
} }
...@@ -200,7 +210,7 @@ gfx::Rect DesktopWindowTreeHostPlatform::GetClientAreaBoundsInScreen() const { ...@@ -200,7 +210,7 @@ gfx::Rect DesktopWindowTreeHostPlatform::GetClientAreaBoundsInScreen() const {
} }
gfx::Rect DesktopWindowTreeHostPlatform::GetRestoredBounds() const { gfx::Rect DesktopWindowTreeHostPlatform::GetRestoredBounds() const {
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return gfx::Rect(0, 0, 640, 840); return gfx::Rect(0, 0, 640, 840);
} }
...@@ -217,22 +227,22 @@ gfx::Rect DesktopWindowTreeHostPlatform::GetWorkAreaBoundsInScreen() const { ...@@ -217,22 +227,22 @@ gfx::Rect DesktopWindowTreeHostPlatform::GetWorkAreaBoundsInScreen() const {
void DesktopWindowTreeHostPlatform::SetShape( void DesktopWindowTreeHostPlatform::SetShape(
std::unique_ptr<Widget::ShapeRects> native_shape) { std::unique_ptr<Widget::ShapeRects> native_shape) {
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
void DesktopWindowTreeHostPlatform::Activate() { void DesktopWindowTreeHostPlatform::Activate() {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
void DesktopWindowTreeHostPlatform::Deactivate() { void DesktopWindowTreeHostPlatform::Deactivate() {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
bool DesktopWindowTreeHostPlatform::IsActive() const { bool DesktopWindowTreeHostPlatform::IsActive() const {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return false; return false;
} }
...@@ -250,25 +260,25 @@ void DesktopWindowTreeHostPlatform::Restore() { ...@@ -250,25 +260,25 @@ void DesktopWindowTreeHostPlatform::Restore() {
bool DesktopWindowTreeHostPlatform::IsMaximized() const { bool DesktopWindowTreeHostPlatform::IsMaximized() const {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return false; return false;
} }
bool DesktopWindowTreeHostPlatform::IsMinimized() const { bool DesktopWindowTreeHostPlatform::IsMinimized() const {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return false; return false;
} }
bool DesktopWindowTreeHostPlatform::HasCapture() const { bool DesktopWindowTreeHostPlatform::HasCapture() const {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return false; return false;
} }
void DesktopWindowTreeHostPlatform::SetAlwaysOnTop(bool always_on_top) { void DesktopWindowTreeHostPlatform::SetAlwaysOnTop(bool always_on_top) {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
bool DesktopWindowTreeHostPlatform::IsAlwaysOnTop() const { bool DesktopWindowTreeHostPlatform::IsAlwaysOnTop() const {
...@@ -279,7 +289,7 @@ bool DesktopWindowTreeHostPlatform::IsAlwaysOnTop() const { ...@@ -279,7 +289,7 @@ bool DesktopWindowTreeHostPlatform::IsAlwaysOnTop() const {
void DesktopWindowTreeHostPlatform::SetVisibleOnAllWorkspaces( void DesktopWindowTreeHostPlatform::SetVisibleOnAllWorkspaces(
bool always_visible) { bool always_visible) {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
bool DesktopWindowTreeHostPlatform::IsVisibleOnAllWorkspaces() const { bool DesktopWindowTreeHostPlatform::IsVisibleOnAllWorkspaces() const {
...@@ -290,13 +300,13 @@ bool DesktopWindowTreeHostPlatform::IsVisibleOnAllWorkspaces() const { ...@@ -290,13 +300,13 @@ bool DesktopWindowTreeHostPlatform::IsVisibleOnAllWorkspaces() const {
bool DesktopWindowTreeHostPlatform::SetWindowTitle( bool DesktopWindowTreeHostPlatform::SetWindowTitle(
const base::string16& title) { const base::string16& title) {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return false; return false;
} }
void DesktopWindowTreeHostPlatform::ClearNativeFocus() { void DesktopWindowTreeHostPlatform::ClearNativeFocus() {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
Widget::MoveLoopResult DesktopWindowTreeHostPlatform::RunMoveLoop( Widget::MoveLoopResult DesktopWindowTreeHostPlatform::RunMoveLoop(
...@@ -304,19 +314,19 @@ Widget::MoveLoopResult DesktopWindowTreeHostPlatform::RunMoveLoop( ...@@ -304,19 +314,19 @@ Widget::MoveLoopResult DesktopWindowTreeHostPlatform::RunMoveLoop(
Widget::MoveLoopSource source, Widget::MoveLoopSource source,
Widget::MoveLoopEscapeBehavior escape_behavior) { Widget::MoveLoopEscapeBehavior escape_behavior) {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return Widget::MOVE_LOOP_CANCELED; return Widget::MOVE_LOOP_CANCELED;
} }
void DesktopWindowTreeHostPlatform::EndMoveLoop() { void DesktopWindowTreeHostPlatform::EndMoveLoop() {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
void DesktopWindowTreeHostPlatform::SetVisibilityChangedAnimationsEnabled( void DesktopWindowTreeHostPlatform::SetVisibilityChangedAnimationsEnabled(
bool value) { bool value) {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
NonClientFrameView* DesktopWindowTreeHostPlatform::CreateNonClientFrameView() { NonClientFrameView* DesktopWindowTreeHostPlatform::CreateNonClientFrameView() {
...@@ -335,54 +345,54 @@ void DesktopWindowTreeHostPlatform::FrameTypeChanged() {} ...@@ -335,54 +345,54 @@ void DesktopWindowTreeHostPlatform::FrameTypeChanged() {}
void DesktopWindowTreeHostPlatform::SetFullscreen(bool fullscreen) { void DesktopWindowTreeHostPlatform::SetFullscreen(bool fullscreen) {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
bool DesktopWindowTreeHostPlatform::IsFullscreen() const { bool DesktopWindowTreeHostPlatform::IsFullscreen() const {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return false; return false;
} }
void DesktopWindowTreeHostPlatform::SetOpacity(float opacity) { void DesktopWindowTreeHostPlatform::SetOpacity(float opacity) {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
void DesktopWindowTreeHostPlatform::SetWindowIcons( void DesktopWindowTreeHostPlatform::SetWindowIcons(
const gfx::ImageSkia& window_icon, const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) { const gfx::ImageSkia& app_icon) {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
void DesktopWindowTreeHostPlatform::InitModalType(ui::ModalType modal_type) { void DesktopWindowTreeHostPlatform::InitModalType(ui::ModalType modal_type) {
// TODO: needs PlatformWindow support (alternatively, remove as // TODO: needs PlatformWindow support (alternatively, remove as
// DesktopWindowTreeHostX11 doesn't support at all). // DesktopWindowTreeHostX11 doesn't support at all).
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
void DesktopWindowTreeHostPlatform::FlashFrame(bool flash_frame) { void DesktopWindowTreeHostPlatform::FlashFrame(bool flash_frame) {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
bool DesktopWindowTreeHostPlatform::IsAnimatingClosed() const { bool DesktopWindowTreeHostPlatform::IsAnimatingClosed() const {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return false; return false;
} }
bool DesktopWindowTreeHostPlatform::IsTranslucentWindowOpacitySupported() bool DesktopWindowTreeHostPlatform::IsTranslucentWindowOpacitySupported()
const { const {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
return false; return false;
} }
void DesktopWindowTreeHostPlatform::SizeConstraintsChanged() { void DesktopWindowTreeHostPlatform::SizeConstraintsChanged() {
// TODO: needs PlatformWindow support. // TODO: needs PlatformWindow support.
NOTIMPLEMENTED(); NOTIMPLEMENTED_LOG_ONCE();
} }
bool DesktopWindowTreeHostPlatform::ShouldUpdateWindowTransparency() const { bool DesktopWindowTreeHostPlatform::ShouldUpdateWindowTransparency() const {
...@@ -415,4 +425,5 @@ void DesktopWindowTreeHostPlatform::OnActivationChanged(bool active) { ...@@ -415,4 +425,5 @@ void DesktopWindowTreeHostPlatform::OnActivationChanged(bool active) {
Widget* DesktopWindowTreeHostPlatform::GetWidget() { Widget* DesktopWindowTreeHostPlatform::GetWidget() {
return native_widget_delegate_->AsWidget(); return native_widget_delegate_->AsWidget();
} }
} // namespace views } // namespace views
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