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/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
11 #include "ash/shelf/shelf.h" | 12 #include "ash/shelf/shelf.h" |
12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
13 #include "ash/shell_port.h" | 14 #include "ash/shell_port.h" |
| 15 #include "ash/wm/widget_finder.h" |
14 #include "ash/wm/window_properties.h" | 16 #include "ash/wm/window_properties.h" |
15 #include "ash/wm/window_state.h" | 17 #include "ash/wm/window_state.h" |
16 #include "ash/wm/wm_event.h" | 18 #include "ash/wm/wm_event.h" |
17 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
18 #include "ui/aura/client/capture_client.h" | 20 #include "ui/aura/client/capture_client.h" |
19 #include "ui/aura/client/focus_client.h" | 21 #include "ui/aura/client/focus_client.h" |
| 22 #include "ui/aura/mus/window_manager_delegate.h" |
| 23 #include "ui/aura/mus/window_port_mus.h" |
| 24 #include "ui/aura/mus/window_tree_client.h" |
20 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
21 #include "ui/aura/window_delegate.h" | 26 #include "ui/aura/window_delegate.h" |
22 #include "ui/aura/window_event_dispatcher.h" | 27 #include "ui/aura/window_event_dispatcher.h" |
23 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
24 #include "ui/compositor/dip_util.h" | 29 #include "ui/compositor/dip_util.h" |
25 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
26 #include "ui/gfx/geometry/size.h" | 31 #include "ui/gfx/geometry/size.h" |
27 #include "ui/views/view.h" | 32 #include "ui/views/view.h" |
28 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
29 #include "ui/wm/core/window_util.h" | 34 #include "ui/wm/core/window_util.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 << container->GetName(); | 138 << container->GetName(); |
134 container->SetProperty(kSnapChildrenToPixelBoundary, true); | 139 container->SetProperty(kSnapChildrenToPixelBoundary, true); |
135 } | 140 } |
136 | 141 |
137 int GetNonClientComponent(aura::Window* window, const gfx::Point& location) { | 142 int GetNonClientComponent(aura::Window* window, const gfx::Point& location) { |
138 return window->delegate() | 143 return window->delegate() |
139 ? window->delegate()->GetNonClientComponent(location) | 144 ? window->delegate()->GetNonClientComponent(location) |
140 : HTNOWHERE; | 145 : HTNOWHERE; |
141 } | 146 } |
142 | 147 |
| 148 void CloseWidgetForWindow(aura::Window* window) { |
| 149 if (Shell::GetAshConfig() == Config::MASH && |
| 150 window->GetProperty(kWidgetCreationTypeKey) == |
| 151 WidgetCreationType::FOR_CLIENT) { |
| 152 // 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 |
| 154 // renders the non-client frame. |
| 155 DCHECK(Shell::window_manager_client()); |
| 156 Shell::window_manager_client()->RequestClose(window); |
| 157 return; |
| 158 } |
| 159 views::Widget* widget = GetInternalWidgetForWindow(window); |
| 160 DCHECK(widget); |
| 161 widget->Close(); |
| 162 } |
| 163 |
| 164 void AddLimitedPreTargetHandlerForWindow(ui::EventHandler* handler, |
| 165 aura::Window* window) { |
| 166 // In mus AddPreTargetHandler() only works for windows created by this client. |
| 167 DCHECK(Shell::GetAshConfig() != Config::MASH || |
| 168 Shell::window_tree_client()->WasCreatedByThisClient( |
| 169 aura::WindowMus::Get(window))); |
| 170 window->AddPreTargetHandler(handler); |
| 171 } |
| 172 |
| 173 void RemoveLimitedPreTargetHandlerForWindow(ui::EventHandler* handler, |
| 174 aura::Window* window) { |
| 175 window->RemovePreTargetHandler(handler); |
| 176 } |
| 177 |
143 } // namespace wm | 178 } // namespace wm |
144 } // namespace ash | 179 } // namespace ash |
OLD | NEW |