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 "ash/wm/window_util.h" | 5 #include "ash/wm/window_util.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
10 #include "ash/public/cpp/config.h" | 10 #include "ash/public/cpp/config.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "ui/aura/mus/window_tree_client.h" | 24 #include "ui/aura/mus/window_tree_client.h" |
25 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
26 #include "ui/aura/window_delegate.h" | 26 #include "ui/aura/window_delegate.h" |
27 #include "ui/aura/window_event_dispatcher.h" | 27 #include "ui/aura/window_event_dispatcher.h" |
28 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
29 #include "ui/compositor/dip_util.h" | 29 #include "ui/compositor/dip_util.h" |
30 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
31 #include "ui/gfx/geometry/size.h" | 31 #include "ui/gfx/geometry/size.h" |
32 #include "ui/views/view.h" | 32 #include "ui/views/view.h" |
33 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
| 34 #include "ui/wm/core/easy_resize_window_targeter.h" |
34 #include "ui/wm/core/window_util.h" | 35 #include "ui/wm/core/window_util.h" |
35 #include "ui/wm/public/activation_client.h" | 36 #include "ui/wm/public/activation_client.h" |
36 | 37 |
37 namespace ash { | 38 namespace ash { |
38 namespace wm { | 39 namespace wm { |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 // Moves |window| to the given |root| window's corresponding container, if it is | 43 // Moves |window| to the given |root| window's corresponding container, if it is |
43 // not already in the same root window. Returns true if |window| was moved. | 44 // not already in the same root window. Returns true if |window| was moved. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 << container->GetName(); | 139 << container->GetName(); |
139 container->SetProperty(kSnapChildrenToPixelBoundary, true); | 140 container->SetProperty(kSnapChildrenToPixelBoundary, true); |
140 } | 141 } |
141 | 142 |
142 int GetNonClientComponent(aura::Window* window, const gfx::Point& location) { | 143 int GetNonClientComponent(aura::Window* window, const gfx::Point& location) { |
143 return window->delegate() | 144 return window->delegate() |
144 ? window->delegate()->GetNonClientComponent(location) | 145 ? window->delegate()->GetNonClientComponent(location) |
145 : HTNOWHERE; | 146 : HTNOWHERE; |
146 } | 147 } |
147 | 148 |
| 149 void SetChildrenUseExtendedHitRegionForWindow(aura::Window* window) { |
| 150 window->SetProperty(kChildrenUseExtendedHitRegion, true); |
| 151 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, |
| 152 -kResizeOutsideBoundsSize, |
| 153 -kResizeOutsideBoundsSize); |
| 154 gfx::Insets touch_extend = |
| 155 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); |
| 156 // TODO: EasyResizeWindowTargeter makes it so children get events outside |
| 157 // their bounds. This only works in mash when mash is providing the non-client |
| 158 // frame. Mus needs to support an api for the WindowManager that enables |
| 159 // events to be dispatched to windows outside the windows bounds that this |
| 160 // function calls into. http://crbug.com/679056. |
| 161 window->SetEventTargeter(base::MakeUnique<::wm::EasyResizeWindowTargeter>( |
| 162 window, mouse_extend, touch_extend)); |
| 163 } |
| 164 |
| 165 bool ShouldUseExtendedHitRegionForWindow(const aura::Window* window) { |
| 166 const aura::Window* parent = window->parent(); |
| 167 return parent && parent->GetProperty(kChildrenUseExtendedHitRegion); |
| 168 } |
| 169 |
148 void CloseWidgetForWindow(aura::Window* window) { | 170 void CloseWidgetForWindow(aura::Window* window) { |
149 if (Shell::GetAshConfig() == Config::MASH && | 171 if (Shell::GetAshConfig() == Config::MASH && |
150 window->GetProperty(kWidgetCreationTypeKey) == | 172 window->GetProperty(kWidgetCreationTypeKey) == |
151 WidgetCreationType::FOR_CLIENT) { | 173 WidgetCreationType::FOR_CLIENT) { |
152 // NOTE: in the FOR_CLIENT case there is not necessarily a widget associated | 174 // NOTE: in the FOR_CLIENT case there is not necessarily a widget associated |
153 // with the window. Mash only creates widgets for top level windows if mash | 175 // with the window. Mash only creates widgets for top level windows if mash |
154 // renders the non-client frame. | 176 // renders the non-client frame. |
155 DCHECK(Shell::window_manager_client()); | 177 DCHECK(Shell::window_manager_client()); |
156 Shell::window_manager_client()->RequestClose(window); | 178 Shell::window_manager_client()->RequestClose(window); |
157 return; | 179 return; |
(...skipping 12 matching lines...) Expand all Loading... |
170 window->AddPreTargetHandler(handler); | 192 window->AddPreTargetHandler(handler); |
171 } | 193 } |
172 | 194 |
173 void RemoveLimitedPreTargetHandlerForWindow(ui::EventHandler* handler, | 195 void RemoveLimitedPreTargetHandlerForWindow(ui::EventHandler* handler, |
174 aura::Window* window) { | 196 aura::Window* window) { |
175 window->RemovePreTargetHandler(handler); | 197 window->RemovePreTargetHandler(handler); |
176 } | 198 } |
177 | 199 |
178 } // namespace wm | 200 } // namespace wm |
179 } // namespace ash | 201 } // namespace ash |
OLD | NEW |