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 "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 26 matching lines...) Expand all Loading... |
37 #include "ui/views/widget/widget_delegate.h" | 37 #include "ui/views/widget/widget_delegate.h" |
38 #include "ui/views/widget/widget_hwnd_utils.h" | 38 #include "ui/views/widget/widget_hwnd_utils.h" |
39 #include "ui/views/win/fullscreen_handler.h" | 39 #include "ui/views/win/fullscreen_handler.h" |
40 #include "ui/views/win/hwnd_message_handler.h" | 40 #include "ui/views/win/hwnd_message_handler.h" |
41 #include "ui/views/window/native_frame_view.h" | 41 #include "ui/views/window/native_frame_view.h" |
42 | 42 |
43 namespace views { | 43 namespace views { |
44 | 44 |
45 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kContentWindowForRootWindow, NULL); | 45 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kContentWindowForRootWindow, NULL); |
46 | 46 |
| 47 // Identifies the DesktopRootWindowHostWin associated with the RootWindow. |
| 48 DEFINE_WINDOW_PROPERTY_KEY(DesktopRootWindowHostWin*, kDesktopRootWindowHostKey, |
| 49 NULL); |
| 50 |
47 //////////////////////////////////////////////////////////////////////////////// | 51 //////////////////////////////////////////////////////////////////////////////// |
48 // DesktopRootWindowHostWin, public: | 52 // DesktopRootWindowHostWin, public: |
49 | 53 |
50 DesktopRootWindowHostWin::DesktopRootWindowHostWin( | 54 DesktopRootWindowHostWin::DesktopRootWindowHostWin( |
51 internal::NativeWidgetDelegate* native_widget_delegate, | 55 internal::NativeWidgetDelegate* native_widget_delegate, |
52 DesktopNativeWidgetAura* desktop_native_widget_aura) | 56 DesktopNativeWidgetAura* desktop_native_widget_aura) |
53 : root_window_(NULL), | 57 : root_window_(NULL), |
54 message_handler_(new HWNDMessageHandler(this)), | 58 message_handler_(new HWNDMessageHandler(this)), |
55 native_widget_delegate_(native_widget_delegate), | 59 native_widget_delegate_(native_widget_delegate), |
56 desktop_native_widget_aura_(desktop_native_widget_aura), | 60 desktop_native_widget_aura_(desktop_native_widget_aura), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 rw_create_params->use_software_renderer = | 126 rw_create_params->use_software_renderer = |
123 params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW; | 127 params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW; |
124 } | 128 } |
125 | 129 |
126 void DesktopRootWindowHostWin::OnRootWindowCreated( | 130 void DesktopRootWindowHostWin::OnRootWindowCreated( |
127 aura::RootWindow* root, | 131 aura::RootWindow* root, |
128 const Widget::InitParams& params) { | 132 const Widget::InitParams& params) { |
129 root_window_ = root; | 133 root_window_ = root; |
130 | 134 |
131 root_window_->SetProperty(kContentWindowForRootWindow, content_window_); | 135 root_window_->SetProperty(kContentWindowForRootWindow, content_window_); |
| 136 root_window_->SetProperty(kDesktopRootWindowHostKey, this); |
132 | 137 |
133 should_animate_window_close_ = | 138 should_animate_window_close_ = |
134 content_window_->type() != aura::client::WINDOW_TYPE_NORMAL && | 139 content_window_->type() != aura::client::WINDOW_TYPE_NORMAL && |
135 !views::corewm::WindowAnimationsDisabled(content_window_); | 140 !views::corewm::WindowAnimationsDisabled(content_window_); |
136 | 141 |
137 root_window_->compositor()->SetHostHasTransparentBackground(true); | 142 root_window_->compositor()->SetHostHasTransparentBackground(true); |
138 root_window_->SetTransparent(true); | 143 root_window_->SetTransparent(true); |
139 } | 144 } |
140 | 145 |
141 scoped_ptr<corewm::Tooltip> DesktopRootWindowHostWin::CreateTooltip() { | 146 scoped_ptr<corewm::Tooltip> DesktopRootWindowHostWin::CreateTooltip() { |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 OnHostKeyEvent(duplicate_event.get()); | 776 OnHostKeyEvent(duplicate_event.get()); |
772 } | 777 } |
773 | 778 |
774 void DesktopRootWindowHostWin::HandleTouchEvent( | 779 void DesktopRootWindowHostWin::HandleTouchEvent( |
775 const ui::TouchEvent& event) { | 780 const ui::TouchEvent& event) { |
776 // HWNDMessageHandler asynchronously processes touch events. Because of this | 781 // HWNDMessageHandler asynchronously processes touch events. Because of this |
777 // it's possible for the aura::RootWindow to have been destroyed by the time | 782 // it's possible for the aura::RootWindow to have been destroyed by the time |
778 // we attempt to process them. | 783 // we attempt to process them. |
779 if (!GetWidget()->GetNativeView()) | 784 if (!GetWidget()->GetNativeView()) |
780 return; | 785 return; |
| 786 |
| 787 // Currently we assume the window that has capture gets touch events too. |
| 788 aura::RootWindow* root = |
| 789 aura::RootWindow::GetForAcceleratedWidget(GetCapture()); |
| 790 if (root) { |
| 791 DesktopRootWindowHostWin* target = |
| 792 root->GetProperty(kDesktopRootWindowHostKey); |
| 793 if (target && target->HasCapture() && target != this) { |
| 794 POINT target_location(event.location().ToPOINT()); |
| 795 ClientToScreen(GetHWND(), &target_location); |
| 796 ScreenToClient(target->GetHWND(), &target_location); |
| 797 ui::TouchEvent target_event(event, static_cast<View*>(NULL), |
| 798 static_cast<View*>(NULL)); |
| 799 target_event.set_location(gfx::Point(target_location)); |
| 800 target_event.set_root_location(target_event.location()); |
| 801 target->root_window_host_delegate_->OnHostTouchEvent(&target_event); |
| 802 return; |
| 803 } |
| 804 } |
781 root_window_host_delegate_->OnHostTouchEvent( | 805 root_window_host_delegate_->OnHostTouchEvent( |
782 const_cast<ui::TouchEvent*>(&event)); | 806 const_cast<ui::TouchEvent*>(&event)); |
783 } | 807 } |
784 | 808 |
785 bool DesktopRootWindowHostWin::HandleIMEMessage(UINT message, | 809 bool DesktopRootWindowHostWin::HandleIMEMessage(UINT message, |
786 WPARAM w_param, | 810 WPARAM w_param, |
787 LPARAM l_param, | 811 LPARAM l_param, |
788 LRESULT* result) { | 812 LRESULT* result) { |
789 MSG msg = {}; | 813 MSG msg = {}; |
790 msg.hwnd = GetHWND(); | 814 msg.hwnd = GetHWND(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 | 897 |
874 // static | 898 // static |
875 DesktopRootWindowHost* DesktopRootWindowHost::Create( | 899 DesktopRootWindowHost* DesktopRootWindowHost::Create( |
876 internal::NativeWidgetDelegate* native_widget_delegate, | 900 internal::NativeWidgetDelegate* native_widget_delegate, |
877 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 901 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
878 return new DesktopRootWindowHostWin(native_widget_delegate, | 902 return new DesktopRootWindowHostWin(native_widget_delegate, |
879 desktop_native_widget_aura); | 903 desktop_native_widget_aura); |
880 } | 904 } |
881 | 905 |
882 } // namespace views | 906 } // namespace views |
OLD | NEW |