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 aura::Window::Windows windows = window_list_provider_->GetWindowList(); | 65 aura::Window::Windows windows = window_list_provider_->GetCurrentWindowList(); |
66 aura::Window::Windows::reverse_iterator iter = windows.rbegin(); | 66 aura::Window::Windows::reverse_iterator iter = windows.rbegin(); |
67 if (state_ == ACTIVE) { | 67 if (state_ == ACTIVE) { |
68 if (left_window_ == right) | 68 if (left_window_ == right) |
69 left_window_ = left; | 69 left_window_ = left; |
70 if (right_window_ == left) | 70 if (right_window_ == left) |
71 right_window_ = right; | 71 right_window_ = right; |
72 | 72 |
73 if (!left) | 73 if (!left) |
74 left = left_window_; | 74 left = left_window_; |
75 if (!right) | 75 if (!right) |
(...skipping 14 matching lines...) Expand all Loading... |
90 iter++; | 90 iter++; |
91 if (right == left && iter != windows.rend()) { | 91 if (right == left && iter != windows.rend()) { |
92 right = *iter; | 92 right = *iter; |
93 iter++; | 93 iter++; |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 SetState(ACTIVE); | 97 SetState(ACTIVE); |
98 if (right_window_ != right) { | 98 if (right_window_ != right) { |
99 right_window_ = right; | 99 right_window_ = right; |
100 container_->StackChildAtTop(right_window_); | 100 // Since the |window_list_provider_| controls directly the order of windows, |
| 101 // it needs to change the window order accordingly. |
| 102 window_list_provider_->MoveToFront(right_window_); |
101 } | 103 } |
102 if (left_window_ != left) { | 104 if (left_window_ != left) { |
103 left_window_ = left; | 105 left_window_ = left; |
104 container_->StackChildAtTop(left_window_); | 106 // Since the |window_list_provider_| controls directly the order of windows, |
| 107 // it needs to change the window order accordingly. |
| 108 window_list_provider_->MoveToFront(left_window_); |
105 } | 109 } |
106 UpdateLayout(true); | 110 UpdateLayout(true); |
107 } | 111 } |
108 | 112 |
109 void SplitViewController::ReplaceWindow(aura::Window* window, | 113 void SplitViewController::ReplaceWindow(aura::Window* window, |
110 aura::Window* replace_with) { | 114 aura::Window* replace_with) { |
111 CHECK(IsSplitViewModeActive()); | 115 CHECK(IsSplitViewModeActive()); |
112 CHECK(replace_with); | 116 CHECK(replace_with); |
113 CHECK(window == left_window_ || window == right_window_); | 117 CHECK(window == left_window_ || window == right_window_); |
114 CHECK(replace_with != left_window_ && replace_with != right_window_); | 118 CHECK(replace_with != left_window_ && replace_with != right_window_); |
115 #if !defined(NDEBUG) | 119 #if !defined(NDEBUG) |
116 aura::Window::Windows windows = window_list_provider_->GetWindowList(); | 120 aura::Window::Windows windows = window_list_provider_->GetCurrentWindowList(); |
117 DCHECK(std::find(windows.begin(), windows.end(), replace_with) != | 121 DCHECK(std::find(windows.begin(), windows.end(), replace_with) != |
118 windows.end()); | 122 windows.end()); |
119 #endif | 123 #endif |
120 | 124 |
121 if (window == left_window_) | 125 if (window == left_window_) |
122 left_window_ = replace_with; | 126 left_window_ = replace_with; |
123 else | 127 else |
124 right_window_ = replace_with; | 128 right_window_ = replace_with; |
125 wm::ActivateWindow(replace_with); | 129 wm::ActivateWindow(replace_with); |
126 UpdateLayout(false); | 130 UpdateLayout(false); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 254 |
251 /////////////////////////////////////////////////////////////////////////////// | 255 /////////////////////////////////////////////////////////////////////////////// |
252 // BezelController::ScrollDelegate: | 256 // BezelController::ScrollDelegate: |
253 | 257 |
254 void SplitViewController::ScrollBegin(BezelController::Bezel bezel, | 258 void SplitViewController::ScrollBegin(BezelController::Bezel bezel, |
255 float delta) { | 259 float delta) { |
256 if (!CanScroll()) | 260 if (!CanScroll()) |
257 return; | 261 return; |
258 SetState(SCROLLING); | 262 SetState(SCROLLING); |
259 | 263 |
260 aura::Window::Windows windows = window_list_provider_->GetWindowList(); | 264 aura::Window::Windows windows = window_list_provider_->GetCurrentWindowList(); |
261 CHECK(windows.size() >= 2); | 265 CHECK(windows.size() >= 2); |
262 aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); | 266 aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); |
263 aura::Window* current_window = *(iter); | 267 aura::Window* current_window = *(iter); |
264 CHECK(wm::IsActiveWindow(current_window)); | 268 CHECK(wm::IsActiveWindow(current_window)); |
265 | 269 |
266 if (delta > 0) { | 270 if (delta > 0) { |
267 right_window_ = current_window; | 271 right_window_ = current_window; |
268 left_window_ = *(iter + 1); | 272 left_window_ = *(iter + 1); |
269 } else { | 273 } else { |
270 left_window_ = current_window; | 274 left_window_ = current_window; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 void SplitViewController::ScrollUpdate(float delta) { | 309 void SplitViewController::ScrollUpdate(float delta) { |
306 if (state_ != SCROLLING) | 310 if (state_ != SCROLLING) |
307 return; | 311 return; |
308 UpdateSeparatorPositionFromScrollDelta(delta); | 312 UpdateSeparatorPositionFromScrollDelta(delta); |
309 UpdateLayout(false); | 313 UpdateLayout(false); |
310 } | 314 } |
311 | 315 |
312 bool SplitViewController::CanScroll() { | 316 bool SplitViewController::CanScroll() { |
313 // TODO(mfomitchev): return false in full screen. | 317 // TODO(mfomitchev): return false in full screen. |
314 bool result = (!IsSplitViewModeActive() && | 318 bool result = (!IsSplitViewModeActive() && |
315 window_list_provider_->GetWindowList().size() >= 2 && | 319 window_list_provider_->GetCurrentWindowList().size() >= 2 && |
316 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()-> | 320 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()-> |
317 GetDisplayNearestWindow(container_).rotation())); | 321 GetDisplayNearestWindow(container_).rotation())); |
318 return result; | 322 return result; |
319 } | 323 } |
320 | 324 |
321 } // namespace athena | 325 } // namespace athena |
OLD | NEW |