| 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_window_tree_host_win.h" | 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "third_party/skia/include/core/SkPath.h" | 8 #include "third_party/skia/include/core/SkPath.h" |
| 9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 497 |
| 498 void DesktopWindowTreeHostWin::ShowImpl() { | 498 void DesktopWindowTreeHostWin::ShowImpl() { |
| 499 message_handler_->Show(); | 499 message_handler_->Show(); |
| 500 } | 500 } |
| 501 | 501 |
| 502 void DesktopWindowTreeHostWin::HideImpl() { | 502 void DesktopWindowTreeHostWin::HideImpl() { |
| 503 if (!pending_close_) | 503 if (!pending_close_) |
| 504 message_handler_->Hide(); | 504 message_handler_->Hide(); |
| 505 } | 505 } |
| 506 | 506 |
| 507 // GetBounds and SetBounds work in pixel coordinates, whereas other get/set | 507 // GetBoundsInPixels and SetBoundsInPixels work in pixel coordinates, whereas |
| 508 // methods work in DIP. | 508 // other get/set methods work in DIP. |
| 509 | 509 |
| 510 gfx::Rect DesktopWindowTreeHostWin::GetBounds() const { | 510 gfx::Rect DesktopWindowTreeHostWin::GetBoundsInPixels() const { |
| 511 gfx::Rect bounds(message_handler_->GetClientAreaBounds()); | 511 gfx::Rect bounds(message_handler_->GetClientAreaBounds()); |
| 512 // If the window bounds were expanded we need to return the original bounds | 512 // If the window bounds were expanded we need to return the original bounds |
| 513 // To achieve this we do the reverse of the expansion, i.e. add the | 513 // To achieve this we do the reverse of the expansion, i.e. add the |
| 514 // window_expansion_top_left_delta_ to the origin and subtract the | 514 // window_expansion_top_left_delta_ to the origin and subtract the |
| 515 // window_expansion_bottom_right_delta_ from the width and height. | 515 // window_expansion_bottom_right_delta_ from the width and height. |
| 516 gfx::Rect without_expansion( | 516 gfx::Rect without_expansion( |
| 517 bounds.x() + window_expansion_top_left_delta_.x(), | 517 bounds.x() + window_expansion_top_left_delta_.x(), |
| 518 bounds.y() + window_expansion_top_left_delta_.y(), | 518 bounds.y() + window_expansion_top_left_delta_.y(), |
| 519 bounds.width() - window_expansion_bottom_right_delta_.x() - | 519 bounds.width() - window_expansion_bottom_right_delta_.x() - |
| 520 window_enlargement_.x(), | 520 window_enlargement_.x(), |
| 521 bounds.height() - window_expansion_bottom_right_delta_.y() - | 521 bounds.height() - window_expansion_bottom_right_delta_.y() - |
| 522 window_enlargement_.y()); | 522 window_enlargement_.y()); |
| 523 return without_expansion; | 523 return without_expansion; |
| 524 } | 524 } |
| 525 | 525 |
| 526 void DesktopWindowTreeHostWin::SetBounds(const gfx::Rect& bounds) { | 526 void DesktopWindowTreeHostWin::SetBoundsInPixels(const gfx::Rect& bounds) { |
| 527 // If the window bounds have to be expanded we need to subtract the | 527 // If the window bounds have to be expanded we need to subtract the |
| 528 // window_expansion_top_left_delta_ from the origin and add the | 528 // window_expansion_top_left_delta_ from the origin and add the |
| 529 // window_expansion_bottom_right_delta_ to the width and height | 529 // window_expansion_bottom_right_delta_ to the width and height |
| 530 gfx::Size old_content_size = GetBounds().size(); | 530 gfx::Size old_content_size = GetBoundsInPixels().size(); |
| 531 | 531 |
| 532 gfx::Rect expanded( | 532 gfx::Rect expanded( |
| 533 bounds.x() - window_expansion_top_left_delta_.x(), | 533 bounds.x() - window_expansion_top_left_delta_.x(), |
| 534 bounds.y() - window_expansion_top_left_delta_.y(), | 534 bounds.y() - window_expansion_top_left_delta_.y(), |
| 535 bounds.width() + window_expansion_bottom_right_delta_.x(), | 535 bounds.width() + window_expansion_bottom_right_delta_.x(), |
| 536 bounds.height() + window_expansion_bottom_right_delta_.y()); | 536 bounds.height() + window_expansion_bottom_right_delta_.y()); |
| 537 | 537 |
| 538 gfx::Rect new_expanded( | 538 gfx::Rect new_expanded( |
| 539 expanded.origin(), | 539 expanded.origin(), |
| 540 GetExpandedWindowSize(message_handler_->window_ex_style(), | 540 GetExpandedWindowSize(message_handler_->window_ex_style(), |
| 541 expanded.size())); | 541 expanded.size())); |
| 542 window_enlargement_ = | 542 window_enlargement_ = |
| 543 gfx::Vector2d(new_expanded.width() - expanded.width(), | 543 gfx::Vector2d(new_expanded.width() - expanded.width(), |
| 544 new_expanded.height() - expanded.height()); | 544 new_expanded.height() - expanded.height()); |
| 545 message_handler_->SetBounds(new_expanded, old_content_size != bounds.size()); | 545 message_handler_->SetBounds(new_expanded, old_content_size != bounds.size()); |
| 546 } | 546 } |
| 547 | 547 |
| 548 gfx::Point DesktopWindowTreeHostWin::GetLocationOnNativeScreen() const { | 548 gfx::Point DesktopWindowTreeHostWin::GetLocationOnNativeScreen() const { |
| 549 return GetBounds().origin(); | 549 return GetBoundsInPixels().origin(); |
| 550 } | 550 } |
| 551 | 551 |
| 552 void DesktopWindowTreeHostWin::SetCapture() { | 552 void DesktopWindowTreeHostWin::SetCapture() { |
| 553 message_handler_->SetCapture(); | 553 message_handler_->SetCapture(); |
| 554 } | 554 } |
| 555 | 555 |
| 556 void DesktopWindowTreeHostWin::ReleaseCapture() { | 556 void DesktopWindowTreeHostWin::ReleaseCapture() { |
| 557 message_handler_->ReleaseCapture(); | 557 message_handler_->ReleaseCapture(); |
| 558 } | 558 } |
| 559 | 559 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 576 ::ClientToScreen(GetHWND(), &cursor_location); | 576 ::ClientToScreen(GetHWND(), &cursor_location); |
| 577 ::SetCursorPos(cursor_location.x, cursor_location.y); | 577 ::SetCursorPos(cursor_location.x, cursor_location.y); |
| 578 } | 578 } |
| 579 | 579 |
| 580 //////////////////////////////////////////////////////////////////////////////// | 580 //////////////////////////////////////////////////////////////////////////////// |
| 581 // DesktopWindowTreeHostWin, aura::AnimationHost implementation: | 581 // DesktopWindowTreeHostWin, aura::AnimationHost implementation: |
| 582 | 582 |
| 583 void DesktopWindowTreeHostWin::SetHostTransitionOffsets( | 583 void DesktopWindowTreeHostWin::SetHostTransitionOffsets( |
| 584 const gfx::Vector2d& top_left_delta, | 584 const gfx::Vector2d& top_left_delta, |
| 585 const gfx::Vector2d& bottom_right_delta) { | 585 const gfx::Vector2d& bottom_right_delta) { |
| 586 gfx::Rect bounds_without_expansion = GetBounds(); | 586 gfx::Rect bounds_without_expansion = GetBoundsInPixels(); |
| 587 window_expansion_top_left_delta_ = top_left_delta; | 587 window_expansion_top_left_delta_ = top_left_delta; |
| 588 window_expansion_bottom_right_delta_ = bottom_right_delta; | 588 window_expansion_bottom_right_delta_ = bottom_right_delta; |
| 589 SetBounds(bounds_without_expansion); | 589 SetBoundsInPixels(bounds_without_expansion); |
| 590 } | 590 } |
| 591 | 591 |
| 592 void DesktopWindowTreeHostWin::OnWindowHidingAnimationCompleted() { | 592 void DesktopWindowTreeHostWin::OnWindowHidingAnimationCompleted() { |
| 593 if (pending_close_) | 593 if (pending_close_) |
| 594 message_handler_->Close(); | 594 message_handler_->Close(); |
| 595 } | 595 } |
| 596 | 596 |
| 597 //////////////////////////////////////////////////////////////////////////////// | 597 //////////////////////////////////////////////////////////////////////////////// |
| 598 // DesktopWindowTreeHostWin, HWNDMessageHandlerDelegate implementation: | 598 // DesktopWindowTreeHostWin, HWNDMessageHandlerDelegate implementation: |
| 599 | 599 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 void DesktopWindowTreeHostWin::HandleBeginWMSizeMove() { | 786 void DesktopWindowTreeHostWin::HandleBeginWMSizeMove() { |
| 787 native_widget_delegate_->OnNativeWidgetBeginUserBoundsChange(); | 787 native_widget_delegate_->OnNativeWidgetBeginUserBoundsChange(); |
| 788 } | 788 } |
| 789 | 789 |
| 790 void DesktopWindowTreeHostWin::HandleEndWMSizeMove() { | 790 void DesktopWindowTreeHostWin::HandleEndWMSizeMove() { |
| 791 native_widget_delegate_->OnNativeWidgetEndUserBoundsChange(); | 791 native_widget_delegate_->OnNativeWidgetEndUserBoundsChange(); |
| 792 } | 792 } |
| 793 | 793 |
| 794 void DesktopWindowTreeHostWin::HandleMove() { | 794 void DesktopWindowTreeHostWin::HandleMove() { |
| 795 native_widget_delegate_->OnNativeWidgetMove(); | 795 native_widget_delegate_->OnNativeWidgetMove(); |
| 796 OnHostMoved(GetBounds().origin()); | 796 OnHostMoved(GetBoundsInPixels().origin()); |
| 797 } | 797 } |
| 798 | 798 |
| 799 void DesktopWindowTreeHostWin::HandleWorkAreaChanged() { | 799 void DesktopWindowTreeHostWin::HandleWorkAreaChanged() { |
| 800 GetWidget()->widget_delegate()->OnWorkAreaChanged(); | 800 GetWidget()->widget_delegate()->OnWorkAreaChanged(); |
| 801 } | 801 } |
| 802 | 802 |
| 803 void DesktopWindowTreeHostWin::HandleVisibilityChanging(bool visible) { | 803 void DesktopWindowTreeHostWin::HandleVisibilityChanging(bool visible) { |
| 804 native_widget_delegate_->OnNativeWidgetVisibilityChanging(visible); | 804 native_widget_delegate_->OnNativeWidgetVisibilityChanging(visible); |
| 805 } | 805 } |
| 806 | 806 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 | 993 |
| 994 // static | 994 // static |
| 995 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 995 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
| 996 internal::NativeWidgetDelegate* native_widget_delegate, | 996 internal::NativeWidgetDelegate* native_widget_delegate, |
| 997 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 997 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
| 998 return new DesktopWindowTreeHostWin(native_widget_delegate, | 998 return new DesktopWindowTreeHostWin(native_widget_delegate, |
| 999 desktop_native_widget_aura); | 999 desktop_native_widget_aura); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 } // namespace views | 1002 } // namespace views |
| OLD | NEW |