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

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

Issue 495193003: athena: Fix overview mode for split-view mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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/window_manager_impl.h" 5 #include "athena/wm/window_manager_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "athena/common/container_priorities.h" 9 #include "athena/common/container_priorities.h"
10 #include "athena/screen/public/screen_manager.h" 10 #include "athena/screen/public/screen_manager.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 176
177 void WindowManagerImpl::SetInOverview(bool active) { 177 void WindowManagerImpl::SetInOverview(bool active) {
178 bool in_overview = !!overview_; 178 bool in_overview = !!overview_;
179 if (active == in_overview) 179 if (active == in_overview)
180 return; 180 return;
181 181
182 bezel_controller_->set_left_right_delegate( 182 bezel_controller_->set_left_right_delegate(
183 active ? NULL : split_view_controller_.get()); 183 active ? NULL : split_view_controller_.get());
184 if (active) { 184 if (active) {
185 split_view_controller_->DeactivateSplitMode();
186 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter()); 185 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter());
187 186
188 // Re-stack all windows in the order defined by window_list_provider_. 187 // Re-stack all windows in the order defined by window_list_provider_.
189 aura::Window::Windows window_list = window_list_provider_->GetWindowList(); 188 aura::Window::Windows window_list = window_list_provider_->GetWindowList();
190 aura::Window::Windows::iterator it; 189 aura::Window::Windows::iterator it;
191 for (it = window_list.begin(); it != window_list.end(); ++it) 190 for (it = window_list.begin(); it != window_list.end(); ++it)
192 container_->StackChildAtTop(*it); 191 container_->StackChildAtTop(*it);
193 overview_ = WindowOverviewMode::Create( 192 overview_ = WindowOverviewMode::Create(
194 container_.get(), window_list_provider_.get(), this); 193 container_.get(), window_list_provider_.get(), this);
195 } else { 194 } else {
196 CHECK(!split_view_controller_->IsSplitViewModeActive());
197 overview_.reset(); 195 overview_.reset();
198 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); 196 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit());
199 } 197 }
200 } 198 }
201 199
202 void WindowManagerImpl::InstallAccelerators() { 200 void WindowManagerImpl::InstallAccelerators() {
203 const AcceleratorData accelerator_data[] = { 201 const AcceleratorData accelerator_data[] = {
204 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, 202 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW,
205 AF_NONE}, 203 AF_NONE},
206 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, 204 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN,
207 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, 205 CMD_TOGGLE_SPLIT_VIEW, AF_NONE},
208 }; 206 };
209 AcceleratorManager::Get()->RegisterAccelerators( 207 AcceleratorManager::Get()->RegisterAccelerators(
210 accelerator_data, arraysize(accelerator_data), this); 208 accelerator_data, arraysize(accelerator_data), this);
211 } 209 }
212 210
213 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { 211 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) {
214 observers_.AddObserver(observer); 212 observers_.AddObserver(observer);
215 } 213 }
216 214
217 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { 215 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) {
218 observers_.RemoveObserver(observer); 216 observers_.RemoveObserver(observer);
219 } 217 }
220 218
219 bool WindowManagerImpl::IsInSplitViewMode(aura::Window** left_window,
220 aura::Window** right_window) {
221 if (!split_view_controller_->IsSplitViewModeActive())
222 return false;
223 if (left_window)
224 *left_window = split_view_controller_->left_window();
225 if (right_window)
226 *right_window = split_view_controller_->right_window();
227 return true;
228 }
229
221 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 230 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
231 if (split_view_controller_->IsSplitViewModeActive())
232 split_view_controller_->DeactivateSplitMode();
222 wm::ActivateWindow(window); 233 wm::ActivateWindow(window);
223 SetInOverview(false); 234 SetInOverview(false);
235 // If |window| does not have the size of the work-area, then make sure it is
236 // resized.
237 const gfx::Size work_area =
238 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
239 if (window->GetTargetBounds().size() != work_area) {
240 const gfx::Rect& window_bounds = window->bounds();
241 const gfx::Rect desired_bounds(work_area);
242 gfx::Transform transform;
243 transform.Translate(desired_bounds.x() - window_bounds.x(),
244 desired_bounds.y() - window_bounds.y());
245 transform.Scale(desired_bounds.width() / window_bounds.width(),
246 desired_bounds.height() / window_bounds.height());
247 window->layer()->GetAnimator()->AbortAllAnimations();
248 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
249 settings.SetPreemptionStrategy(
250 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
251 settings.AddObserver(
252 new ui::ClosureAnimationObserver(base::Bind(&SetWindowState,
253 base::Unretained(window),
254 desired_bounds,
255 gfx::Transform())));
256 window->SetTransform(transform);
257 }
224 } 258 }
225 259
226 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, 260 void WindowManagerImpl::OnSplitViewMode(aura::Window* left,
227 aura::Window* right) { 261 aura::Window* right) {
228 SetInOverview(false); 262 SetInOverview(false);
229 split_view_controller_->ActivateSplitMode(left, right); 263 split_view_controller_->ActivateSplitMode(left, right);
230 } 264 }
231 265
232 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { 266 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) {
233 // TODO(oshima): Creating a new window should updates the ovewview mode 267 // TODO(oshima): Creating a new window should updates the ovewview mode
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 base::Unretained(next_window), 365 base::Unretained(next_window),
332 window->bounds(), 366 window->bounds(),
333 gfx::Transform()))); 367 gfx::Transform())));
334 368
335 gfx::Transform transform; 369 gfx::Transform transform;
336 transform.Scale(window->bounds().width() / next_window->bounds().width(), 370 transform.Scale(window->bounds().width() / next_window->bounds().width(),
337 window->bounds().height() / next_window->bounds().height()); 371 window->bounds().height() / next_window->bounds().height());
338 transform.Translate(window->bounds().x() - next_window->bounds().x(), 0); 372 transform.Translate(window->bounds().x() - next_window->bounds().x(), 0);
339 next_window->SetTransform(transform); 373 next_window->SetTransform(transform);
340 374
341 OnSelectWindow(next_window); 375 wm::ActivateWindow(next_window);
342 } 376 }
343 window->Hide(); 377 window->Hide();
344 } 378 }
345 379
346 void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) { 380 void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) {
347 aura::Window* next_window = GetWindowBehind(window); 381 aura::Window* next_window = GetWindowBehind(window);
348 if (!next_window) 382 if (!next_window)
349 return; 383 return;
350 next_window->SetTransform(gfx::Transform()); 384 next_window->SetTransform(gfx::Transform());
351 next_window->Hide(); 385 next_window->Hide();
(...skipping 14 matching lines...) Expand all
366 DCHECK(!instance); 400 DCHECK(!instance);
367 } 401 }
368 402
369 // static 403 // static
370 WindowManager* WindowManager::GetInstance() { 404 WindowManager* WindowManager::GetInstance() {
371 DCHECK(instance); 405 DCHECK(instance);
372 return instance; 406 return instance;
373 } 407 }
374 408
375 } // namespace athena 409 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698