| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 DesktopWindowTreeHostWin::~DesktopWindowTreeHostWin() { | 92 DesktopWindowTreeHostWin::~DesktopWindowTreeHostWin() { |
| 93 // 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. |
| 94 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed( | 94 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed( |
| 95 dispatcher_); | 95 dispatcher_); |
| 96 DestroyDispatcher(); | 96 DestroyDispatcher(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // static | 99 // static |
| 100 aura::Window* DesktopWindowTreeHostWin::GetContentWindowForHWND(HWND hwnd) { | 100 aura::Window* DesktopWindowTreeHostWin::GetContentWindowForHWND(HWND hwnd) { |
| 101 aura::WindowEventDispatcher* dispatcher = | 101 aura::WindowTreeHost* host = |
| 102 aura::WindowEventDispatcher::GetForAcceleratedWidget(hwnd); | 102 aura::WindowTreeHost::GetForAcceleratedWidget(hwnd); |
| 103 return dispatcher ? | 103 return host ? host->window()->GetProperty(kContentWindowForRootWindow) : NULL; |
| 104 dispatcher->window()->GetProperty(kContentWindowForRootWindow) : NULL; | |
| 105 } | 104 } |
| 106 | 105 |
| 107 // static | 106 // static |
| 108 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { | 107 ui::NativeTheme* DesktopWindowTreeHost::GetNativeTheme(aura::Window* window) { |
| 109 // Use NativeThemeWin for windows shown on the desktop, those not on the | 108 // Use NativeThemeWin for windows shown on the desktop, those not on the |
| 110 // desktop come from Ash and get NativeThemeAura. | 109 // desktop come from Ash and get NativeThemeAura. |
| 111 aura::WindowEventDispatcher* dispatcher = | 110 aura::WindowTreeHost* host = window ? window->GetHost() : NULL; |
| 112 window ? window->GetDispatcher() : NULL; | 111 if (host) { |
| 113 if (dispatcher) { | 112 HWND host_hwnd = host->GetAcceleratedWidget(); |
| 114 HWND host_hwnd = dispatcher->host()->GetAcceleratedWidget(); | |
| 115 if (host_hwnd && | 113 if (host_hwnd && |
| 116 DesktopWindowTreeHostWin::GetContentWindowForHWND(host_hwnd)) { | 114 DesktopWindowTreeHostWin::GetContentWindowForHWND(host_hwnd)) { |
| 117 return ui::NativeThemeWin::instance(); | 115 return ui::NativeThemeWin::instance(); |
| 118 } | 116 } |
| 119 } | 117 } |
| 120 return ui::NativeThemeAura::instance(); | 118 return ui::NativeThemeAura::instance(); |
| 121 } | 119 } |
| 122 | 120 |
| 123 //////////////////////////////////////////////////////////////////////////////// | 121 //////////////////////////////////////////////////////////////////////////////// |
| 124 // DesktopWindowTreeHostWin, DesktopWindowTreeHost implementation: | 122 // DesktopWindowTreeHostWin, DesktopWindowTreeHost implementation: |
| 125 | 123 |
| 126 void DesktopWindowTreeHostWin::Init(aura::Window* content_window, | 124 void DesktopWindowTreeHostWin::Init(aura::Window* content_window, |
| 127 const Widget::InitParams& params) { | 125 const Widget::InitParams& params) { |
| 128 // TODO(beng): SetInitParams(). | 126 // TODO(beng): SetInitParams(). |
| 129 content_window_ = content_window; | 127 content_window_ = content_window; |
| 130 | 128 |
| 131 aura::client::SetAnimationHost(content_window_, this); | 129 aura::client::SetAnimationHost(content_window_, this); |
| 132 | 130 |
| 133 ConfigureWindowStyles(message_handler_.get(), params, | 131 ConfigureWindowStyles(message_handler_.get(), params, |
| 134 GetWidget()->widget_delegate(), | 132 GetWidget()->widget_delegate(), |
| 135 native_widget_delegate_); | 133 native_widget_delegate_); |
| 136 | 134 |
| 137 HWND parent_hwnd = NULL; | 135 HWND parent_hwnd = NULL; |
| 138 if (params.parent && params.parent->GetDispatcher()) { | 136 if (params.parent && params.parent->GetHost()) |
| 139 parent_hwnd = | 137 parent_hwnd = params.parent->GetHost()->GetAcceleratedWidget(); |
| 140 params.parent->GetDispatcher()->host()->GetAcceleratedWidget(); | |
| 141 } | |
| 142 | 138 |
| 143 message_handler_->set_remove_standard_frame(params.remove_standard_frame); | 139 message_handler_->set_remove_standard_frame(params.remove_standard_frame); |
| 144 | 140 |
| 145 has_non_client_view_ = Widget::RequiresNonClientView(params.type); | 141 has_non_client_view_ = Widget::RequiresNonClientView(params.type); |
| 146 | 142 |
| 147 gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(params.bounds); | 143 gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(params.bounds); |
| 148 message_handler_->Init(parent_hwnd, pixel_bounds); | 144 message_handler_->Init(parent_hwnd, pixel_bounds); |
| 149 if (params.type == Widget::InitParams::TYPE_MENU) { | 145 if (params.type == Widget::InitParams::TYPE_MENU) { |
| 150 ::SetProp(GetAcceleratedWidget(), | 146 ::SetProp(GetAcceleratedWidget(), |
| 151 kForceSoftwareCompositor, | 147 kForceSoftwareCompositor, |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 | 869 |
| 874 void DesktopWindowTreeHostWin::HandleTouchEvent( | 870 void DesktopWindowTreeHostWin::HandleTouchEvent( |
| 875 const ui::TouchEvent& event) { | 871 const ui::TouchEvent& event) { |
| 876 // HWNDMessageHandler asynchronously processes touch events. Because of this | 872 // HWNDMessageHandler asynchronously processes touch events. Because of this |
| 877 // it's possible for the aura::WindowEventDispatcher to have been destroyed | 873 // it's possible for the aura::WindowEventDispatcher to have been destroyed |
| 878 // by the time we attempt to process them. | 874 // by the time we attempt to process them. |
| 879 if (!GetWidget()->GetNativeView()) | 875 if (!GetWidget()->GetNativeView()) |
| 880 return; | 876 return; |
| 881 | 877 |
| 882 // Currently we assume the window that has capture gets touch events too. | 878 // Currently we assume the window that has capture gets touch events too. |
| 883 aura::WindowEventDispatcher* dispatcher = | 879 aura::WindowTreeHost* host = |
| 884 aura::WindowEventDispatcher::GetForAcceleratedWidget(GetCapture()); | 880 aura::WindowTreeHost::GetForAcceleratedWidget(GetCapture()); |
| 885 if (dispatcher) { | 881 if (host) { |
| 886 DesktopWindowTreeHostWin* target = | 882 DesktopWindowTreeHostWin* target = |
| 887 dispatcher->window()->GetProperty(kDesktopWindowTreeHostKey); | 883 host->window()->GetProperty(kDesktopWindowTreeHostKey); |
| 888 if (target && target->HasCapture() && target != this) { | 884 if (target && target->HasCapture() && target != this) { |
| 889 POINT target_location(event.location().ToPOINT()); | 885 POINT target_location(event.location().ToPOINT()); |
| 890 ClientToScreen(GetHWND(), &target_location); | 886 ClientToScreen(GetHWND(), &target_location); |
| 891 ScreenToClient(target->GetHWND(), &target_location); | 887 ScreenToClient(target->GetHWND(), &target_location); |
| 892 ui::TouchEvent target_event(event, static_cast<View*>(NULL), | 888 ui::TouchEvent target_event(event, static_cast<View*>(NULL), |
| 893 static_cast<View*>(NULL)); | 889 static_cast<View*>(NULL)); |
| 894 target_event.set_location(gfx::Point(target_location)); | 890 target_event.set_location(gfx::Point(target_location)); |
| 895 target_event.set_root_location(target_event.location()); | 891 target_event.set_root_location(target_event.location()); |
| 896 target->SendEventToProcessor(&target_event); | 892 target->SendEventToProcessor(&target_event); |
| 897 return; | 893 return; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 | 1010 |
| 1015 // static | 1011 // static |
| 1016 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 1012 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
| 1017 internal::NativeWidgetDelegate* native_widget_delegate, | 1013 internal::NativeWidgetDelegate* native_widget_delegate, |
| 1018 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 1014 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
| 1019 return new DesktopWindowTreeHostWin(native_widget_delegate, | 1015 return new DesktopWindowTreeHostWin(native_widget_delegate, |
| 1020 desktop_native_widget_aura); | 1016 desktop_native_widget_aura); |
| 1021 } | 1017 } |
| 1022 | 1018 |
| 1023 } // namespace views | 1019 } // namespace views |
| OLD | NEW |