| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/widget/desktop_aura/desktop_root_window_host_ozone.h" |
| 6 |
| 7 #include "ui/aura/client/drag_drop_client.h" |
| 5 #include "ui/aura/window_tree_host.h" | 8 #include "ui/aura/window_tree_host.h" |
| 9 #include "ui/native_theme/native_theme.h" |
| 10 #include "ui/views/corewm/tooltip_aura.h" |
| 11 #include "ui/views/linux_ui/linux_ui.h" |
| 6 #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" | 12 #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" |
| 7 #include "ui/views/widget/desktop_aura/desktop_factory_ozone.h" | 13 #include "ui/views/widget/desktop_aura/desktop_factory_ozone.h" |
| 8 | 14 |
| 9 namespace views { | 15 namespace views { |
| 10 | 16 |
| 17 //////////////////////////////////////////////////////////////////////////////// |
| 18 // DesktopRootWindowHostOzone, public: |
| 19 DesktopRootWindowHostOzone::DesktopRootWindowHostOzone( |
| 20 internal::NativeWidgetDelegate* native_widget_delegate, |
| 21 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
| 22 DesktopFactoryOzone* d_factory = DesktopFactoryOzone::GetInstance(); |
| 23 |
| 24 drwh_ozone_ = d_factory->CreateRootWindowHost( |
| 25 native_widget_delegate, |
| 26 desktop_native_widget_aura); |
| 27 } |
| 28 |
| 29 DesktopRootWindowHostOzone::~DesktopRootWindowHostOzone() { |
| 30 } |
| 31 |
| 32 //////////////////////////////////////////////////////////////////////////////// |
| 33 // DesktopRootWindowHostOzone, DesktopRootWindowHost implementation: |
| 34 |
| 35 void DesktopRootWindowHostOzone::Init( |
| 36 aura::Window* content_window, |
| 37 const Widget::InitParams& params, |
| 38 aura::RootWindow::CreateParams* rw_create_params) { |
| 39 drwh_ozone_->Init(content_window, params, rw_create_params); |
| 40 } |
| 41 |
| 42 void DesktopRootWindowHostOzone::OnRootWindowCreated( |
| 43 aura::RootWindow* root, |
| 44 const Widget::InitParams& params) { |
| 45 drwh_ozone_->OnRootWindowCreated(root, params); |
| 46 } |
| 47 |
| 48 scoped_ptr<corewm::Tooltip> DesktopRootWindowHostOzone::CreateTooltip() { |
| 49 return drwh_ozone_->CreateTooltip(); |
| 50 } |
| 51 |
| 52 scoped_ptr<aura::client::DragDropClient> |
| 53 DesktopRootWindowHostOzone::CreateDragDropClient( |
| 54 DesktopNativeCursorManager* cursor_manager) { |
| 55 return drwh_ozone_->CreateDragDropClient(cursor_manager); |
| 56 } |
| 57 |
| 58 void DesktopRootWindowHostOzone::Close() { |
| 59 drwh_ozone_->Close(); |
| 60 } |
| 61 |
| 62 void DesktopRootWindowHostOzone::CloseNow() { |
| 63 drwh_ozone_->CloseNow(); |
| 64 } |
| 65 |
| 66 aura::RootWindowHost* DesktopRootWindowHostOzone::AsRootWindowHost() { |
| 67 return drwh_ozone_->AsRootWindowHost(); |
| 68 } |
| 69 |
| 70 void DesktopRootWindowHostOzone::ShowWindowWithState( |
| 71 ui::WindowShowState show_state) { |
| 72 drwh_ozone_->ShowWindowWithState(show_state); |
| 73 } |
| 74 |
| 75 void DesktopRootWindowHostOzone::ShowMaximizedWithBounds( |
| 76 const gfx::Rect& restored_bounds) { |
| 77 drwh_ozone_->ShowMaximizedWithBounds(restored_bounds); |
| 78 } |
| 79 |
| 80 bool DesktopRootWindowHostOzone::IsVisible() const { |
| 81 return drwh_ozone_->IsVisible(); |
| 82 } |
| 83 |
| 84 void DesktopRootWindowHostOzone::SetSize(const gfx::Size& size) { |
| 85 drwh_ozone_->SetSize(size); |
| 86 } |
| 87 |
| 88 void DesktopRootWindowHostOzone::CenterWindow(const gfx::Size& size) { |
| 89 drwh_ozone_->CenterWindow(size); |
| 90 } |
| 91 |
| 92 void DesktopRootWindowHostOzone::GetWindowPlacement( |
| 93 gfx::Rect* bounds, |
| 94 ui::WindowShowState* show_state) const { |
| 95 drwh_ozone_->GetWindowPlacement(bounds, show_state); |
| 96 } |
| 97 |
| 98 gfx::Rect DesktopRootWindowHostOzone::GetWindowBoundsInScreen() const { |
| 99 return drwh_ozone_->GetWindowBoundsInScreen(); |
| 100 } |
| 101 |
| 102 gfx::Rect DesktopRootWindowHostOzone::GetClientAreaBoundsInScreen() const { |
| 103 return drwh_ozone_->GetClientAreaBoundsInScreen(); |
| 104 } |
| 105 |
| 106 gfx::Rect DesktopRootWindowHostOzone::GetRestoredBounds() const { |
| 107 return drwh_ozone_->GetRestoredBounds(); |
| 108 } |
| 109 |
| 110 gfx::Rect DesktopRootWindowHostOzone::GetWorkAreaBoundsInScreen() const { |
| 111 return drwh_ozone_->GetWorkAreaBoundsInScreen(); |
| 112 } |
| 113 |
| 114 void DesktopRootWindowHostOzone::SetShape(gfx::NativeRegion native_region) { |
| 115 drwh_ozone_->SetShape(native_region); |
| 116 } |
| 117 |
| 118 void DesktopRootWindowHostOzone::Activate() { |
| 119 drwh_ozone_->Activate(); |
| 120 } |
| 121 |
| 122 void DesktopRootWindowHostOzone::Deactivate() { |
| 123 drwh_ozone_->Deactivate(); |
| 124 } |
| 125 |
| 126 bool DesktopRootWindowHostOzone::IsActive() const { |
| 127 return drwh_ozone_->IsActive(); |
| 128 } |
| 129 |
| 130 void DesktopRootWindowHostOzone::Maximize() { |
| 131 drwh_ozone_->Maximize(); |
| 132 } |
| 133 |
| 134 void DesktopRootWindowHostOzone::Minimize() { |
| 135 drwh_ozone_->Minimize(); |
| 136 } |
| 137 |
| 138 void DesktopRootWindowHostOzone::Restore() { |
| 139 drwh_ozone_->Restore(); |
| 140 } |
| 141 |
| 142 bool DesktopRootWindowHostOzone::IsMaximized() const { |
| 143 return drwh_ozone_->IsMaximized(); |
| 144 } |
| 145 |
| 146 bool DesktopRootWindowHostOzone::IsMinimized() const { |
| 147 return drwh_ozone_->IsMinimized(); |
| 148 } |
| 149 |
| 150 bool DesktopRootWindowHostOzone::HasCapture() const { |
| 151 return drwh_ozone_->HasCapture(); |
| 152 } |
| 153 |
| 154 void DesktopRootWindowHostOzone::SetAlwaysOnTop(bool always_on_top) { |
| 155 drwh_ozone_->SetAlwaysOnTop(always_on_top); |
| 156 } |
| 157 |
| 158 bool DesktopRootWindowHostOzone::IsAlwaysOnTop() const { |
| 159 return drwh_ozone_->IsAlwaysOnTop(); |
| 160 } |
| 161 |
| 162 void DesktopRootWindowHostOzone::SetWindowTitle(const string16& title) { |
| 163 drwh_ozone_->SetWindowTitle(title); |
| 164 } |
| 165 |
| 166 void DesktopRootWindowHostOzone::ClearNativeFocus() { |
| 167 drwh_ozone_->ClearNativeFocus(); |
| 168 } |
| 169 |
| 170 Widget::MoveLoopResult DesktopRootWindowHostOzone::RunMoveLoop( |
| 171 const gfx::Vector2d& drag_offset, |
| 172 Widget::MoveLoopSource source, |
| 173 Widget::MoveLoopEscapeBehavior escape_behavior) { |
| 174 return drwh_ozone_->RunMoveLoop(drag_offset, source, escape_behavior); |
| 175 } |
| 176 |
| 177 void DesktopRootWindowHostOzone::EndMoveLoop() { |
| 178 drwh_ozone_->EndMoveLoop(); |
| 179 } |
| 180 |
| 181 void DesktopRootWindowHostOzone::SetVisibilityChangedAnimationsEnabled( |
| 182 bool value) { |
| 183 drwh_ozone_->SetVisibilityChangedAnimationsEnabled(value); |
| 184 } |
| 185 |
| 186 bool DesktopRootWindowHostOzone::ShouldUseNativeFrame() { |
| 187 return drwh_ozone_->ShouldUseNativeFrame(); |
| 188 } |
| 189 |
| 190 void DesktopRootWindowHostOzone::FrameTypeChanged() { |
| 191 drwh_ozone_->FrameTypeChanged(); |
| 192 } |
| 193 |
| 194 NonClientFrameView* DesktopRootWindowHostOzone::CreateNonClientFrameView() { |
| 195 return drwh_ozone_->CreateNonClientFrameView(); |
| 196 } |
| 197 |
| 198 void DesktopRootWindowHostOzone::SetFullscreen(bool fullscreen) { |
| 199 drwh_ozone_->SetFullscreen(fullscreen); |
| 200 } |
| 201 |
| 202 bool DesktopRootWindowHostOzone::IsFullscreen() const { |
| 203 return drwh_ozone_->IsFullscreen(); |
| 204 } |
| 205 |
| 206 void DesktopRootWindowHostOzone::SetOpacity(unsigned char opacity) { |
| 207 drwh_ozone_->SetOpacity(opacity); |
| 208 } |
| 209 |
| 210 void DesktopRootWindowHostOzone::SetWindowIcons( |
| 211 const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) { |
| 212 drwh_ozone_->SetWindowIcons(window_icon, app_icon); |
| 213 } |
| 214 |
| 215 void DesktopRootWindowHostOzone::InitModalType(ui::ModalType modal_type) { |
| 216 drwh_ozone_->InitModalType(modal_type); |
| 217 } |
| 218 |
| 219 void DesktopRootWindowHostOzone::FlashFrame(bool flash_frame) { |
| 220 drwh_ozone_->FlashFrame(flash_frame); |
| 221 } |
| 222 |
| 223 void DesktopRootWindowHostOzone::OnRootViewLayout() const { |
| 224 drwh_ozone_->OnRootViewLayout(); |
| 225 } |
| 226 |
| 227 void DesktopRootWindowHostOzone::OnNativeWidgetFocus() { |
| 228 drwh_ozone_->OnNativeWidgetFocus(); |
| 229 } |
| 230 |
| 231 void DesktopRootWindowHostOzone::OnNativeWidgetBlur() { |
| 232 drwh_ozone_->OnNativeWidgetBlur(); |
| 233 } |
| 234 |
| 235 bool DesktopRootWindowHostOzone::IsAnimatingClosed() const { |
| 236 return drwh_ozone_->IsAnimatingClosed(); |
| 237 } |
| 238 |
| 239 //////////////////////////////////////////////////////////////////////////////// |
| 240 // DesktopRootWindowHostOzone, aura::RootWindowHost implementation: |
| 241 |
| 242 aura::RootWindow* DesktopRootWindowHostOzone::GetRootWindow() { |
| 243 return drwh_ozone_->GetRootWindow(); |
| 244 } |
| 245 |
| 246 gfx::AcceleratedWidget DesktopRootWindowHostOzone::GetAcceleratedWidget() { |
| 247 return drwh_ozone_->GetAcceleratedWidget(); |
| 248 } |
| 249 |
| 250 void DesktopRootWindowHostOzone::Show() { |
| 251 drwh_ozone_->Show(); |
| 252 } |
| 253 |
| 254 void DesktopRootWindowHostOzone::Hide() { |
| 255 drwh_ozone_->Hide(); |
| 256 } |
| 257 |
| 258 void DesktopRootWindowHostOzone::ToggleFullScreen() { |
| 259 drwh_ozone_->ToggleFullScreen(); |
| 260 } |
| 261 |
| 262 gfx::Rect DesktopRootWindowHostOzone::GetBounds() const { |
| 263 return drwh_ozone_->GetBounds(); |
| 264 } |
| 265 |
| 266 void DesktopRootWindowHostOzone::SetBounds(const gfx::Rect& bounds) { |
| 267 drwh_ozone_->SetBounds(bounds); |
| 268 } |
| 269 |
| 270 gfx::Insets DesktopRootWindowHostOzone::GetInsets() const { |
| 271 return drwh_ozone_->GetInsets(); |
| 272 } |
| 273 |
| 274 void DesktopRootWindowHostOzone::SetInsets(const gfx::Insets& insets) { |
| 275 drwh_ozone_->SetInsets(insets); |
| 276 } |
| 277 |
| 278 gfx::Point DesktopRootWindowHostOzone::GetLocationOnNativeScreen() const { |
| 279 return drwh_ozone_->GetLocationOnNativeScreen(); |
| 280 } |
| 281 |
| 282 void DesktopRootWindowHostOzone::SetCapture() { |
| 283 drwh_ozone_->SetCapture(); |
| 284 } |
| 285 |
| 286 void DesktopRootWindowHostOzone::ReleaseCapture() { |
| 287 drwh_ozone_->ReleaseCapture(); |
| 288 } |
| 289 |
| 290 void DesktopRootWindowHostOzone::SetCursor(gfx::NativeCursor cursor) { |
| 291 drwh_ozone_->SetCursor(cursor); |
| 292 } |
| 293 |
| 294 bool DesktopRootWindowHostOzone::QueryMouseLocation( |
| 295 gfx::Point* location_return) { |
| 296 return drwh_ozone_->QueryMouseLocation(location_return); |
| 297 } |
| 298 |
| 299 bool DesktopRootWindowHostOzone::ConfineCursorToRootWindow() { |
| 300 return drwh_ozone_->ConfineCursorToRootWindow(); |
| 301 } |
| 302 |
| 303 void DesktopRootWindowHostOzone::UnConfineCursor() { |
| 304 drwh_ozone_->UnConfineCursor(); |
| 305 } |
| 306 |
| 307 void DesktopRootWindowHostOzone::OnCursorVisibilityChanged(bool show) { |
| 308 drwh_ozone_->OnCursorVisibilityChanged(show); |
| 309 } |
| 310 |
| 311 void DesktopRootWindowHostOzone::MoveCursorTo(const gfx::Point& location) { |
| 312 drwh_ozone_->MoveCursorTo(location); |
| 313 } |
| 314 |
| 315 void DesktopRootWindowHostOzone::PostNativeEvent( |
| 316 const base::NativeEvent& native_event) { |
| 317 drwh_ozone_->PostNativeEvent(native_event); |
| 318 } |
| 319 |
| 320 void DesktopRootWindowHostOzone::OnDeviceScaleFactorChanged( |
| 321 float device_scale_factor) { |
| 322 drwh_ozone_->OnDeviceScaleFactorChanged(device_scale_factor); |
| 323 } |
| 324 |
| 325 void DesktopRootWindowHostOzone::PrepareForShutdown() { |
| 326 drwh_ozone_->PrepareForShutdown(); |
| 327 } |
| 328 |
| 329 //////////////////////////////////////////////////////////////////////////////// |
| 330 // DesktopRootWindowHostOzone, MessageLoop::Dispatcher implementation: |
| 331 |
| 332 bool DesktopRootWindowHostOzone::Dispatch(const base::NativeEvent& ne) { |
| 333 return drwh_ozone_->Dispatch(ne); |
| 334 } |
| 335 |
| 336 //////////////////////////////////////////////////////////////////////////////// |
| 337 // DesktopRootWindowHost, public: |
| 338 |
| 339 // static |
| 11 DesktopRootWindowHost* DesktopRootWindowHost::Create( | 340 DesktopRootWindowHost* DesktopRootWindowHost::Create( |
| 12 internal::NativeWidgetDelegate* native_widget_delegate, | 341 internal::NativeWidgetDelegate* native_widget_delegate, |
| 13 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 342 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
| 14 DesktopFactoryOzone* d_factory = DesktopFactoryOzone::GetInstance(); | 343 return new DesktopRootWindowHostOzone(native_widget_delegate, |
| 15 | 344 desktop_native_widget_aura); |
| 16 return d_factory->CreateRootWindowHost(native_widget_delegate, | 345 } |
| 17 desktop_native_widget_aura); | 346 |
| 347 // static |
| 348 ui::NativeTheme* DesktopRootWindowHost::GetNativeTheme(aura::Window* window) { |
| 349 const views::LinuxUI* linux_ui = views::LinuxUI::instance(); |
| 350 if (linux_ui) { |
| 351 ui::NativeTheme* native_theme = linux_ui->GetNativeTheme(); |
| 352 if (native_theme) |
| 353 return native_theme; |
| 354 } |
| 355 |
| 356 return ui::NativeTheme::instance(); |
| 18 } | 357 } |
| 19 | 358 |
| 20 } // namespace views | 359 } // namespace views |
| OLD | NEW |