| 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/win/metro.h" | 7 #include "base/win/metro.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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 internal::NativeWidgetDelegate* native_widget_delegate, | 76 internal::NativeWidgetDelegate* native_widget_delegate, |
| 77 DesktopNativeWidgetAura* desktop_native_widget_aura) | 77 DesktopNativeWidgetAura* desktop_native_widget_aura) |
| 78 : message_handler_(new HWNDMessageHandler(this)), | 78 : message_handler_(new HWNDMessageHandler(this)), |
| 79 native_widget_delegate_(native_widget_delegate), | 79 native_widget_delegate_(native_widget_delegate), |
| 80 desktop_native_widget_aura_(desktop_native_widget_aura), | 80 desktop_native_widget_aura_(desktop_native_widget_aura), |
| 81 content_window_(NULL), | 81 content_window_(NULL), |
| 82 drag_drop_client_(NULL), | 82 drag_drop_client_(NULL), |
| 83 should_animate_window_close_(false), | 83 should_animate_window_close_(false), |
| 84 pending_close_(false), | 84 pending_close_(false), |
| 85 has_non_client_view_(false), | 85 has_non_client_view_(false), |
| 86 tooltip_(NULL) { | 86 tooltip_(NULL), |
| 87 need_synchronous_paint_(false), |
| 88 in_sizing_loop_(false) { |
| 87 } | 89 } |
| 88 | 90 |
| 89 DesktopWindowTreeHostWin::~DesktopWindowTreeHostWin() { | 91 DesktopWindowTreeHostWin::~DesktopWindowTreeHostWin() { |
| 90 // WARNING: |content_window_| has been destroyed by the time we get here. | 92 // WARNING: |content_window_| has been destroyed by the time we get here. |
| 91 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 93 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
| 92 DestroyDispatcher(); | 94 DestroyDispatcher(); |
| 93 } | 95 } |
| 94 | 96 |
| 95 // static | 97 // static |
| 96 aura::Window* DesktopWindowTreeHostWin::GetContentWindowForHWND(HWND hwnd) { | 98 aura::Window* DesktopWindowTreeHostWin::GetContentWindowForHWND(HWND hwnd) { |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 | 712 |
| 711 void DesktopWindowTreeHostWin::HandleCaptureLost() { | 713 void DesktopWindowTreeHostWin::HandleCaptureLost() { |
| 712 OnHostLostWindowCapture(); | 714 OnHostLostWindowCapture(); |
| 713 } | 715 } |
| 714 | 716 |
| 715 void DesktopWindowTreeHostWin::HandleClose() { | 717 void DesktopWindowTreeHostWin::HandleClose() { |
| 716 GetWidget()->Close(); | 718 GetWidget()->Close(); |
| 717 } | 719 } |
| 718 | 720 |
| 719 bool DesktopWindowTreeHostWin::HandleCommand(int command) { | 721 bool DesktopWindowTreeHostWin::HandleCommand(int command) { |
| 722 // Windows uses the 4 lower order bits of |notification_code| for type- |
| 723 // specific information so we must exclude this when comparing. |
| 724 static const int sc_mask = 0xFFF0; |
| 725 switch (command & sc_mask) { |
| 726 case SC_RESTORE: |
| 727 case SC_MAXIMIZE: |
| 728 need_synchronous_paint_ = true; |
| 729 break; |
| 730 |
| 731 case SC_SIZE: |
| 732 in_sizing_loop_ = true; |
| 733 break; |
| 734 |
| 735 default: |
| 736 break; |
| 737 } |
| 720 return GetWidget()->widget_delegate()->ExecuteWindowsCommand(command); | 738 return GetWidget()->widget_delegate()->ExecuteWindowsCommand(command); |
| 721 } | 739 } |
| 722 | 740 |
| 723 void DesktopWindowTreeHostWin::HandleAccelerator( | 741 void DesktopWindowTreeHostWin::HandleAccelerator( |
| 724 const ui::Accelerator& accelerator) { | 742 const ui::Accelerator& accelerator) { |
| 725 GetWidget()->GetFocusManager()->ProcessAccelerator(accelerator); | 743 GetWidget()->GetFocusManager()->ProcessAccelerator(accelerator); |
| 726 } | 744 } |
| 727 | 745 |
| 728 void DesktopWindowTreeHostWin::HandleCreate() { | 746 void DesktopWindowTreeHostWin::HandleCreate() { |
| 729 native_widget_delegate_->OnNativeWidgetCreated(true); | 747 native_widget_delegate_->OnNativeWidgetCreated(true); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 745 bool DesktopWindowTreeHostWin::HandleInitialFocus( | 763 bool DesktopWindowTreeHostWin::HandleInitialFocus( |
| 746 ui::WindowShowState show_state) { | 764 ui::WindowShowState show_state) { |
| 747 return GetWidget()->SetInitialFocus(show_state); | 765 return GetWidget()->SetInitialFocus(show_state); |
| 748 } | 766 } |
| 749 | 767 |
| 750 void DesktopWindowTreeHostWin::HandleDisplayChange() { | 768 void DesktopWindowTreeHostWin::HandleDisplayChange() { |
| 751 GetWidget()->widget_delegate()->OnDisplayChanged(); | 769 GetWidget()->widget_delegate()->OnDisplayChanged(); |
| 752 } | 770 } |
| 753 | 771 |
| 754 void DesktopWindowTreeHostWin::HandleBeginWMSizeMove() { | 772 void DesktopWindowTreeHostWin::HandleBeginWMSizeMove() { |
| 773 if (in_sizing_loop_) |
| 774 need_synchronous_paint_ = true; |
| 755 native_widget_delegate_->OnNativeWidgetBeginUserBoundsChange(); | 775 native_widget_delegate_->OnNativeWidgetBeginUserBoundsChange(); |
| 756 } | 776 } |
| 757 | 777 |
| 758 void DesktopWindowTreeHostWin::HandleEndWMSizeMove() { | 778 void DesktopWindowTreeHostWin::HandleEndWMSizeMove() { |
| 779 if (in_sizing_loop_) { |
| 780 need_synchronous_paint_ = false; |
| 781 in_sizing_loop_ = false; |
| 782 } |
| 759 native_widget_delegate_->OnNativeWidgetEndUserBoundsChange(); | 783 native_widget_delegate_->OnNativeWidgetEndUserBoundsChange(); |
| 760 } | 784 } |
| 761 | 785 |
| 762 void DesktopWindowTreeHostWin::HandleMove() { | 786 void DesktopWindowTreeHostWin::HandleMove() { |
| 763 native_widget_delegate_->OnNativeWidgetMove(); | 787 native_widget_delegate_->OnNativeWidgetMove(); |
| 764 OnHostMoved(GetBounds().origin()); | 788 OnHostMoved(GetBounds().origin()); |
| 765 } | 789 } |
| 766 | 790 |
| 767 void DesktopWindowTreeHostWin::HandleWorkAreaChanged() { | 791 void DesktopWindowTreeHostWin::HandleWorkAreaChanged() { |
| 768 GetWidget()->widget_delegate()->OnWorkAreaChanged(); | 792 GetWidget()->widget_delegate()->OnWorkAreaChanged(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 LPARAM l_param) { | 929 LPARAM l_param) { |
| 906 } | 930 } |
| 907 | 931 |
| 908 bool DesktopWindowTreeHostWin::HandleScrollEvent( | 932 bool DesktopWindowTreeHostWin::HandleScrollEvent( |
| 909 const ui::ScrollEvent& event) { | 933 const ui::ScrollEvent& event) { |
| 910 SendEventToProcessor(const_cast<ui::ScrollEvent*>(&event)); | 934 SendEventToProcessor(const_cast<ui::ScrollEvent*>(&event)); |
| 911 return event.handled(); | 935 return event.handled(); |
| 912 } | 936 } |
| 913 | 937 |
| 914 void DesktopWindowTreeHostWin::HandleWindowSizeChanging() { | 938 void DesktopWindowTreeHostWin::HandleWindowSizeChanging() { |
| 915 if (compositor()) | 939 if (compositor() && need_synchronous_paint_) { |
| 916 compositor()->FinishAllRendering(); | 940 compositor()->FinishAllRendering(); |
| 941 // If we received the window size changing notification due to a restore or |
| 942 // maximize operation, then we can reset the need_synchronous_paint_ flag |
| 943 // here. For a sizing operation, the flag will be reset at the end of the |
| 944 // operation. |
| 945 if (!in_sizing_loop_) |
| 946 need_synchronous_paint_ = false; |
| 947 } |
| 917 } | 948 } |
| 918 | 949 |
| 919 //////////////////////////////////////////////////////////////////////////////// | 950 //////////////////////////////////////////////////////////////////////////////// |
| 920 // DesktopWindowTreeHostWin, private: | 951 // DesktopWindowTreeHostWin, private: |
| 921 | 952 |
| 922 Widget* DesktopWindowTreeHostWin::GetWidget() { | 953 Widget* DesktopWindowTreeHostWin::GetWidget() { |
| 923 return native_widget_delegate_->AsWidget(); | 954 return native_widget_delegate_->AsWidget(); |
| 924 } | 955 } |
| 925 | 956 |
| 926 const Widget* DesktopWindowTreeHostWin::GetWidget() const { | 957 const Widget* DesktopWindowTreeHostWin::GetWidget() const { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 991 |
| 961 // static | 992 // static |
| 962 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 993 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
| 963 internal::NativeWidgetDelegate* native_widget_delegate, | 994 internal::NativeWidgetDelegate* native_widget_delegate, |
| 964 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 995 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
| 965 return new DesktopWindowTreeHostWin(native_widget_delegate, | 996 return new DesktopWindowTreeHostWin(native_widget_delegate, |
| 966 desktop_native_widget_aura); | 997 desktop_native_widget_aura); |
| 967 } | 998 } |
| 968 | 999 |
| 969 } // namespace views | 1000 } // namespace views |
| OLD | NEW |