Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: ash/common/wm_root_window_controller.cc

Issue 2624613002: Promotes common functions to WmRootWindowController (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/wm_root_window_controller.h ('k') | ash/mus/bridge/wm_root_window_controller_mus.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/common/wm_root_window_controller.h" 5 #include "ash/common/wm_root_window_controller.h"
6 6
7 #include "ash/aura/wm_window_aura.h"
7 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/shelf/shelf_layout_manager.h" 9 #include "ash/common/shelf/shelf_layout_manager.h"
9 #include "ash/common/shelf/shelf_widget.h" 10 #include "ash/common/shelf/shelf_widget.h"
10 #include "ash/common/shelf/wm_shelf.h" 11 #include "ash/common/shelf/wm_shelf.h"
11 #include "ash/common/shell_delegate.h" 12 #include "ash/common/shell_delegate.h"
12 #include "ash/common/system/status_area_widget.h" 13 #include "ash/common/system/status_area_widget.h"
13 #include "ash/common/wallpaper/wallpaper_delegate.h" 14 #include "ash/common/wallpaper/wallpaper_delegate.h"
14 #include "ash/common/wallpaper/wallpaper_widget_controller.h" 15 #include "ash/common/wallpaper/wallpaper_widget_controller.h"
15 #include "ash/common/wm/always_on_top_controller.h" 16 #include "ash/common/wm/always_on_top_controller.h"
16 #include "ash/common/wm/container_finder.h" 17 #include "ash/common/wm/container_finder.h"
17 #include "ash/common/wm/dock/docked_window_layout_manager.h" 18 #include "ash/common/wm/dock/docked_window_layout_manager.h"
18 #include "ash/common/wm/lock_layout_manager.h" 19 #include "ash/common/wm/lock_layout_manager.h"
19 #include "ash/common/wm/panels/panel_layout_manager.h" 20 #include "ash/common/wm/panels/panel_layout_manager.h"
20 #include "ash/common/wm/root_window_layout_manager.h" 21 #include "ash/common/wm/root_window_layout_manager.h"
21 #include "ash/common/wm/system_modal_container_layout_manager.h" 22 #include "ash/common/wm/system_modal_container_layout_manager.h"
22 #include "ash/common/wm/window_state.h" 23 #include "ash/common/wm/window_state.h"
23 #include "ash/common/wm/wm_snap_to_pixel_layout_manager.h" 24 #include "ash/common/wm/wm_snap_to_pixel_layout_manager.h"
24 #include "ash/common/wm/workspace/workspace_layout_manager.h" 25 #include "ash/common/wm/workspace/workspace_layout_manager.h"
25 #include "ash/common/wm/workspace_controller.h" 26 #include "ash/common/wm/workspace_controller.h"
26 #include "ash/common/wm_shell.h" 27 #include "ash/common/wm_shell.h"
27 #include "ash/common/wm_window.h" 28 #include "ash/common/wm_window.h"
28 #include "ash/public/cpp/shell_window_ids.h" 29 #include "ash/public/cpp/shell_window_ids.h"
29 #include "base/memory/ptr_util.h" 30 #include "base/memory/ptr_util.h"
31 #include "ui/aura/window.h"
32 #include "ui/aura/window_event_dispatcher.h"
33 #include "ui/aura/window_tree_host.h"
30 #include "ui/base/models/menu_model.h" 34 #include "ui/base/models/menu_model.h"
35 #include "ui/events/event_targeter.h"
36 #include "ui/events/event_utils.h"
31 #include "ui/views/controls/menu/menu_model_adapter.h" 37 #include "ui/views/controls/menu/menu_model_adapter.h"
32 #include "ui/views/controls/menu/menu_runner.h" 38 #include "ui/views/controls/menu/menu_runner.h"
33 39
34 namespace ash { 40 namespace ash {
35 namespace { 41 namespace {
36 42
37 // Scales |value| that is originally between 0 and |src_max| to be between 43 // Scales |value| that is originally between 0 and |src_max| to be between
38 // 0 and |dst_max|. 44 // 0 and |dst_max|.
39 float ToRelativeValue(int value, int src_max, int dst_max) { 45 float ToRelativeValue(int value, int src_max, int dst_max) {
40 return static_cast<float>(value) / static_cast<float>(src_max) * dst_max; 46 return static_cast<float>(value) / static_cast<float>(src_max) * dst_max;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 229 }
224 230
225 WmWindow* WmRootWindowController::GetContainer(int container_id) { 231 WmWindow* WmRootWindowController::GetContainer(int container_id) {
226 return root_->GetChildByShellWindowId(container_id); 232 return root_->GetChildByShellWindowId(container_id);
227 } 233 }
228 234
229 const WmWindow* WmRootWindowController::GetContainer(int container_id) const { 235 const WmWindow* WmRootWindowController::GetContainer(int container_id) const {
230 return root_->GetChildByShellWindowId(container_id); 236 return root_->GetChildByShellWindowId(container_id);
231 } 237 }
232 238
239 void WmRootWindowController::ConfigureWidgetInitParamsForContainer(
240 views::Widget* widget,
241 int shell_container_id,
242 views::Widget::InitParams* init_params) {
243 init_params->parent = WmWindowAura::GetAuraWindow(
244 GetWindow()->GetChildByShellWindowId(shell_container_id));
245 }
246
247 gfx::Point WmRootWindowController::GetLastMouseLocationInRoot() {
msw 2017/01/09 23:26:48 nit: match function decl order
sky 2017/01/09 23:39:11 Done.
248 return WmWindowAura::GetAuraWindow(GetWindow())
249 ->GetHost()
250 ->dispatcher()
251 ->GetLastMouseLocationInRoot();
252 }
253
254 WmWindow* WmRootWindowController::FindEventTarget(
255 const gfx::Point& location_in_screen) {
256 gfx::Point location_in_root =
257 GetWindow()->ConvertPointFromScreen(location_in_screen);
258 aura::Window* root = WmWindowAura::GetAuraWindow(GetWindow());
259 ui::MouseEvent test_event(ui::ET_MOUSE_MOVED, location_in_root,
260 location_in_root, ui::EventTimeForNow(),
261 ui::EF_NONE, ui::EF_NONE);
262 ui::EventTarget* event_handler = static_cast<ui::EventTarget*>(root)
263 ->GetEventTargeter()
264 ->FindTargetForEvent(root, &test_event);
265 return WmWindowAura::Get(static_cast<aura::Window*>(event_handler));
266 }
267
233 void WmRootWindowController::ShowContextMenu( 268 void WmRootWindowController::ShowContextMenu(
234 const gfx::Point& location_in_screen, 269 const gfx::Point& location_in_screen,
235 ui::MenuSourceType source_type) { 270 ui::MenuSourceType source_type) {
236 ShellDelegate* delegate = WmShell::Get()->delegate(); 271 ShellDelegate* delegate = WmShell::Get()->delegate();
237 DCHECK(delegate); 272 DCHECK(delegate);
238 menu_model_.reset(delegate->CreateContextMenu(GetShelf(), nullptr)); 273 menu_model_.reset(delegate->CreateContextMenu(GetShelf(), nullptr));
239 if (!menu_model_) 274 if (!menu_model_)
240 return; 275 return;
241 276
242 menu_model_adapter_.reset(new views::MenuModelAdapter( 277 menu_model_adapter_.reset(new views::MenuModelAdapter(
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 } 618 }
584 619
585 void WmRootWindowController::OnMenuClosed() { 620 void WmRootWindowController::OnMenuClosed() {
586 menu_runner_.reset(); 621 menu_runner_.reset();
587 menu_model_adapter_.reset(); 622 menu_model_adapter_.reset();
588 menu_model_.reset(); 623 menu_model_.reset();
589 GetShelf()->UpdateVisibilityState(); 624 GetShelf()->UpdateVisibilityState();
590 } 625 }
591 626
592 } // namespace ash 627 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm_root_window_controller.h ('k') | ash/mus/bridge/wm_root_window_controller_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698