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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 internal::NativeWidgetDelegate* native_widget_delegate, | 78 internal::NativeWidgetDelegate* native_widget_delegate, |
79 DesktopNativeWidgetAura* desktop_native_widget_aura) | 79 DesktopNativeWidgetAura* desktop_native_widget_aura) |
80 : message_handler_(new HWNDMessageHandler(this)), | 80 : message_handler_(new HWNDMessageHandler(this)), |
81 native_widget_delegate_(native_widget_delegate), | 81 native_widget_delegate_(native_widget_delegate), |
82 desktop_native_widget_aura_(desktop_native_widget_aura), | 82 desktop_native_widget_aura_(desktop_native_widget_aura), |
83 content_window_(NULL), | 83 content_window_(NULL), |
84 drag_drop_client_(NULL), | 84 drag_drop_client_(NULL), |
85 should_animate_window_close_(false), | 85 should_animate_window_close_(false), |
86 pending_close_(false), | 86 pending_close_(false), |
87 has_non_client_view_(false), | 87 has_non_client_view_(false), |
88 tooltip_(NULL) { | 88 tooltip_(NULL), |
89 weak_factory_(this) { | |
89 } | 90 } |
90 | 91 |
91 DesktopWindowTreeHostWin::~DesktopWindowTreeHostWin() { | 92 DesktopWindowTreeHostWin::~DesktopWindowTreeHostWin() { |
92 // WARNING: |content_window_| has been destroyed by the time we get here. | 93 // WARNING: |content_window_| has been destroyed by the time we get here. |
93 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 94 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
94 DestroyDispatcher(); | 95 DestroyDispatcher(); |
95 } | 96 } |
96 | 97 |
97 // static | 98 // static |
98 aura::Window* DesktopWindowTreeHostWin::GetContentWindowForHWND(HWND hwnd) { | 99 aura::Window* DesktopWindowTreeHostWin::GetContentWindowForHWND(HWND hwnd) { |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
817 if (!GetWidget()->GetNativeView()) | 818 if (!GetWidget()->GetNativeView()) |
818 return; | 819 return; |
819 | 820 |
820 // Currently we assume the window that has capture gets touch events too. | 821 // Currently we assume the window that has capture gets touch events too. |
821 aura::WindowTreeHost* host = | 822 aura::WindowTreeHost* host = |
822 aura::WindowTreeHost::GetForAcceleratedWidget(GetCapture()); | 823 aura::WindowTreeHost::GetForAcceleratedWidget(GetCapture()); |
823 if (host) { | 824 if (host) { |
824 DesktopWindowTreeHostWin* target = | 825 DesktopWindowTreeHostWin* target = |
825 host->window()->GetProperty(kDesktopWindowTreeHostKey); | 826 host->window()->GetProperty(kDesktopWindowTreeHostKey); |
826 if (target && target->HasCapture() && target != this) { | 827 if (target && target->HasCapture() && target != this) { |
828 // Windows like menus need to be closed if a touch occurs outside the | |
829 // bounds of the window. | |
830 if ((event.type() == ui::ET_TOUCH_PRESSED) && | |
831 GetWidget()->GetNativeView()->GetProperty( | |
832 aura::client::kReleaseCaptureOnTouchOutside)) { | |
833 target->ReleaseCapture(); | |
834 // We should send the touch to the correct window. We use PostTask here | |
835 // as we don't want to send the touch event in the context of the | |
836 // nested loop if any. | |
837 base::MessageLoop::current()->PostTask( | |
sky
2016/01/08 23:51:56
Is there no way to have the menu code do the posti
ananta
2016/01/09 00:01:15
The touch events are handled by the gesture recogn
| |
838 FROM_HERE, | |
839 base::Bind(&DesktopWindowTreeHostWin::PostEventToProcessor, | |
840 weak_factory_.GetWeakPtr(), | |
841 event)); | |
842 return; | |
843 } | |
844 | |
827 POINT target_location(event.location().ToPOINT()); | 845 POINT target_location(event.location().ToPOINT()); |
828 ClientToScreen(GetHWND(), &target_location); | 846 ClientToScreen(GetHWND(), &target_location); |
829 ScreenToClient(target->GetHWND(), &target_location); | 847 ScreenToClient(target->GetHWND(), &target_location); |
830 ui::TouchEvent target_event(event, static_cast<View*>(NULL), | 848 ui::TouchEvent target_event(event, static_cast<View*>(NULL), |
831 static_cast<View*>(NULL)); | 849 static_cast<View*>(NULL)); |
832 target_event.set_location(gfx::Point(target_location)); | 850 target_event.set_location(gfx::Point(target_location)); |
833 target_event.set_root_location(target_event.location()); | 851 target_event.set_root_location(target_event.location()); |
834 target->SendEventToProcessor(&target_event); | 852 target->SendEventToProcessor(&target_event); |
835 return; | 853 return; |
836 } | 854 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
942 for (index = window()->children().begin(); | 960 for (index = window()->children().begin(); |
943 index != window()->children().end(); | 961 index != window()->children().end(); |
944 ++index) { | 962 ++index) { |
945 if ((*index)->GetProperty(aura::client::kModalKey) != | 963 if ((*index)->GetProperty(aura::client::kModalKey) != |
946 ui:: MODAL_TYPE_NONE && (*index)->TargetVisibility()) | 964 ui:: MODAL_TYPE_NONE && (*index)->TargetVisibility()) |
947 return true; | 965 return true; |
948 } | 966 } |
949 return false; | 967 return false; |
950 } | 968 } |
951 | 969 |
970 void DesktopWindowTreeHostWin::PostEventToProcessor( | |
971 const ui::Event& event) { | |
972 SendEventToProcessor(const_cast<ui::Event*>(&event)); | |
973 } | |
974 | |
952 //////////////////////////////////////////////////////////////////////////////// | 975 //////////////////////////////////////////////////////////////////////////////// |
953 // DesktopWindowTreeHost, public: | 976 // DesktopWindowTreeHost, public: |
954 | 977 |
955 // static | 978 // static |
956 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 979 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
957 internal::NativeWidgetDelegate* native_widget_delegate, | 980 internal::NativeWidgetDelegate* native_widget_delegate, |
958 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 981 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
959 return new DesktopWindowTreeHostWin(native_widget_delegate, | 982 return new DesktopWindowTreeHostWin(native_widget_delegate, |
960 desktop_native_widget_aura); | 983 desktop_native_widget_aura); |
961 } | 984 } |
962 | 985 |
963 } // namespace views | 986 } // namespace views |
OLD | NEW |