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

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

Issue 694883002: Do not allow split view to be engaged by a bezel gesture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/window_manager_impl.h » ('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_manager.h" 10 #include "athena/wm/public/window_manager.h"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 548
549 float SplitViewController::GetMaxDistanceFromMiddleForTest() const { 549 float SplitViewController::GetMaxDistanceFromMiddleForTest() const {
550 return kMaxDistanceFromMiddle; 550 return kMaxDistanceFromMiddle;
551 } 551 }
552 552
553 float SplitViewController::GetMinFlingVelocityForTest() const { 553 float SplitViewController::GetMinFlingVelocityForTest() const {
554 return kMinFlingVelocity; 554 return kMinFlingVelocity;
555 } 555 }
556 556
557 /////////////////////////////////////////////////////////////////////////////// 557 ///////////////////////////////////////////////////////////////////////////////
558 // BezelController::ScrollDelegate: 558 // DragHandleScrollDelegate:
559 559
560 void SplitViewController::BezelScrollBegin(BezelController::Bezel bezel, 560 void SplitViewController::HandleScrollBegin(float delta) {
561 float delta) { 561 CHECK(state_ == ACTIVE);
562 if (!BezelCanScroll()) 562 state_ = SCROLLING;
563 return; 563 divider_scroll_start_position_ = GetDefaultDividerPosition();
564
565 SetState(SCROLLING);
566
567 const aura::Window::Windows& windows = window_list_provider_->GetWindowList();
568 CHECK(windows.size() >= 2);
569 aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
570 aura::Window* current_window = *(iter);
571
572 if (delta > 0) {
573 right_window_ = current_window;
574 left_window_ = *(iter + 1);
575 } else {
576 left_window_ = current_window;
577 right_window_ = *(iter + 1);
578 }
579
580 CHECK(left_window_);
581 CHECK(right_window_);
582
583 // Calculate divider_scroll_start_position_
584 gfx::Screen* screen = gfx::Screen::GetScreenFor(container_);
585 const gfx::Rect& display_bounds =
586 screen->GetDisplayNearestWindow(container_).bounds();
587 gfx::Rect container_bounds = container_->GetBoundsInScreen();
588 divider_scroll_start_position_ =
589 delta > 0 ? display_bounds.x() - container_bounds.x()
590 : display_bounds.right() - container_bounds.x();
591
592 divider_position_ = divider_scroll_start_position_ + delta; 564 divider_position_ = divider_scroll_start_position_ + delta;
593 UpdateLayout(false); 565 UpdateLayout(false);
594 } 566 }
595 567
596 void SplitViewController::BezelScrollEnd(float velocity) { 568 void SplitViewController::HandleScrollEnd(float velocity) {
597 if (state_ != SCROLLING) 569 if (state_ != SCROLLING)
598 return; 570 return;
599 571
600 int delta = GetDefaultDividerPosition() - divider_position_; 572 int delta = GetDefaultDividerPosition() - divider_position_;
601 WindowToActivate window = WINDOW_NONE; 573 WindowToActivate window = WINDOW_NONE;
602 if (std::abs(velocity) > kMinFlingVelocity) 574 if (std::abs(velocity) > kMinFlingVelocity)
603 window = velocity > 0 ? WINDOW_LEFT : WINDOW_RIGHT; 575 window = velocity > 0 ? WINDOW_LEFT : WINDOW_RIGHT;
604 else if (std::abs(delta) > kMaxDistanceFromMiddle) 576 else if (std::abs(delta) > kMaxDistanceFromMiddle)
605 window = delta > 0 ? WINDOW_RIGHT : WINDOW_LEFT; 577 window = delta > 0 ? WINDOW_RIGHT : WINDOW_LEFT;
606 578
(...skipping 10 matching lines...) Expand all
617 case WINDOW_RIGHT: 589 case WINDOW_RIGHT:
618 divider_position_ = 0; 590 divider_position_ = 0;
619 SetState(INACTIVE); 591 SetState(INACTIVE);
620 wm::ActivateWindow(right_window_); 592 wm::ActivateWindow(right_window_);
621 break; 593 break;
622 } 594 }
623 595
624 UpdateLayout(true); 596 UpdateLayout(true);
625 } 597 }
626 598
627 void SplitViewController::BezelScrollUpdate(float delta) { 599 void SplitViewController::HandleScrollUpdate(float delta) {
628 if (state_ != SCROLLING) 600 if (state_ != SCROLLING)
629 return; 601 return;
630 divider_position_ = divider_scroll_start_position_ + delta; 602 divider_position_ = divider_scroll_start_position_ + delta;
631 UpdateLayout(false); 603 UpdateLayout(false);
632 } 604 }
633 605
634 bool SplitViewController::BezelCanScroll() {
635 return CanActivateSplitViewMode();
636 }
637
638 ///////////////////////////////////////////////////////////////////////////////
639 // DragHandleScrollDelegate:
640
641 void SplitViewController::HandleScrollBegin(float delta) {
642 CHECK(state_ == ACTIVE);
643 state_ = SCROLLING;
644 divider_scroll_start_position_ = GetDefaultDividerPosition();
645 divider_position_ = divider_scroll_start_position_ + delta;
646 UpdateLayout(false);
647 }
648
649 void SplitViewController::HandleScrollEnd(float velocity) {
650 BezelScrollEnd(velocity);
651 }
652
653 void SplitViewController::HandleScrollUpdate(float delta) {
654 BezelScrollUpdate(delta);
655 }
656
657 /////////////////////////////////////////////////////////////////////////////// 606 ///////////////////////////////////////////////////////////////////////////////
658 // WindowManagerObserver: 607 // WindowManagerObserver:
659 608
660 void SplitViewController::OnOverviewModeEnter() { 609 void SplitViewController::OnOverviewModeEnter() {
661 if (divider_widget_) 610 if (divider_widget_)
662 HideDivider(); 611 HideDivider();
663 } 612 }
664 613
665 void SplitViewController::OnOverviewModeExit() { 614 void SplitViewController::OnOverviewModeExit() {
666 if (state_ != INACTIVE) 615 if (state_ != INACTIVE)
667 ShowDivider(); 616 ShowDivider();
668 } 617 }
669 618
670 void SplitViewController::OnSplitViewModeEnter() { 619 void SplitViewController::OnSplitViewModeEnter() {
671 } 620 }
672 621
673 void SplitViewController::OnSplitViewModeExit() { 622 void SplitViewController::OnSplitViewModeExit() {
674 } 623 }
675 624
676 } // namespace athena 625 } // namespace athena
OLDNEW
« no previous file with comments | « athena/wm/split_view_controller.h ('k') | athena/wm/window_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698