| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_root_window_host_win.h" | 5 #include "ui/views/widget/desktop_root_window_host_win.h" |
| 6 | 6 |
| 7 #include "ui/aura/desktop/desktop_activation_client.h" |
| 8 #include "ui/aura/desktop/desktop_dispatcher_client.h" |
| 9 #include "ui/aura/focus_manager.h" |
| 7 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
| 11 #include "ui/views/widget/desktop_capture_client.h" |
| 8 #include "ui/views/win/hwnd_message_handler.h" | 12 #include "ui/views/win/hwnd_message_handler.h" |
| 9 | 13 |
| 10 namespace views { | 14 namespace views { |
| 11 | 15 |
| 12 //////////////////////////////////////////////////////////////////////////////// | 16 //////////////////////////////////////////////////////////////////////////////// |
| 13 // DesktopRootWindowHostWin, public: | 17 // DesktopRootWindowHostWin, public: |
| 14 | 18 |
| 15 DesktopRootWindowHostWin::DesktopRootWindowHostWin( | 19 DesktopRootWindowHostWin::DesktopRootWindowHostWin( |
| 16 internal::NativeWidgetDelegate* native_widget_delegate, | 20 internal::NativeWidgetDelegate* native_widget_delegate, |
| 17 const gfx::Rect& initial_bounds) | 21 const gfx::Rect& initial_bounds) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 33 // TODO(beng): SetInitParams(). | 37 // TODO(beng): SetInitParams(). |
| 34 content_window_ = content_window; | 38 content_window_ = content_window; |
| 35 message_handler_->Init(NULL, params.bounds); | 39 message_handler_->Init(NULL, params.bounds); |
| 36 | 40 |
| 37 aura::RootWindow::CreateParams rw_params(params.bounds); | 41 aura::RootWindow::CreateParams rw_params(params.bounds); |
| 38 rw_params.host = this; | 42 rw_params.host = this; |
| 39 root_window_.reset(new aura::RootWindow(rw_params)); | 43 root_window_.reset(new aura::RootWindow(rw_params)); |
| 40 root_window_->Init(); | 44 root_window_->Init(); |
| 41 root_window_->AddChild(content_window_); | 45 root_window_->AddChild(content_window_); |
| 42 root_window_host_delegate_ = root_window_.get(); | 46 root_window_host_delegate_ = root_window_.get(); |
| 47 |
| 48 native_widget_delegate_->OnNativeWidgetCreated(); |
| 49 |
| 50 capture_client_.reset(new DesktopCaptureClient); |
| 51 aura::client::SetCaptureClient(root_window_.get(), capture_client_.get()); |
| 52 |
| 53 focus_manager_.reset(new aura::FocusManager); |
| 54 root_window_->set_focus_manager(focus_manager_.get()); |
| 55 |
| 56 activation_client_.reset( |
| 57 new aura::DesktopActivationClient(root_window_->GetFocusManager())); |
| 58 aura::client::SetActivationClient(root_window_.get(), |
| 59 activation_client_.get()); |
| 60 |
| 61 dispatcher_client_.reset(new aura::DesktopDispatcherClient); |
| 62 aura::client::SetDispatcherClient(root_window_.get(), |
| 63 dispatcher_client_.get()); |
| 64 } |
| 65 |
| 66 void DesktopRootWindowHostWin::Close() { |
| 67 message_handler_->Close(); |
| 68 } |
| 69 |
| 70 void DesktopRootWindowHostWin::CloseNow() { |
| 71 message_handler_->CloseNow(); |
| 72 } |
| 73 |
| 74 aura::RootWindowHost* DesktopRootWindowHostWin::AsRootWindowHost() { |
| 75 return this; |
| 43 } | 76 } |
| 44 | 77 |
| 45 void DesktopRootWindowHostWin::ShowWindowWithState( | 78 void DesktopRootWindowHostWin::ShowWindowWithState( |
| 46 ui::WindowShowState show_state) { | 79 ui::WindowShowState show_state) { |
| 47 message_handler_->ShowWindowWithState(show_state); | 80 message_handler_->ShowWindowWithState(show_state); |
| 48 } | 81 } |
| 49 | 82 |
| 83 bool DesktopRootWindowHostWin::IsVisible() const { |
| 84 return message_handler_->IsVisible(); |
| 85 } |
| 86 |
| 87 gfx::Rect DesktopRootWindowHostWin::GetClientAreaBoundsInScreen() const { |
| 88 return message_handler_->GetClientAreaBoundsInScreen(); |
| 89 } |
| 90 |
| 50 //////////////////////////////////////////////////////////////////////////////// | 91 //////////////////////////////////////////////////////////////////////////////// |
| 51 // DesktopRootWindowHostWin, RootWindowHost implementation: | 92 // DesktopRootWindowHostWin, RootWindowHost implementation: |
| 52 | 93 |
| 53 aura::RootWindow* DesktopRootWindowHostWin::GetRootWindow() { | 94 aura::RootWindow* DesktopRootWindowHostWin::GetRootWindow() { |
| 54 return root_window_.get(); | 95 return root_window_.get(); |
| 55 } | 96 } |
| 56 | 97 |
| 57 gfx::AcceleratedWidget DesktopRootWindowHostWin::GetAcceleratedWidget() { | 98 gfx::AcceleratedWidget DesktopRootWindowHostWin::GetAcceleratedWidget() { |
| 58 return message_handler_->hwnd(); | 99 return message_handler_->hwnd(); |
| 59 } | 100 } |
| 60 | 101 |
| 61 void DesktopRootWindowHostWin::Show() { | 102 void DesktopRootWindowHostWin::Show() { |
| 103 message_handler_->Show(); |
| 62 } | 104 } |
| 63 | 105 |
| 64 void DesktopRootWindowHostWin::Hide() { | 106 void DesktopRootWindowHostWin::Hide() { |
| 107 message_handler_->Hide(); |
| 65 } | 108 } |
| 66 | 109 |
| 67 void DesktopRootWindowHostWin::ToggleFullScreen() { | 110 void DesktopRootWindowHostWin::ToggleFullScreen() { |
| 68 } | 111 } |
| 69 | 112 |
| 70 gfx::Rect DesktopRootWindowHostWin::GetBounds() const { | 113 gfx::Rect DesktopRootWindowHostWin::GetBounds() const { |
| 71 return gfx::Rect(100, 100); | 114 return gfx::Rect(100, 100); |
| 72 } | 115 } |
| 73 | 116 |
| 74 void DesktopRootWindowHostWin::SetBounds(const gfx::Rect& bounds) { | 117 void DesktopRootWindowHostWin::SetBounds(const gfx::Rect& bounds) { |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 } | 287 } |
| 245 | 288 |
| 246 void DesktopRootWindowHostWin::HandleCreate() { | 289 void DesktopRootWindowHostWin::HandleCreate() { |
| 247 // TODO(beng): moar | 290 // TODO(beng): moar |
| 248 NOTIMPLEMENTED(); | 291 NOTIMPLEMENTED(); |
| 249 | 292 |
| 250 // 1. Window property association | 293 // 1. Window property association |
| 251 // 2. MouseWheel. | 294 // 2. MouseWheel. |
| 252 // 3. Drop target. | 295 // 3. Drop target. |
| 253 // 4. Tooltip Manager. | 296 // 4. Tooltip Manager. |
| 254 | |
| 255 native_widget_delegate_->OnNativeWidgetCreated(); | |
| 256 } | 297 } |
| 257 | 298 |
| 258 void DesktopRootWindowHostWin::HandleDestroying() { | 299 void DesktopRootWindowHostWin::HandleDestroying() { |
| 259 native_widget_delegate_->OnNativeWidgetDestroying(); | 300 native_widget_delegate_->OnNativeWidgetDestroying(); |
| 260 } | 301 } |
| 261 | 302 |
| 262 void DesktopRootWindowHostWin::HandleDestroyed() { | 303 void DesktopRootWindowHostWin::HandleDestroyed() { |
| 263 } | 304 } |
| 264 | 305 |
| 265 bool DesktopRootWindowHostWin::HandleInitialFocus() { | 306 bool DesktopRootWindowHostWin::HandleInitialFocus() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 279 } | 320 } |
| 280 | 321 |
| 281 void DesktopRootWindowHostWin::HandleWorkAreaChanged() { | 322 void DesktopRootWindowHostWin::HandleWorkAreaChanged() { |
| 282 } | 323 } |
| 283 | 324 |
| 284 void DesktopRootWindowHostWin::HandleVisibilityChanged(bool visible) { | 325 void DesktopRootWindowHostWin::HandleVisibilityChanged(bool visible) { |
| 285 } | 326 } |
| 286 | 327 |
| 287 void DesktopRootWindowHostWin::HandleClientSizeChanged( | 328 void DesktopRootWindowHostWin::HandleClientSizeChanged( |
| 288 const gfx::Size& new_size) { | 329 const gfx::Size& new_size) { |
| 289 root_window_host_delegate_->OnHostResized(new_size); | 330 if (root_window_host_delegate_) |
| 331 root_window_host_delegate_->OnHostResized(new_size); |
| 290 // TODO(beng): replace with a layout manager?? | 332 // TODO(beng): replace with a layout manager?? |
| 291 content_window_->SetBounds(gfx::Rect(new_size)); | 333 content_window_->SetBounds(gfx::Rect(new_size)); |
| 292 } | 334 } |
| 293 | 335 |
| 294 void DesktopRootWindowHostWin::HandleFrameChanged() { | 336 void DesktopRootWindowHostWin::HandleFrameChanged() { |
| 295 } | 337 } |
| 296 | 338 |
| 297 void DesktopRootWindowHostWin::HandleNativeFocus(HWND last_focused_window) { | 339 void DesktopRootWindowHostWin::HandleNativeFocus(HWND last_focused_window) { |
| 298 } | 340 } |
| 299 | 341 |
| 300 void DesktopRootWindowHostWin::HandleNativeBlur(HWND focused_window) { | 342 void DesktopRootWindowHostWin::HandleNativeBlur(HWND focused_window) { |
| 301 } | 343 } |
| 302 | 344 |
| 303 bool DesktopRootWindowHostWin::HandleMouseEvent(const ui::MouseEvent& event) { | 345 bool DesktopRootWindowHostWin::HandleMouseEvent(const ui::MouseEvent& event) { |
| 304 return false; | 346 return root_window_host_delegate_->OnHostMouseEvent( |
| 347 const_cast<ui::MouseEvent*>(&event)); |
| 305 } | 348 } |
| 306 | 349 |
| 307 bool DesktopRootWindowHostWin::HandleKeyEvent(const ui::KeyEvent& event) { | 350 bool DesktopRootWindowHostWin::HandleKeyEvent(const ui::KeyEvent& event) { |
| 308 return false; | 351 return false; |
| 309 } | 352 } |
| 310 | 353 |
| 311 bool DesktopRootWindowHostWin::HandleUntranslatedKeyEvent( | 354 bool DesktopRootWindowHostWin::HandleUntranslatedKeyEvent( |
| 312 const ui::KeyEvent& event) { | 355 const ui::KeyEvent& event) { |
| 313 return false; | 356 return false; |
| 314 } | 357 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 // DesktopRootWindowHost, public: | 407 // DesktopRootWindowHost, public: |
| 365 | 408 |
| 366 // static | 409 // static |
| 367 DesktopRootWindowHost* DesktopRootWindowHost::Create( | 410 DesktopRootWindowHost* DesktopRootWindowHost::Create( |
| 368 internal::NativeWidgetDelegate* native_widget_delegate, | 411 internal::NativeWidgetDelegate* native_widget_delegate, |
| 369 const gfx::Rect& initial_bounds) { | 412 const gfx::Rect& initial_bounds) { |
| 370 return new DesktopRootWindowHostWin(native_widget_delegate, initial_bounds); | 413 return new DesktopRootWindowHostWin(native_widget_delegate, initial_bounds); |
| 371 } | 414 } |
| 372 | 415 |
| 373 } // namespace views | 416 } // namespace views |
| OLD | NEW |