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

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

Issue 535973002: Disable screen rotation when splitview is engaged and only allow splitview in landscape. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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/wm/public/window_list_provider.h" 10 #include "athena/wm/public/window_list_provider.h"
10 #include "athena/wm/public/window_manager.h" 11 #include "athena/wm/public/window_manager.h"
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
13 #include "ui/compositor/closure_animation_observer.h" 14 #include "ui/compositor/closure_animation_observer.h"
14 #include "ui/compositor/layer_animation_observer.h" 15 #include "ui/compositor/layer_animation_observer.h"
15 #include "ui/compositor/scoped_layer_animation_settings.h" 16 #include "ui/compositor/scoped_layer_animation_settings.h"
16 #include "ui/events/event_handler.h" 17 #include "ui/events/event_handler.h"
17 #include "ui/gfx/display.h" 18 #include "ui/gfx/display.h"
18 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
19 #include "ui/wm/core/window_util.h" 20 #include "ui/wm/core/window_util.h"
20 21
21 namespace athena { 22 namespace athena {
22 23
23 namespace { 24 namespace {
24 25
25 // Returns a target transform which is suitable for animating a windows's 26 // Returns a target transform which is suitable for animating a windows's
26 // bounds. 27 // bounds.
27 gfx::Transform GetTargetTransformForBoundsAnimation(const gfx::Rect& from, 28 gfx::Transform GetTargetTransformForBoundsAnimation(const gfx::Rect& from,
28 const gfx::Rect& to) { 29 const gfx::Rect& to) {
29 gfx::Transform transform; 30 gfx::Transform transform;
30 transform.Translate(to.x() - from.x(), to.y() - from.y()); 31 transform.Translate(to.x() - from.x(), to.y() - from.y());
31 transform.Scale(to.width() / static_cast<float>(from.width()), 32 transform.Scale(to.width() / static_cast<float>(from.width()),
32 to.height() / static_cast<float>(from.height())); 33 to.height() / static_cast<float>(from.height()));
33 return transform; 34 return transform;
34 } 35 }
35 36
37 bool IsLandscapeOrientation(gfx::Display::Rotation rotation) {
38 return rotation == gfx::Display::ROTATE_0 ||
39 rotation == gfx::Display::ROTATE_180;
40 }
41
36 } // namespace 42 } // namespace
37 43
38 SplitViewController::SplitViewController( 44 SplitViewController::SplitViewController(
39 aura::Window* container, 45 aura::Window* container,
40 WindowListProvider* window_list_provider) 46 WindowListProvider* window_list_provider)
41 : state_(INACTIVE), 47 : state_(INACTIVE),
42 container_(container), 48 container_(container),
43 window_list_provider_(window_list_provider), 49 window_list_provider_(window_list_provider),
44 left_window_(NULL), 50 left_window_(NULL),
45 right_window_(NULL), 51 right_window_(NULL),
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 UpdateLayout(false); 126 UpdateLayout(false);
121 window->SetTransform(gfx::Transform()); 127 window->SetTransform(gfx::Transform());
122 window->Hide(); 128 window->Hide();
123 } 129 }
124 130
125 void SplitViewController::DeactivateSplitMode() { 131 void SplitViewController::DeactivateSplitMode() {
126 CHECK_EQ(ACTIVE, state_); 132 CHECK_EQ(ACTIVE, state_);
127 state_ = INACTIVE; 133 state_ = INACTIVE;
128 UpdateLayout(false); 134 UpdateLayout(false);
129 left_window_ = right_window_ = NULL; 135 left_window_ = right_window_ = NULL;
136 ScreenManager::Get()->SetRotationLocked(false);
130 } 137 }
131 138
132 gfx::Rect SplitViewController::GetLeftTargetBounds() { 139 gfx::Rect SplitViewController::GetLeftTargetBounds() {
133 gfx::Rect work_area = 140 gfx::Rect work_area =
134 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area(); 141 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area();
135 return gfx::Rect(0, 0, container_->bounds().width() / 2, work_area.height()); 142 return gfx::Rect(0, 0, container_->bounds().width() / 2, work_area.height());
136 } 143 }
137 144
138 gfx::Rect SplitViewController::GetRightTargetBounds() { 145 gfx::Rect SplitViewController::GetRightTargetBounds() {
139 gfx::Rect work_area = 146 gfx::Rect work_area =
140 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area(); 147 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area();
141 int container_width = container_->bounds().width(); 148 int container_width = container_->bounds().width();
142 return gfx::Rect( 149 return gfx::Rect(
143 container_width / 2, 0, container_width / 2, work_area.height()); 150 container_width / 2, 0, container_width / 2, work_area.height());
144 } 151 }
145 152
146 void SplitViewController::UpdateLayout(bool animate) { 153 void SplitViewController::UpdateLayout(bool animate) {
147 CHECK(left_window_); 154 CHECK(left_window_);
148 CHECK(right_window_); 155 CHECK(right_window_);
149 156
157 // Splitview can be activated from SplitViewController::ActivateSplitMode or
158 // SplitViewController::ScrollEnd. Additionally we don't want to rotate the
159 // screen while engaging splitview (i.e. state_ == SCROLLING).
160 ScreenManager::Get()->SetRotationLocked(state_ != INACTIVE);
mfomitchev 2014/09/03 15:33:59 Perhaps we should create a SetState() method and l
flackr 2014/09/03 16:42:13 Done.
150 if (state_ == INACTIVE && !animate) { 161 if (state_ == INACTIVE && !animate) {
151 if (!wm::IsActiveWindow(left_window_)) 162 if (!wm::IsActiveWindow(left_window_))
152 left_window_->Hide(); 163 left_window_->Hide();
153 if (!wm::IsActiveWindow(right_window_)) 164 if (!wm::IsActiveWindow(right_window_))
154 right_window_->Hide(); 165 right_window_->Hide();
155 SetWindowTransforms(gfx::Transform(), gfx::Transform(), false); 166 SetWindowTransforms(gfx::Transform(), gfx::Transform(), false);
156 return; 167 return;
157 } 168 }
158 169
159 left_window_->Show(); 170 left_window_->Show();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 297 }
287 298
288 void SplitViewController::ScrollUpdate(float delta) { 299 void SplitViewController::ScrollUpdate(float delta) {
289 if (state_ != SCROLLING) 300 if (state_ != SCROLLING)
290 return; 301 return;
291 UpdateSeparatorPositionFromScrollDelta(delta); 302 UpdateSeparatorPositionFromScrollDelta(delta);
292 UpdateLayout(false); 303 UpdateLayout(false);
293 } 304 }
294 305
295 bool SplitViewController::CanScroll() { 306 bool SplitViewController::CanScroll() {
296 // TODO(mfomitchev): return false in vertical orientation, in full screen. 307 // TODO(mfomitchev): return false in full screen.
297 bool result = (!IsSplitViewModeActive() && 308 bool result = (!IsSplitViewModeActive() &&
298 window_list_provider_->GetWindowList().size() >= 2); 309 window_list_provider_->GetWindowList().size() >= 2 &&
310 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()->
311 GetDisplayNearestWindow(container_).rotation()));
299 return result; 312 return result;
300 } 313 }
301 314
302 } // namespace athena 315 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698