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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 if (!right && iter != windows.rend()) { | 91 if (!right && iter != windows.rend()) { |
92 right = *iter; | 92 right = *iter; |
93 iter++; | 93 iter++; |
94 if (right == left && iter != windows.rend()) { | 94 if (right == left && iter != windows.rend()) { |
95 right = *iter; | 95 right = *iter; |
96 iter++; | 96 iter++; |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
| 100 to_hide_.clear(); |
| 101 if (left_window_ && left_window_ != left && left_window_ != right) |
| 102 to_hide_.push_back(left_window_); |
| 103 if (right_window_ && right_window_ != left && right_window_ != right) |
| 104 to_hide_.push_back(right_window_); |
| 105 |
100 SetState(ACTIVE); | 106 SetState(ACTIVE); |
101 right_window_ = right; | 107 right_window_ = right; |
102 left_window_ = left; | 108 left_window_ = left; |
103 UpdateLayout(true); | 109 UpdateLayout(true); |
104 } | 110 } |
105 | 111 |
106 void SplitViewController::ReplaceWindow(aura::Window* window, | 112 void SplitViewController::ReplaceWindow(aura::Window* window, |
107 aura::Window* replace_with) { | 113 aura::Window* replace_with) { |
108 CHECK(IsSplitViewModeActive()); | 114 CHECK(IsSplitViewModeActive()); |
109 CHECK(replace_with); | 115 CHECK(replace_with); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return; | 156 return; |
151 | 157 |
152 state_ = state; | 158 state_ = state; |
153 ScreenManager::Get()->SetRotationLocked(state_ != INACTIVE); | 159 ScreenManager::Get()->SetRotationLocked(state_ != INACTIVE); |
154 } | 160 } |
155 | 161 |
156 void SplitViewController::UpdateLayout(bool animate) { | 162 void SplitViewController::UpdateLayout(bool animate) { |
157 CHECK(left_window_); | 163 CHECK(left_window_); |
158 CHECK(right_window_); | 164 CHECK(right_window_); |
159 | 165 |
160 // Splitview can be activated from SplitViewController::ActivateSplitMode or | 166 if (!animate) { |
161 // SplitViewController::ScrollEnd. Additionally we don't want to rotate the | 167 for (size_t i = 0; i < to_hide_.size(); ++i) |
162 // screen while engaging splitview (i.e. state_ == SCROLLING). | 168 to_hide_[i]->Hide(); |
163 if (state_ == INACTIVE && !animate) { | 169 to_hide_.clear(); |
164 if (!wm::IsActiveWindow(left_window_)) | 170 |
165 left_window_->Hide(); | 171 if (state_ == INACTIVE) { |
166 if (!wm::IsActiveWindow(right_window_)) | 172 if (!wm::IsActiveWindow(left_window_)) |
167 right_window_->Hide(); | 173 left_window_->Hide(); |
168 SetWindowTransforms(gfx::Transform(), gfx::Transform(), false); | 174 if (!wm::IsActiveWindow(right_window_)) |
169 return; | 175 right_window_->Hide(); |
| 176 |
| 177 SetWindowTransforms(gfx::Transform(), gfx::Transform(), false); |
| 178 return; |
| 179 } |
170 } | 180 } |
171 | 181 |
172 left_window_->Show(); | 182 left_window_->Show(); |
173 right_window_->Show(); | 183 right_window_->Show(); |
174 DCHECK(wm::IsActiveWindow(left_window_) || wm::IsActiveWindow(right_window_)); | 184 DCHECK(wm::IsActiveWindow(left_window_) || wm::IsActiveWindow(right_window_)); |
175 if (wm::IsActiveWindow(left_window_)) | 185 if (wm::IsActiveWindow(left_window_)) |
176 container_->StackChildBelow(right_window_, left_window_); | 186 container_->StackChildBelow(right_window_, left_window_); |
177 else | 187 else |
178 container_->StackChildBelow(left_window_, right_window_); | 188 container_->StackChildBelow(left_window_, right_window_); |
179 | 189 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 bool SplitViewController::CanScroll() { | 324 bool SplitViewController::CanScroll() { |
315 // TODO(mfomitchev): return false in full screen. | 325 // TODO(mfomitchev): return false in full screen. |
316 bool result = (!IsSplitViewModeActive() && | 326 bool result = (!IsSplitViewModeActive() && |
317 window_list_provider_->GetWindowList().size() >= 2 && | 327 window_list_provider_->GetWindowList().size() >= 2 && |
318 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()-> | 328 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()-> |
319 GetDisplayNearestWindow(container_).rotation())); | 329 GetDisplayNearestWindow(container_).rotation())); |
320 return result; | 330 return result; |
321 } | 331 } |
322 | 332 |
323 } // namespace athena | 333 } // namespace athena |
OLD | NEW |