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 "athena/wm/split_view_controller.h" | 5 #include "athena/wm/split_view_controller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "athena/screen/public/screen_manager.h" | 9 #include "athena/screen/public/screen_manager.h" |
10 #include "athena/wm/public/window_list_provider.h" | 10 #include "athena/wm/public/window_list_provider.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 | 55 |
56 SplitViewController::~SplitViewController() { | 56 SplitViewController::~SplitViewController() { |
57 } | 57 } |
58 | 58 |
59 bool SplitViewController::IsSplitViewModeActive() const { | 59 bool SplitViewController::IsSplitViewModeActive() const { |
60 return state_ == ACTIVE; | 60 return state_ == ACTIVE; |
61 } | 61 } |
62 | 62 |
63 void SplitViewController::ActivateSplitMode(aura::Window* left, | 63 void SplitViewController::ActivateSplitMode(aura::Window* left, |
64 aura::Window* right) { | 64 aura::Window* right) { |
65 DCHECK((left && wm::IsActiveWindow(left)) || | |
66 (right && wm::IsActiveWindow(right))); | |
67 | |
sadrul
2014/09/09 14:27:28
We allow both to be NULL.
| |
65 aura::Window::Windows windows = window_list_provider_->GetWindowList(); | 68 aura::Window::Windows windows = window_list_provider_->GetWindowList(); |
66 aura::Window::Windows::reverse_iterator iter = windows.rbegin(); | 69 aura::Window::Windows::reverse_iterator iter = windows.rbegin(); |
67 if (state_ == ACTIVE) { | 70 if (state_ == ACTIVE) { |
68 if (left_window_ == right) | 71 if (left_window_ == right) |
69 left_window_ = left; | 72 left_window_ = left; |
70 if (right_window_ == left) | 73 if (right_window_ == left) |
71 right_window_ = right; | 74 right_window_ = right; |
72 | 75 |
73 if (!left) | 76 if (!left) |
74 left = left_window_; | 77 left = left_window_; |
(...skipping 13 matching lines...) Expand all Loading... | |
88 if (!right && iter != windows.rend()) { | 91 if (!right && iter != windows.rend()) { |
89 right = *iter; | 92 right = *iter; |
90 iter++; | 93 iter++; |
91 if (right == left && iter != windows.rend()) { | 94 if (right == left && iter != windows.rend()) { |
92 right = *iter; | 95 right = *iter; |
93 iter++; | 96 iter++; |
94 } | 97 } |
95 } | 98 } |
96 | 99 |
97 SetState(ACTIVE); | 100 SetState(ACTIVE); |
98 if (right_window_ != right) { | 101 right_window_ = right; |
99 right_window_ = right; | 102 left_window_ = left; |
100 container_->StackChildAtTop(right_window_); | |
101 } | |
102 if (left_window_ != left) { | |
103 left_window_ = left; | |
104 container_->StackChildAtTop(left_window_); | |
105 } | |
106 UpdateLayout(true); | 103 UpdateLayout(true); |
107 } | 104 } |
108 | 105 |
109 void SplitViewController::ReplaceWindow(aura::Window* window, | 106 void SplitViewController::ReplaceWindow(aura::Window* window, |
110 aura::Window* replace_with) { | 107 aura::Window* replace_with) { |
111 CHECK(IsSplitViewModeActive()); | 108 CHECK(IsSplitViewModeActive()); |
112 CHECK(replace_with); | 109 CHECK(replace_with); |
113 CHECK(window == left_window_ || window == right_window_); | 110 CHECK(window == left_window_ || window == right_window_); |
114 CHECK(replace_with != left_window_ && replace_with != right_window_); | 111 CHECK(replace_with != left_window_ && replace_with != right_window_); |
115 #if !defined(NDEBUG) | 112 #if !defined(NDEBUG) |
116 aura::Window::Windows windows = window_list_provider_->GetWindowList(); | 113 aura::Window::Windows windows = window_list_provider_->GetWindowList(); |
117 DCHECK(std::find(windows.begin(), windows.end(), replace_with) != | 114 DCHECK(std::find(windows.begin(), windows.end(), replace_with) != |
118 windows.end()); | 115 windows.end()); |
119 #endif | 116 #endif |
120 | 117 |
121 if (window == left_window_) | 118 if (window == left_window_) |
122 left_window_ = replace_with; | 119 left_window_ = replace_with; |
123 else | 120 else |
124 right_window_ = replace_with; | 121 right_window_ = replace_with; |
125 wm::ActivateWindow(replace_with); | |
126 UpdateLayout(false); | 122 UpdateLayout(false); |
127 window->SetTransform(gfx::Transform()); | 123 window->SetTransform(gfx::Transform()); |
128 window->Hide(); | 124 window->Hide(); |
129 } | 125 } |
130 | 126 |
131 void SplitViewController::DeactivateSplitMode() { | 127 void SplitViewController::DeactivateSplitMode() { |
132 CHECK_EQ(ACTIVE, state_); | 128 CHECK_EQ(ACTIVE, state_); |
133 SetState(INACTIVE); | 129 SetState(INACTIVE); |
134 UpdateLayout(false); | 130 UpdateLayout(false); |
135 left_window_ = right_window_ = NULL; | 131 left_window_ = right_window_ = NULL; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 if (!wm::IsActiveWindow(left_window_)) | 164 if (!wm::IsActiveWindow(left_window_)) |
169 left_window_->Hide(); | 165 left_window_->Hide(); |
170 if (!wm::IsActiveWindow(right_window_)) | 166 if (!wm::IsActiveWindow(right_window_)) |
171 right_window_->Hide(); | 167 right_window_->Hide(); |
172 SetWindowTransforms(gfx::Transform(), gfx::Transform(), false); | 168 SetWindowTransforms(gfx::Transform(), gfx::Transform(), false); |
173 return; | 169 return; |
174 } | 170 } |
175 | 171 |
176 left_window_->Show(); | 172 left_window_->Show(); |
177 right_window_->Show(); | 173 right_window_->Show(); |
174 DCHECK(wm::IsActiveWindow(left_window_) || wm::IsActiveWindow(right_window_)); | |
175 if (wm::IsActiveWindow(left_window_)) | |
176 container_->StackChildBelow(right_window_, left_window_); | |
177 else | |
178 container_->StackChildBelow(left_window_, right_window_); | |
sadrul
2014/09/09 14:27:27
Can the z-ordering issue described in the bug be f
pkotwicz
2014/09/09 17:06:28
The remainder of the change is to ensure that eith
sadrul
2014/09/11 05:45:48
We are still activating windows from various place
| |
179 | |
178 if (state_ == ACTIVE) { | 180 if (state_ == ACTIVE) { |
179 if (animate) { | 181 if (animate) { |
180 gfx::Transform left_transform = GetTargetTransformForBoundsAnimation( | 182 gfx::Transform left_transform = GetTargetTransformForBoundsAnimation( |
181 left_window_->bounds(), GetLeftTargetBounds()); | 183 left_window_->bounds(), GetLeftTargetBounds()); |
182 gfx::Transform right_transform = GetTargetTransformForBoundsAnimation( | 184 gfx::Transform right_transform = GetTargetTransformForBoundsAnimation( |
183 right_window_->bounds(), GetRightTargetBounds()); | 185 right_window_->bounds(), GetRightTargetBounds()); |
184 SetWindowTransforms(left_transform, right_transform, true); | 186 SetWindowTransforms(left_transform, right_transform, true); |
185 } else { | 187 } else { |
186 left_window_->SetBounds(GetLeftTargetBounds()); | 188 left_window_->SetBounds(GetLeftTargetBounds()); |
187 right_window_->SetBounds(GetRightTargetBounds()); | 189 right_window_->SetBounds(GetRightTargetBounds()); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 bool SplitViewController::CanScroll() { | 314 bool SplitViewController::CanScroll() { |
313 // TODO(mfomitchev): return false in full screen. | 315 // TODO(mfomitchev): return false in full screen. |
314 bool result = (!IsSplitViewModeActive() && | 316 bool result = (!IsSplitViewModeActive() && |
315 window_list_provider_->GetWindowList().size() >= 2 && | 317 window_list_provider_->GetWindowList().size() >= 2 && |
316 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()-> | 318 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()-> |
317 GetDisplayNearestWindow(container_).rotation())); | 319 GetDisplayNearestWindow(container_).rotation())); |
318 return result; | 320 return result; |
319 } | 321 } |
320 | 322 |
321 } // namespace athena | 323 } // namespace athena |
OLD | NEW |