| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura/window_tree_host_platform.h" | 5 #include "ui/aura/window_tree_host_platform.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // static | 35 // static |
| 36 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) { | 36 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) { |
| 37 return new WindowTreeHostPlatform(bounds); | 37 return new WindowTreeHostPlatform(bounds); |
| 38 } | 38 } |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 WindowTreeHostPlatform::WindowTreeHostPlatform(const gfx::Rect& bounds) | 41 WindowTreeHostPlatform::WindowTreeHostPlatform(const gfx::Rect& bounds) |
| 42 : WindowTreeHostPlatform() { | 42 : WindowTreeHostPlatform() { |
| 43 CreateCompositor(); | 43 CreateCompositor(); |
| 44 #if defined(USE_OZONE) | 44 #if defined(USE_OZONE) |
| 45 window_ = | 45 platform_window_ = |
| 46 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); | 46 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); |
| 47 #elif defined(OS_WIN) | 47 #elif defined(OS_WIN) |
| 48 window_.reset(new ui::WinWindow(this, bounds)); | 48 platform_window_.reset(new ui::WinWindow(this, bounds)); |
| 49 #elif defined(OS_ANDROID) | 49 #elif defined(OS_ANDROID) |
| 50 window_.reset(new ui::PlatformWindowAndroid(this)); | 50 platform_window_.reset(new ui::PlatformWindowAndroid(this)); |
| 51 #else | 51 #else |
| 52 NOTIMPLEMENTED(); | 52 NOTIMPLEMENTED(); |
| 53 #endif | 53 #endif |
| 54 } | 54 } |
| 55 | 55 |
| 56 WindowTreeHostPlatform::WindowTreeHostPlatform() | 56 WindowTreeHostPlatform::WindowTreeHostPlatform() |
| 57 : WindowTreeHostPlatform(nullptr) {} | 57 : WindowTreeHostPlatform(nullptr) {} |
| 58 | 58 |
| 59 WindowTreeHostPlatform::WindowTreeHostPlatform( | 59 WindowTreeHostPlatform::WindowTreeHostPlatform( |
| 60 std::unique_ptr<WindowPort> window_port) | 60 std::unique_ptr<WindowPort> window_port) |
| 61 : WindowTreeHost(std::move(window_port)), | 61 : WindowTreeHost(std::move(window_port)), |
| 62 widget_(gfx::kNullAcceleratedWidget), | 62 widget_(gfx::kNullAcceleratedWidget), |
| 63 current_cursor_(ui::kCursorNull) { | 63 current_cursor_(ui::kCursorNull) { |
| 64 } | 64 } |
| 65 | 65 |
| 66 void WindowTreeHostPlatform::SetPlatformWindow( | 66 void WindowTreeHostPlatform::SetPlatformWindow( |
| 67 std::unique_ptr<ui::PlatformWindow> window) { | 67 std::unique_ptr<ui::PlatformWindow> window) { |
| 68 window_ = std::move(window); | 68 platform_window_ = std::move(window); |
| 69 } | 69 } |
| 70 | 70 |
| 71 WindowTreeHostPlatform::~WindowTreeHostPlatform() { | 71 WindowTreeHostPlatform::~WindowTreeHostPlatform() { |
| 72 DestroyCompositor(); | 72 DestroyCompositor(); |
| 73 DestroyDispatcher(); | 73 DestroyDispatcher(); |
| 74 window_->Close(); | 74 platform_window_->Close(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 ui::EventSource* WindowTreeHostPlatform::GetEventSource() { | 77 ui::EventSource* WindowTreeHostPlatform::GetEventSource() { |
| 78 return this; | 78 return this; |
| 79 } | 79 } |
| 80 | 80 |
| 81 gfx::AcceleratedWidget WindowTreeHostPlatform::GetAcceleratedWidget() { | 81 gfx::AcceleratedWidget WindowTreeHostPlatform::GetAcceleratedWidget() { |
| 82 return widget_; | 82 return widget_; |
| 83 } | 83 } |
| 84 | 84 |
| 85 void WindowTreeHostPlatform::ShowImpl() { | 85 void WindowTreeHostPlatform::ShowImpl() { |
| 86 window_->Show(); | 86 platform_window_->Show(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void WindowTreeHostPlatform::HideImpl() { | 89 void WindowTreeHostPlatform::HideImpl() { |
| 90 window_->Hide(); | 90 platform_window_->Hide(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 gfx::Rect WindowTreeHostPlatform::GetBoundsInPixels() const { | 93 gfx::Rect WindowTreeHostPlatform::GetBoundsInPixels() const { |
| 94 return window_ ? window_->GetBounds() : gfx::Rect(); | 94 return platform_window_ ? platform_window_->GetBounds() : gfx::Rect(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void WindowTreeHostPlatform::SetBoundsInPixels(const gfx::Rect& bounds) { | 97 void WindowTreeHostPlatform::SetBoundsInPixels(const gfx::Rect& bounds) { |
| 98 window_->SetBounds(bounds); | 98 platform_window_->SetBounds(bounds); |
| 99 } | 99 } |
| 100 | 100 |
| 101 gfx::Point WindowTreeHostPlatform::GetLocationOnScreenInPixels() const { | 101 gfx::Point WindowTreeHostPlatform::GetLocationOnScreenInPixels() const { |
| 102 return window_->GetBounds().origin(); | 102 return platform_window_->GetBounds().origin(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void WindowTreeHostPlatform::SetCapture() { | 105 void WindowTreeHostPlatform::SetCapture() { |
| 106 window_->SetCapture(); | 106 platform_window_->SetCapture(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void WindowTreeHostPlatform::ReleaseCapture() { | 109 void WindowTreeHostPlatform::ReleaseCapture() { |
| 110 window_->ReleaseCapture(); | 110 platform_window_->ReleaseCapture(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void WindowTreeHostPlatform::SetCursorNative(gfx::NativeCursor cursor) { | 113 void WindowTreeHostPlatform::SetCursorNative(gfx::NativeCursor cursor) { |
| 114 if (cursor == current_cursor_) | 114 if (cursor == current_cursor_) |
| 115 return; | 115 return; |
| 116 current_cursor_ = cursor; | 116 current_cursor_ = cursor; |
| 117 | 117 |
| 118 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
| 119 ui::CursorLoaderWin cursor_loader; | 119 ui::CursorLoaderWin cursor_loader; |
| 120 cursor_loader.SetPlatformCursor(&cursor); | 120 cursor_loader.SetPlatformCursor(&cursor); |
| 121 #endif | 121 #endif |
| 122 | 122 |
| 123 window_->SetCursor(cursor.platform()); | 123 platform_window_->SetCursor(cursor.platform()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void WindowTreeHostPlatform::MoveCursorToScreenLocationInPixels( | 126 void WindowTreeHostPlatform::MoveCursorToScreenLocationInPixels( |
| 127 const gfx::Point& location_in_pixels) { | 127 const gfx::Point& location_in_pixels) { |
| 128 window_->MoveCursorTo(location_in_pixels); | 128 platform_window_->MoveCursorTo(location_in_pixels); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void WindowTreeHostPlatform::OnCursorVisibilityChangedNative(bool show) { | 131 void WindowTreeHostPlatform::OnCursorVisibilityChangedNative(bool show) { |
| 132 NOTIMPLEMENTED(); | 132 NOTIMPLEMENTED(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) { | 135 void WindowTreeHostPlatform::OnBoundsChanged(const gfx::Rect& new_bounds) { |
| 136 float current_scale = compositor()->device_scale_factor(); | 136 float current_scale = compositor()->device_scale_factor(); |
| 137 float new_scale = display::Screen::GetScreen() | 137 float new_scale = display::Screen::GetScreen() |
| 138 ->GetDisplayNearestWindow(window()) | 138 ->GetDisplayNearestWindow(window()) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 DCHECK_EQ(widget, widget_); | 188 DCHECK_EQ(widget, widget_); |
| 189 widget_ = gfx::kNullAcceleratedWidget; | 189 widget_ = gfx::kNullAcceleratedWidget; |
| 190 } | 190 } |
| 191 | 191 |
| 192 void WindowTreeHostPlatform::OnActivationChanged(bool active) { | 192 void WindowTreeHostPlatform::OnActivationChanged(bool active) { |
| 193 if (active) | 193 if (active) |
| 194 OnHostActivated(); | 194 OnHostActivated(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace aura | 197 } // namespace aura |
| OLD | NEW |