OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/default_state.h" | 5 #include "ash/common/wm/default_state.h" |
6 | 6 |
7 #include "ash/common/shell_window_ids.h" | 7 #include "ash/common/shell_window_ids.h" |
8 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 8 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
9 #include "ash/common/wm/window_animation_types.h" | 9 #include "ash/common/wm/window_animation_types.h" |
10 #include "ash/common/wm/window_parenting_utils.h" | 10 #include "ash/common/wm/window_parenting_utils.h" |
11 #include "ash/common/wm/window_positioning_utils.h" | 11 #include "ash/common/wm/window_positioning_utils.h" |
12 #include "ash/common/wm/window_state.h" | 12 #include "ash/common/wm/window_state.h" |
13 #include "ash/common/wm/window_state_delegate.h" | 13 #include "ash/common/wm/window_state_delegate.h" |
14 #include "ash/common/wm/window_state_util.h" | 14 #include "ash/common/wm/window_state_util.h" |
15 #include "ash/common/wm/wm_event.h" | 15 #include "ash/common/wm/wm_event.h" |
16 #include "ash/common/wm/wm_globals.h" | |
17 #include "ash/common/wm/wm_root_window_controller.h" | |
18 #include "ash/common/wm/wm_screen_util.h" | 16 #include "ash/common/wm/wm_screen_util.h" |
19 #include "ash/common/wm/wm_window.h" | 17 #include "ash/common/wm_root_window_controller.h" |
18 #include "ash/common/wm_shell.h" | |
19 #include "ash/common/wm_window.h" | |
20 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
21 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" |
22 | 22 |
23 namespace ash { | 23 namespace ash { |
24 namespace wm { | 24 namespace wm { |
25 namespace { | 25 namespace { |
26 | 26 |
27 // This specifies how much percent (30%) of a window rect | 27 // This specifies how much percent (30%) of a window rect |
28 // must be visible when the window is added to the workspace. | 28 // must be visible when the window is added to the workspace. |
29 const float kMinimumPercentOnScreenArea = 0.3f; | 29 const float kMinimumPercentOnScreenArea = 0.3f; |
(...skipping 18 matching lines...) Expand all Loading... | |
48 // display it should be restored, so this is best guess. | 48 // display it should be restored, so this is best guess. |
49 // TODO(oshima): Restore information should contain the | 49 // TODO(oshima): Restore information should contain the |
50 // work area information like WindowResizer does for the | 50 // work area information like WindowResizer does for the |
51 // last window location. | 51 // last window location. |
52 gfx::Rect display_area = | 52 gfx::Rect display_area = |
53 window_state->window()->GetDisplayNearestWindow().bounds(); | 53 window_state->window()->GetDisplayNearestWindow().bounds(); |
54 | 54 |
55 if (!display_area.Intersects(restore_bounds)) { | 55 if (!display_area.Intersects(restore_bounds)) { |
56 const display::Display& display = | 56 const display::Display& display = |
57 display::Screen::GetScreen()->GetDisplayMatching(restore_bounds); | 57 display::Screen::GetScreen()->GetDisplayMatching(restore_bounds); |
58 WmGlobals* globals = window_state->window()->GetGlobals(); | 58 WmShell* shell = window_state->window()->GetShell(); |
James Cook
2016/06/03 20:10:47
Thanks for fixing local variable names.
| |
59 WmWindow* new_root = globals->GetRootWindowForDisplayId(display.id()); | 59 WmWindow* new_root = shell->GetRootWindowForDisplayId(display.id()); |
60 if (new_root != window_state->window()->GetRootWindow()) { | 60 if (new_root != window_state->window()->GetRootWindow()) { |
61 WmWindow* new_container = new_root->GetChildByShellWindowId( | 61 WmWindow* new_container = new_root->GetChildByShellWindowId( |
62 window_state->window()->GetParent()->GetShellWindowId()); | 62 window_state->window()->GetParent()->GetShellWindowId()); |
63 new_container->AddChild(window_state->window()); | 63 new_container->AddChild(window_state->window()); |
64 } | 64 } |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 DockedWindowLayoutManager* GetDockedWindowLayoutManager(WmGlobals* globals) { | 68 DockedWindowLayoutManager* GetDockedWindowLayoutManager(WmShell* shell) { |
69 return DockedWindowLayoutManager::Get(globals->GetActiveWindow()); | 69 return DockedWindowLayoutManager::Get(shell->GetActiveWindow()); |
70 } | 70 } |
71 | 71 |
72 class ScopedPreferredAlignmentResetter { | 72 class ScopedPreferredAlignmentResetter { |
73 public: | 73 public: |
74 ScopedPreferredAlignmentResetter(DockedAlignment dock_alignment, | 74 ScopedPreferredAlignmentResetter(DockedAlignment dock_alignment, |
75 DockedWindowLayoutManager* dock_layout) | 75 DockedWindowLayoutManager* dock_layout) |
76 : docked_window_layout_manager_(dock_layout) { | 76 : docked_window_layout_manager_(dock_layout) { |
77 docked_window_layout_manager_->set_preferred_alignment(dock_alignment); | 77 docked_window_layout_manager_->set_preferred_alignment(dock_alignment); |
78 } | 78 } |
79 ~ScopedPreferredAlignmentResetter() { | 79 ~ScopedPreferredAlignmentResetter() { |
(...skipping 20 matching lines...) Expand all Loading... | |
100 } | 100 } |
101 | 101 |
102 private: | 102 private: |
103 DockedWindowLayoutManager* docked_window_layout_manager_; | 103 DockedWindowLayoutManager* docked_window_layout_manager_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(ScopedDockedLayoutEventSourceResetter); | 105 DISALLOW_COPY_AND_ASSIGN(ScopedDockedLayoutEventSourceResetter); |
106 }; | 106 }; |
107 | 107 |
108 void CycleSnapDock(WindowState* window_state, WMEventType event) { | 108 void CycleSnapDock(WindowState* window_state, WMEventType event) { |
109 DockedWindowLayoutManager* dock_layout = | 109 DockedWindowLayoutManager* dock_layout = |
110 GetDockedWindowLayoutManager(window_state->window()->GetGlobals()); | 110 GetDockedWindowLayoutManager(window_state->window()->GetShell()); |
111 wm::WindowStateType desired_snap_state = | 111 wm::WindowStateType desired_snap_state = |
112 event == WM_EVENT_CYCLE_SNAP_DOCK_LEFT | 112 event == WM_EVENT_CYCLE_SNAP_DOCK_LEFT |
113 ? wm::WINDOW_STATE_TYPE_LEFT_SNAPPED | 113 ? wm::WINDOW_STATE_TYPE_LEFT_SNAPPED |
114 : wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED; | 114 : wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED; |
115 DockedAlignment desired_dock_alignment = | 115 DockedAlignment desired_dock_alignment = |
116 event == WM_EVENT_CYCLE_SNAP_DOCK_LEFT ? DOCKED_ALIGNMENT_LEFT | 116 event == WM_EVENT_CYCLE_SNAP_DOCK_LEFT ? DOCKED_ALIGNMENT_LEFT |
117 : DOCKED_ALIGNMENT_RIGHT; | 117 : DOCKED_ALIGNMENT_RIGHT; |
118 DockedAlignment current_dock_alignment = | 118 DockedAlignment current_dock_alignment = |
119 dock_layout ? dock_layout->CalculateAlignment() : DOCKED_ALIGNMENT_NONE; | 119 dock_layout ? dock_layout->CalculateAlignment() : DOCKED_ALIGNMENT_NONE; |
120 | 120 |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); | 727 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); |
728 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); | 728 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); |
729 window_state->SetBoundsDirectAnimated(center_in_parent); | 729 window_state->SetBoundsDirectAnimated(center_in_parent); |
730 } | 730 } |
731 // Centering window is treated as if a user moved and resized the window. | 731 // Centering window is treated as if a user moved and resized the window. |
732 window_state->set_bounds_changed_by_user(true); | 732 window_state->set_bounds_changed_by_user(true); |
733 } | 733 } |
734 | 734 |
735 } // namespace wm | 735 } // namespace wm |
736 } // namespace ash | 736 } // namespace ash |
OLD | NEW |