| 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_aura/desktop_root_window_host_win.h" | 5 #include "ui/views/widget/desktop_aura/desktop_root_window_host_win.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkPath.h" | 7 #include "third_party/skia/include/core/SkPath.h" |
| 8 #include "third_party/skia/include/core/SkRegion.h" | 8 #include "third_party/skia/include/core/SkRegion.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/focus_manager.h" | 10 #include "ui/aura/focus_manager.h" |
| 11 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
| 12 #include "ui/aura/window_property.h" | 12 #include "ui/aura/window_property.h" |
| 13 #include "ui/base/cursor/cursor_loader_win.h" | 13 #include "ui/base/cursor/cursor_loader_win.h" |
| 14 #include "ui/base/ime/input_method_win.h" | 14 #include "ui/base/ime/input_method_win.h" |
| 15 #include "ui/base/win/shell.h" | 15 #include "ui/base/win/shell.h" |
| 16 #include "ui/gfx/insets.h" | 16 #include "ui/gfx/insets.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
| 18 #include "ui/gfx/path_win.h" | 18 #include "ui/gfx/path_win.h" |
| 19 #include "ui/native_theme/native_theme_aura.h" | 19 #include "ui/native_theme/native_theme_aura.h" |
| 20 #include "ui/native_theme/native_theme_win.h" | 20 #include "ui/native_theme/native_theme_win.h" |
| 21 #include "ui/views/corewm/compound_event_filter.h" | 21 #include "ui/views/corewm/compound_event_filter.h" |
| 22 #include "ui/views/corewm/corewm_switches.h" | 22 #include "ui/views/corewm/corewm_switches.h" |
| 23 #include "ui/views/corewm/cursor_manager.h" | 23 #include "ui/views/corewm/cursor_manager.h" |
| 24 #include "ui/views/corewm/focus_controller.h" | 24 #include "ui/views/corewm/focus_controller.h" |
| 25 #include "ui/views/corewm/input_method_event_filter.h" | 25 #include "ui/views/corewm/input_method_event_filter.h" |
| 26 #include "ui/views/corewm/window_animations.h" |
| 26 #include "ui/views/ime/input_method_bridge.h" | 27 #include "ui/views/ime/input_method_bridge.h" |
| 27 #include "ui/views/widget/desktop_aura/desktop_activation_client.h" | 28 #include "ui/views/widget/desktop_aura/desktop_activation_client.h" |
| 28 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" | 29 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" |
| 29 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" | 30 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" |
| 30 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" | 31 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" |
| 31 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" | 32 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" |
| 32 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" | 33 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" |
| 33 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 34 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 34 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" | 35 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" |
| 35 #include "ui/views/widget/root_view.h" | 36 #include "ui/views/widget/root_view.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 DesktopRootWindowHostWin::DesktopRootWindowHostWin( | 50 DesktopRootWindowHostWin::DesktopRootWindowHostWin( |
| 50 internal::NativeWidgetDelegate* native_widget_delegate, | 51 internal::NativeWidgetDelegate* native_widget_delegate, |
| 51 DesktopNativeWidgetAura* desktop_native_widget_aura, | 52 DesktopNativeWidgetAura* desktop_native_widget_aura, |
| 52 const gfx::Rect& initial_bounds) | 53 const gfx::Rect& initial_bounds) |
| 53 : ALLOW_THIS_IN_INITIALIZER_LIST( | 54 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 54 message_handler_(new HWNDMessageHandler(this))), | 55 message_handler_(new HWNDMessageHandler(this))), |
| 55 native_widget_delegate_(native_widget_delegate), | 56 native_widget_delegate_(native_widget_delegate), |
| 56 desktop_native_widget_aura_(desktop_native_widget_aura), | 57 desktop_native_widget_aura_(desktop_native_widget_aura), |
| 57 root_window_host_delegate_(NULL), | 58 root_window_host_delegate_(NULL), |
| 58 content_window_(NULL) { | 59 content_window_(NULL), |
| 60 should_animate_window_close_(false), |
| 61 pending_close_(false) { |
| 59 } | 62 } |
| 60 | 63 |
| 61 DesktopRootWindowHostWin::~DesktopRootWindowHostWin() { | 64 DesktopRootWindowHostWin::~DesktopRootWindowHostWin() { |
| 62 if (corewm::UseFocusControllerOnDesktop()) { | 65 if (corewm::UseFocusControllerOnDesktop()) { |
| 63 aura::client::SetFocusClient(root_window_, NULL); | 66 aura::client::SetFocusClient(root_window_, NULL); |
| 64 aura::client::SetActivationClient(root_window_, NULL); | 67 aura::client::SetActivationClient(root_window_, NULL); |
| 65 } | 68 } |
| 66 } | 69 } |
| 67 | 70 |
| 68 // static | 71 // static |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 160 |
| 158 desktop_native_widget_aura_->InstallInputMethodEventFilter(root_window_); | 161 desktop_native_widget_aura_->InstallInputMethodEventFilter(root_window_); |
| 159 | 162 |
| 160 drag_drop_client_.reset(new DesktopDragDropClientWin(root_window_, | 163 drag_drop_client_.reset(new DesktopDragDropClientWin(root_window_, |
| 161 GetHWND())); | 164 GetHWND())); |
| 162 aura::client::SetDragDropClient(root_window_, drag_drop_client_.get()); | 165 aura::client::SetDragDropClient(root_window_, drag_drop_client_.get()); |
| 163 | 166 |
| 164 focus_client_->FocusWindow(content_window_); | 167 focus_client_->FocusWindow(content_window_); |
| 165 root_window_->SetProperty(kContentWindowForRootWindow, content_window_); | 168 root_window_->SetProperty(kContentWindowForRootWindow, content_window_); |
| 166 | 169 |
| 170 aura::client::SetAnimationHost(content_window_, this); |
| 171 |
| 172 should_animate_window_close_ = |
| 173 content_window_->type() != aura::client::WINDOW_TYPE_NORMAL && |
| 174 !views::corewm::WindowAnimationsDisabled(content_window_); |
| 175 |
| 167 return root_window_; | 176 return root_window_; |
| 168 } | 177 } |
| 169 | 178 |
| 179 void DesktopRootWindowHostWin::InitFocus(aura::Window* window) { |
| 180 focus_client_->FocusWindow(window); |
| 181 } |
| 182 |
| 170 void DesktopRootWindowHostWin::Close() { | 183 void DesktopRootWindowHostWin::Close() { |
| 171 message_handler_->Close(); | 184 if (should_animate_window_close_) { |
| 185 pending_close_ = true; |
| 186 // OnWindowHidingAnimationCompleted does the actual Close. |
| 187 content_window_->Hide(); |
| 188 } else { |
| 189 message_handler_->Close(); |
| 190 } |
| 172 } | 191 } |
| 173 | 192 |
| 174 void DesktopRootWindowHostWin::CloseNow() { | 193 void DesktopRootWindowHostWin::CloseNow() { |
| 175 message_handler_->CloseNow(); | 194 message_handler_->CloseNow(); |
| 176 } | 195 } |
| 177 | 196 |
| 178 aura::RootWindowHost* DesktopRootWindowHostWin::AsRootWindowHost() { | 197 aura::RootWindowHost* DesktopRootWindowHostWin::AsRootWindowHost() { |
| 179 return this; | 198 return this; |
| 180 } | 199 } |
| 181 | 200 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 378 |
| 360 gfx::AcceleratedWidget DesktopRootWindowHostWin::GetAcceleratedWidget() { | 379 gfx::AcceleratedWidget DesktopRootWindowHostWin::GetAcceleratedWidget() { |
| 361 return message_handler_->hwnd(); | 380 return message_handler_->hwnd(); |
| 362 } | 381 } |
| 363 | 382 |
| 364 void DesktopRootWindowHostWin::Show() { | 383 void DesktopRootWindowHostWin::Show() { |
| 365 message_handler_->Show(); | 384 message_handler_->Show(); |
| 366 } | 385 } |
| 367 | 386 |
| 368 void DesktopRootWindowHostWin::Hide() { | 387 void DesktopRootWindowHostWin::Hide() { |
| 369 message_handler_->Hide(); | 388 if (!pending_close_) |
| 389 message_handler_->Hide(); |
| 370 } | 390 } |
| 371 | 391 |
| 372 void DesktopRootWindowHostWin::ToggleFullScreen() { | 392 void DesktopRootWindowHostWin::ToggleFullScreen() { |
| 373 } | 393 } |
| 374 | 394 |
| 375 gfx::Rect DesktopRootWindowHostWin::GetBounds() const { | 395 gfx::Rect DesktopRootWindowHostWin::GetBounds() const { |
| 376 // Match the logic in HWNDMessageHandler::ClientAreaSizeChanged(). | 396 // Match the logic in HWNDMessageHandler::ClientAreaSizeChanged(). |
| 377 return WidgetSizeIsClientSize() ? | 397 gfx::Rect bounds(WidgetSizeIsClientSize() ? GetClientAreaBoundsInScreen() |
| 378 GetClientAreaBoundsInScreen() : GetWindowBoundsInScreen(); | 398 : GetWindowBoundsInScreen()); |
| 399 gfx::Rect without_expansion(bounds.x() - window_expansion_.x(), |
| 400 bounds.y() - window_expansion_.y(), |
| 401 bounds.width() - window_expansion_.width(), |
| 402 bounds.height() - window_expansion_.height()); |
| 403 return without_expansion; |
| 379 } | 404 } |
| 380 | 405 |
| 381 void DesktopRootWindowHostWin::SetBounds(const gfx::Rect& bounds) { | 406 void DesktopRootWindowHostWin::SetBounds(const gfx::Rect& bounds) { |
| 382 message_handler_->SetBounds(bounds); | 407 gfx::Rect expanded(bounds.x() + window_expansion_.x(), |
| 408 bounds.y() + window_expansion_.y(), |
| 409 bounds.width() + window_expansion_.width(), |
| 410 bounds.height() + window_expansion_.height()); |
| 411 message_handler_->SetBounds(expanded); |
| 383 } | 412 } |
| 384 | 413 |
| 385 gfx::Insets DesktopRootWindowHostWin::GetInsets() const { | 414 gfx::Insets DesktopRootWindowHostWin::GetInsets() const { |
| 386 return gfx::Insets(); | 415 return gfx::Insets(); |
| 387 } | 416 } |
| 388 | 417 |
| 389 void DesktopRootWindowHostWin::SetInsets(const gfx::Insets& insets) { | 418 void DesktopRootWindowHostWin::SetInsets(const gfx::Insets& insets) { |
| 390 } | 419 } |
| 391 | 420 |
| 392 gfx::Point DesktopRootWindowHostWin::GetLocationOnNativeScreen() const { | 421 gfx::Point DesktopRootWindowHostWin::GetLocationOnNativeScreen() const { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 } | 477 } |
| 449 | 478 |
| 450 void DesktopRootWindowHostWin::OnDeviceScaleFactorChanged( | 479 void DesktopRootWindowHostWin::OnDeviceScaleFactorChanged( |
| 451 float device_scale_factor) { | 480 float device_scale_factor) { |
| 452 } | 481 } |
| 453 | 482 |
| 454 void DesktopRootWindowHostWin::PrepareForShutdown() { | 483 void DesktopRootWindowHostWin::PrepareForShutdown() { |
| 455 } | 484 } |
| 456 | 485 |
| 457 //////////////////////////////////////////////////////////////////////////////// | 486 //////////////////////////////////////////////////////////////////////////////// |
| 487 // DesktopRootWindowHostWin, aura::WindowAnimationHost implementation: |
| 488 |
| 489 void DesktopRootWindowHostWin::SetHostTransitionBounds( |
| 490 const gfx::Rect& bounds) { |
| 491 gfx::Rect bounds_without_expansion = GetBounds(); |
| 492 window_expansion_ = bounds; |
| 493 SetBounds(bounds_without_expansion); |
| 494 } |
| 495 |
| 496 void DesktopRootWindowHostWin::OnWindowHidingAnimationCompleted() { |
| 497 if (pending_close_) |
| 498 message_handler_->Close(); |
| 499 } |
| 500 |
| 501 //////////////////////////////////////////////////////////////////////////////// |
| 458 // DesktopRootWindowHostWin, HWNDMessageHandlerDelegate implementation: | 502 // DesktopRootWindowHostWin, HWNDMessageHandlerDelegate implementation: |
| 459 | 503 |
| 460 bool DesktopRootWindowHostWin::IsWidgetWindow() const { | 504 bool DesktopRootWindowHostWin::IsWidgetWindow() const { |
| 461 return true; | 505 return true; |
| 462 } | 506 } |
| 463 | 507 |
| 464 bool DesktopRootWindowHostWin::IsUsingCustomFrame() const { | 508 bool DesktopRootWindowHostWin::IsUsingCustomFrame() const { |
| 465 return !GetWidget()->ShouldUseNativeFrame(); | 509 return !GetWidget()->ShouldUseNativeFrame(); |
| 466 } | 510 } |
| 467 | 511 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 void DesktopRootWindowHostWin::HandleWorkAreaChanged() { | 693 void DesktopRootWindowHostWin::HandleWorkAreaChanged() { |
| 650 GetWidget()->widget_delegate()->OnWorkAreaChanged(); | 694 GetWidget()->widget_delegate()->OnWorkAreaChanged(); |
| 651 } | 695 } |
| 652 | 696 |
| 653 void DesktopRootWindowHostWin::HandleVisibilityChanged(bool visible) { | 697 void DesktopRootWindowHostWin::HandleVisibilityChanged(bool visible) { |
| 654 native_widget_delegate_->OnNativeWidgetVisibilityChanged(visible); | 698 native_widget_delegate_->OnNativeWidgetVisibilityChanged(visible); |
| 655 } | 699 } |
| 656 | 700 |
| 657 void DesktopRootWindowHostWin::HandleClientSizeChanged( | 701 void DesktopRootWindowHostWin::HandleClientSizeChanged( |
| 658 const gfx::Size& new_size) { | 702 const gfx::Size& new_size) { |
| 703 gfx::Size without_expansion(new_size.width() - window_expansion_.width(), |
| 704 new_size.height() - window_expansion_.height()); |
| 659 if (root_window_host_delegate_) | 705 if (root_window_host_delegate_) |
| 660 root_window_host_delegate_->OnHostResized(new_size); | 706 root_window_host_delegate_->OnHostResized(new_size); |
| 661 // TODO(beng): replace with a layout manager?? | 707 // TODO(beng): replace with a layout manager?? |
| 662 content_window_->SetBounds(gfx::Rect(new_size)); | 708 content_window_->SetBounds(gfx::Rect(without_expansion)); |
| 663 } | 709 } |
| 664 | 710 |
| 665 void DesktopRootWindowHostWin::HandleFrameChanged() { | 711 void DesktopRootWindowHostWin::HandleFrameChanged() { |
| 666 // Replace the frame and layout the contents. | 712 // Replace the frame and layout the contents. |
| 667 GetWidget()->non_client_view()->UpdateFrame(true); | 713 GetWidget()->non_client_view()->UpdateFrame(true); |
| 668 } | 714 } |
| 669 | 715 |
| 670 void DesktopRootWindowHostWin::HandleNativeFocus(HWND last_focused_window) { | 716 void DesktopRootWindowHostWin::HandleNativeFocus(HWND last_focused_window) { |
| 671 // TODO(beng): inform the native_widget_delegate_. | 717 // TODO(beng): inform the native_widget_delegate_. |
| 672 InputMethod* input_method = GetInputMethod(); | 718 InputMethod* input_method = GetInputMethod(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 DesktopRootWindowHost* DesktopRootWindowHost::Create( | 830 DesktopRootWindowHost* DesktopRootWindowHost::Create( |
| 785 internal::NativeWidgetDelegate* native_widget_delegate, | 831 internal::NativeWidgetDelegate* native_widget_delegate, |
| 786 DesktopNativeWidgetAura* desktop_native_widget_aura, | 832 DesktopNativeWidgetAura* desktop_native_widget_aura, |
| 787 const gfx::Rect& initial_bounds) { | 833 const gfx::Rect& initial_bounds) { |
| 788 return new DesktopRootWindowHostWin(native_widget_delegate, | 834 return new DesktopRootWindowHostWin(native_widget_delegate, |
| 789 desktop_native_widget_aura, | 835 desktop_native_widget_aura, |
| 790 initial_bounds); | 836 initial_bounds); |
| 791 } | 837 } |
| 792 | 838 |
| 793 } // namespace views | 839 } // namespace views |
| OLD | NEW |