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

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

Issue 464163005: athena: Fix switching to a window of a different size. (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
« no previous file with comments | « no previous file | athena/wm/window_manager_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/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"
11 #include "athena/wm/bezel_controller.h" 11 #include "athena/wm/bezel_controller.h"
12 #include "athena/wm/public/window_manager_observer.h" 12 #include "athena/wm/public/window_manager_observer.h"
13 #include "athena/wm/split_view_controller.h" 13 #include "athena/wm/split_view_controller.h"
14 #include "athena/wm/title_drag_controller.h" 14 #include "athena/wm/title_drag_controller.h"
15 #include "athena/wm/window_list_provider_impl.h" 15 #include "athena/wm/window_list_provider_impl.h"
16 #include "athena/wm/window_overview_mode.h" 16 #include "athena/wm/window_overview_mode.h"
17 #include "base/bind.h"
17 #include "base/logging.h" 18 #include "base/logging.h"
18 #include "ui/aura/layout_manager.h" 19 #include "ui/aura/layout_manager.h"
19 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
21 #include "ui/compositor/closure_animation_observer.h"
22 #include "ui/compositor/scoped_layer_animation_settings.h"
20 #include "ui/gfx/display.h" 23 #include "ui/gfx/display.h"
21 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
22 #include "ui/wm/core/shadow_controller.h" 25 #include "ui/wm/core/shadow_controller.h"
23 #include "ui/wm/core/window_util.h" 26 #include "ui/wm/core/window_util.h"
24 #include "ui/wm/core/wm_state.h" 27 #include "ui/wm/core/wm_state.h"
25 #include "ui/wm/public/activation_client.h" 28 #include "ui/wm/public/activation_client.h"
26 #include "ui/wm/public/window_types.h" 29 #include "ui/wm/public/window_types.h"
27 30
28 namespace athena { 31 namespace athena {
29 namespace { 32 namespace {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 167
165 void WindowManagerImpl::SetInOverview(bool active) { 168 void WindowManagerImpl::SetInOverview(bool active) {
166 bool in_overview = !!overview_; 169 bool in_overview = !!overview_;
167 if (active == in_overview) 170 if (active == in_overview)
168 return; 171 return;
169 172
170 bezel_controller_->set_left_right_delegate( 173 bezel_controller_->set_left_right_delegate(
171 active ? NULL : split_view_controller_.get()); 174 active ? NULL : split_view_controller_.get());
172 if (active) { 175 if (active) {
173 split_view_controller_->DeactivateSplitMode(); 176 split_view_controller_->DeactivateSplitMode();
174 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 177 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter());
175 OnOverviewModeEnter()); 178
176 // Re-stack all windows in the order defined by window_list_provider_. 179 // Re-stack all windows in the order defined by window_list_provider_.
177 aura::Window::Windows window_list = window_list_provider_->GetWindowList(); 180 aura::Window::Windows window_list = window_list_provider_->GetWindowList();
178 aura::Window::Windows::iterator it; 181 aura::Window::Windows::iterator it;
179 for (it = window_list.begin(); it != window_list.end(); ++it) 182 for (it = window_list.begin(); it != window_list.end(); ++it)
180 container_->StackChildAtTop(*it); 183 container_->StackChildAtTop(*it);
181 overview_ = WindowOverviewMode::Create( 184 overview_ = WindowOverviewMode::Create(
182 container_.get(), window_list_provider_.get(), this); 185 container_.get(), window_list_provider_.get(), this);
183 } else { 186 } else {
184 CHECK(!split_view_controller_->IsSplitViewModeActive()); 187 CHECK(!split_view_controller_->IsSplitViewModeActive());
185 overview_.reset(); 188 overview_.reset();
186 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, 189 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit());
187 OnOverviewModeExit());
188 } 190 }
189 } 191 }
190 192
191 void WindowManagerImpl::InstallAccelerators() { 193 void WindowManagerImpl::InstallAccelerators() {
192 const AcceleratorData accelerator_data[] = { 194 const AcceleratorData accelerator_data[] = {
193 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, 195 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW,
194 AF_NONE}, 196 AF_NONE},
195 }; 197 };
196 AcceleratorManager::Get()->RegisterAccelerators( 198 AcceleratorManager::Get()->RegisterAccelerators(
197 accelerator_data, arraysize(accelerator_data), this); 199 accelerator_data, arraysize(accelerator_data), this);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 behind = (iter == windows.rend()) ? NULL : *iter; 260 behind = (iter == windows.rend()) ? NULL : *iter;
259 } 261 }
260 262
261 return behind; 263 return behind;
262 } 264 }
263 265
264 void WindowManagerImpl::OnTitleDragStarted(aura::Window* window) { 266 void WindowManagerImpl::OnTitleDragStarted(aura::Window* window) {
265 aura::Window* next_window = GetWindowBehind(window); 267 aura::Window* next_window = GetWindowBehind(window);
266 if (!next_window) 268 if (!next_window)
267 return; 269 return;
268 // Make sure |window| is active. Also make sure that |next_window| is visible, 270 // Make sure |window| is active.
269 // and positioned to match the top-left edge of |window|.
270 wm::ActivateWindow(window); 271 wm::ActivateWindow(window);
272
273 // Make sure |next_window| is visibile.
271 next_window->Show(); 274 next_window->Show();
275
276 // Position |next_window| correctly (left aligned if it's larger than
277 // |window|, and center aligned otherwise).
272 int dx = window->bounds().x() - next_window->bounds().x(); 278 int dx = window->bounds().x() - next_window->bounds().x();
279 if (next_window->bounds().width() < window->bounds().width())
280 dx += (window->bounds().width() - next_window->bounds().width()) / 2;
oshima 2014/08/20 13:41:59 could be just me and you may ignore but dy -= (ne
sadrul 2014/08/20 22:34:24 Done.
281
273 if (dx) { 282 if (dx) {
274 gfx::Transform transform; 283 gfx::Transform transform;
275 transform.Translate(dx, 0); 284 transform.Translate(dx, 0);
276 next_window->SetTransform(transform); 285 next_window->SetTransform(transform);
277 } 286 }
278 } 287 }
279 288
280 void WindowManagerImpl::OnTitleDragCompleted(aura::Window* window) { 289 void WindowManagerImpl::OnTitleDragCompleted(aura::Window* window) {
281 aura::Window* next_window = GetWindowBehind(window); 290 aura::Window* next_window = GetWindowBehind(window);
282 if (!next_window) 291 if (!next_window)
283 return; 292 return;
284 if (split_view_controller_->IsSplitViewModeActive()) 293 if (split_view_controller_->IsSplitViewModeActive()) {
285 split_view_controller_->ReplaceWindow(window, next_window); 294 split_view_controller_->ReplaceWindow(window, next_window);
286 else 295 wm::ActivateWindow(next_window);
296 } else {
297 ui::ScopedLayerAnimationSettings
298 settings(next_window->layer()->GetAnimator());
299 settings.AddObserver(new ui::ClosureAnimationObserver(
300 base::Bind(&aura::Window::SetBounds,
301 base::Unretained(next_window),
302 window->bounds())));
303 settings.AddObserver(new ui::ClosureAnimationObserver(
304 base::Bind(&aura::Window::SetTransform,
305 base::Unretained(next_window),
306 gfx::Transform())));
oshima 2014/08/20 13:41:59 I'd be nice to have a utility observer to set the
sadrul 2014/08/20 22:34:24 Done.
307
308 gfx::Transform transform;
309 transform.Scale(window->bounds().width() / next_window->bounds().width(),
310 window->bounds().height() / next_window->bounds().height());
311 transform.Translate(window->bounds().x() - next_window->bounds().x(), 0);
312 next_window->SetTransform(transform);
313
287 OnSelectWindow(next_window); 314 OnSelectWindow(next_window);
288 wm::ActivateWindow(next_window); 315 }
316 window->Hide();
oshima 2014/08/20 13:41:59 Is this important now? looks like we show all wind
sadrul 2014/08/20 22:34:24 It's not important in the sense that not doing a H
289 } 317 }
290 318
291 void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) { 319 void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) {
292 aura::Window* next_window = GetWindowBehind(window); 320 aura::Window* next_window = GetWindowBehind(window);
293 if (!next_window) 321 if (!next_window)
294 return; 322 return;
295 next_window->SetTransform(gfx::Transform()); 323 next_window->SetTransform(gfx::Transform());
324 next_window->Hide();
296 } 325 }
297 326
298 // static 327 // static
299 WindowManager* WindowManager::Create() { 328 WindowManager* WindowManager::Create() {
300 DCHECK(!instance); 329 DCHECK(!instance);
301 new WindowManagerImpl; 330 new WindowManagerImpl;
302 DCHECK(instance); 331 DCHECK(instance);
303 return instance; 332 return instance;
304 } 333 }
305 334
306 // static 335 // static
307 void WindowManager::Shutdown() { 336 void WindowManager::Shutdown() {
308 DCHECK(instance); 337 DCHECK(instance);
309 delete instance; 338 delete instance;
310 DCHECK(!instance); 339 DCHECK(!instance);
311 } 340 }
312 341
313 // static 342 // static
314 WindowManager* WindowManager::GetInstance() { 343 WindowManager* WindowManager::GetInstance() {
315 DCHECK(instance); 344 DCHECK(instance);
316 return instance; 345 return instance;
317 } 346 }
318 347
319 } // namespace athena 348 } // namespace athena
OLDNEW
« no previous file with comments | « no previous file | athena/wm/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698