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

Side by Side Diff: athena/wm/split_view_controller.cc

Issue 574113004: [Athena] Fix switching activities by swiping from the right bezel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@athena_split
Patch Set: Created 6 years, 2 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 | « athena/wm/split_view_controller.h ('k') | athena/wm/split_view_controller_unittest.cc » ('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 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"
11 #include "athena/wm/public/window_manager.h" 11 #include "athena/wm/public/window_manager.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "ui/aura/scoped_window_targeter.h" 13 #include "ui/aura/scoped_window_targeter.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/aura/window_targeter.h" 15 #include "ui/aura/window_targeter.h"
16 #include "ui/compositor/closure_animation_observer.h" 16 #include "ui/compositor/closure_animation_observer.h"
17 #include "ui/compositor/layer.h" 17 #include "ui/compositor/layer.h"
18 #include "ui/compositor/scoped_layer_animation_settings.h" 18 #include "ui/compositor/scoped_layer_animation_settings.h"
19 #include "ui/events/event_handler.h" 19 #include "ui/events/event_handler.h"
20 #include "ui/gfx/display.h" 20 #include "ui/gfx/display.h"
21 #include "ui/gfx/screen.h" 21 #include "ui/gfx/screen.h"
22 #include "ui/views/background.h" 22 #include "ui/views/background.h"
23 #include "ui/views/layout/box_layout.h" 23 #include "ui/views/layout/box_layout.h"
24 #include "ui/views/widget/root_view.h" 24 #include "ui/views/widget/root_view.h"
25 #include "ui/views/widget/root_view_targeter.h" 25 #include "ui/views/widget/root_view_targeter.h"
26 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
27 #include "ui/wm/core/window_util.h" 27 #include "ui/wm/core/window_util.h"
28 #include "ui/wm/public/activation_client.h"
28 29
29 namespace athena { 30 namespace athena {
30 31
31 namespace { 32 namespace {
32 33
33 const int kDragHandleWidth = 4; 34 const int kDragHandleWidth = 4;
34 const int kDragHandleHeight = 80; 35 const int kDragHandleHeight = 80;
35 const int kDragHandleMargin = 1; 36 const int kDragHandleMargin = 1;
36 const int kDividerWidth = kDragHandleWidth + 2 * kDragHandleMargin; 37 const int kDividerWidth = kDragHandleWidth + 2 * kDragHandleMargin;
37 38
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 window_list_provider_->GetWindowList().size() >= 2 && 171 window_list_provider_->GetWindowList().size() >= 2 &&
171 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()-> 172 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()->
172 GetDisplayNearestWindow(container_).rotation())); 173 GetDisplayNearestWindow(container_).rotation()));
173 } 174 }
174 175
175 bool SplitViewController::IsSplitViewModeActive() const { 176 bool SplitViewController::IsSplitViewModeActive() const {
176 return state_ == ACTIVE; 177 return state_ == ACTIVE;
177 } 178 }
178 179
179 void SplitViewController::ActivateSplitMode(aura::Window* left, 180 void SplitViewController::ActivateSplitMode(aura::Window* left,
180 aura::Window* right) { 181 aura::Window* right,
182 aura::Window* to_activate) {
181 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); 183 const aura::Window::Windows& windows = window_list_provider_->GetWindowList();
182 aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); 184 aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
183 if (state_ == ACTIVE) { 185 if (state_ == ACTIVE) {
184 if (!left && left_window_ != right) 186 if (!left && left_window_ != right)
185 left = left_window_; 187 left = left_window_;
186 if (!right && right_window_ != left) 188 if (!right && right_window_ != left)
187 right = right_window_; 189 right = right_window_;
188 } 190 }
189 191
190 if (!left && iter != windows.rend()) { 192 if (!left && iter != windows.rend()) {
(...skipping 13 matching lines...) Expand all
204 iter++; 206 iter++;
205 } 207 }
206 } 208 }
207 209
208 to_hide_.clear(); 210 to_hide_.clear();
209 if (left_window_ && left_window_ != left && left_window_ != right) 211 if (left_window_ && left_window_ != left && left_window_ != right)
210 to_hide_.push_back(left_window_); 212 to_hide_.push_back(left_window_);
211 if (right_window_ && right_window_ != left && right_window_ != right) 213 if (right_window_ && right_window_ != left && right_window_ != right)
212 to_hide_.push_back(right_window_); 214 to_hide_.push_back(right_window_);
213 215
216 left_window_ = left;
217 right_window_ = right;
218
214 divider_position_ = GetDefaultDividerPosition(); 219 divider_position_ = GetDefaultDividerPosition();
215 SetState(ACTIVE); 220 SetState(ACTIVE);
216 right_window_ = right;
217 left_window_ = left;
218 UpdateLayout(true); 221 UpdateLayout(true);
222
223 aura::client::ActivationClient* activation_client =
224 aura::client::GetActivationClient(container_->GetRootWindow());
225 aura::Window* active_window = activation_client->GetActiveWindow();
226 if (to_activate) {
227 CHECK(to_activate == left_window_ || to_activate == right_window_);
228 wm::ActivateWindow(to_activate);
229 } else if (active_window != left_window_ &&
230 active_window != right_window_) {
231 // A window which does not belong to an activity could be active.
232 wm::ActivateWindow(left_window_);
233 }
234 active_window = activation_client->GetActiveWindow();
235
236 if (active_window == left_window_)
237 window_list_provider_->StackWindowBehindTo(right_window_, left_window_);
238 else
239 window_list_provider_->StackWindowBehindTo(left_window_, right_window_);
219 } 240 }
220 241
221 void SplitViewController::ReplaceWindow(aura::Window* window, 242 void SplitViewController::ReplaceWindow(aura::Window* window,
222 aura::Window* replace_with) { 243 aura::Window* replace_with) {
223 CHECK(IsSplitViewModeActive()); 244 CHECK(IsSplitViewModeActive());
224 CHECK(replace_with); 245 CHECK(replace_with);
225 CHECK(window == left_window_ || window == right_window_); 246 CHECK(window == left_window_ || window == right_window_);
226 CHECK(replace_with != left_window_ && replace_with != right_window_); 247 CHECK(replace_with != left_window_ && replace_with != right_window_);
227 DCHECK(window_list_provider_->IsWindowInList(replace_with)); 248 DCHECK(window_list_provider_->IsWindowInList(replace_with));
228 249
229 if (window == left_window_) 250 aura::Window* not_replaced = NULL;
251 if (window == left_window_) {
230 left_window_ = replace_with; 252 left_window_ = replace_with;
231 else 253 not_replaced = right_window_;
254 } else {
232 right_window_ = replace_with; 255 right_window_ = replace_with;
256 not_replaced = left_window_;
257 }
258 UpdateLayout(false);
259
233 wm::ActivateWindow(replace_with); 260 wm::ActivateWindow(replace_with);
234 UpdateLayout(false); 261 window_list_provider_->StackWindowBehindTo(not_replaced, replace_with);
262
235 window->SetTransform(gfx::Transform()); 263 window->SetTransform(gfx::Transform());
236 window->Hide(); 264 window->Hide();
237 } 265 }
238 266
239 void SplitViewController::DeactivateSplitMode() { 267 void SplitViewController::DeactivateSplitMode() {
240 CHECK_EQ(ACTIVE, state_); 268 CHECK_EQ(ACTIVE, state_);
241 SetState(INACTIVE); 269 SetState(INACTIVE);
242 UpdateLayout(false); 270 UpdateLayout(false);
243 left_window_ = right_window_ = NULL; 271 left_window_ = right_window_ = NULL;
244 } 272 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // TODO(mfomitchev): Use to_hide_ instead 388 // TODO(mfomitchev): Use to_hide_ instead
361 right_window_->Hide(); 389 right_window_->Hide();
362 } 390 }
363 SetWindowTransforms( 391 SetWindowTransforms(
364 gfx::Transform(), gfx::Transform(), gfx::Transform(), false); 392 gfx::Transform(), gfx::Transform(), gfx::Transform(), false);
365 return; 393 return;
366 } 394 }
367 395
368 left_window_->Show(); 396 left_window_->Show();
369 right_window_->Show(); 397 right_window_->Show();
370 window_list_provider_->MoveToFront(right_window_);
371 window_list_provider_->MoveToFront(left_window_);
372 398
373 gfx::Transform divider_transform; 399 gfx::Transform divider_transform;
374 divider_transform.Translate(divider_position_, 0); 400 divider_transform.Translate(divider_position_, 0);
375 if (state_ == ACTIVE) { 401 if (state_ == ACTIVE) {
376 if (animate) { 402 if (animate) {
377 gfx::Transform left_transform = 403 gfx::Transform left_transform =
378 GetTransformForBounds(left_window_->bounds(), GetLeftAreaBounds()); 404 GetTransformForBounds(left_window_->bounds(), GetLeftAreaBounds());
379 gfx::Transform right_transform = 405 gfx::Transform right_transform =
380 GetTransformForBounds(right_window_->bounds(), GetRightAreaBounds()); 406 GetTransformForBounds(right_window_->bounds(), GetRightAreaBounds());
381 SetWindowTransforms( 407 SetWindowTransforms(
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 ShowDivider(); 602 ShowDivider();
577 } 603 }
578 604
579 void SplitViewController::OnSplitViewModeEnter() { 605 void SplitViewController::OnSplitViewModeEnter() {
580 } 606 }
581 607
582 void SplitViewController::OnSplitViewModeExit() { 608 void SplitViewController::OnSplitViewModeExit() {
583 } 609 }
584 610
585 } // namespace athena 611 } // namespace athena
OLDNEW
« no previous file with comments | « athena/wm/split_view_controller.h ('k') | athena/wm/split_view_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698