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

Side by Side Diff: ash/common/wm/workspace/workspace_layout_manager.cc

Issue 2739763003: Moves maintaining ShellObservers back to Shell (Closed)
Patch Set: merge Created 3 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/common/wm/workspace/workspace_layout_manager.h" 5 #include "ash/common/wm/workspace/workspace_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 23 matching lines...) Expand all
34 34
35 namespace ash { 35 namespace ash {
36 36
37 WorkspaceLayoutManager::WorkspaceLayoutManager(WmWindow* window) 37 WorkspaceLayoutManager::WorkspaceLayoutManager(WmWindow* window)
38 : window_(window), 38 : window_(window),
39 root_window_(window->GetRootWindow()), 39 root_window_(window->GetRootWindow()),
40 root_window_controller_(root_window_->GetRootWindowController()), 40 root_window_controller_(root_window_->GetRootWindowController()),
41 shell_(window_->GetShell()), 41 shell_(window_->GetShell()),
42 work_area_in_parent_(wm::GetDisplayWorkAreaBoundsInParent(window_)), 42 work_area_in_parent_(wm::GetDisplayWorkAreaBoundsInParent(window_)),
43 is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr) { 43 is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr) {
44 shell_->AddShellObserver(this); 44 Shell::GetInstance()->AddShellObserver(this);
45 Shell::GetInstance()->activation_client()->AddObserver(this); 45 Shell::GetInstance()->activation_client()->AddObserver(this);
46 root_window_->aura_window()->AddObserver(this); 46 root_window_->aura_window()->AddObserver(this);
47 display::Screen::GetScreen()->AddObserver(this); 47 display::Screen::GetScreen()->AddObserver(this);
48 DCHECK(window->aura_window()->GetProperty(kSnapChildrenToPixelBoundary)); 48 DCHECK(window->aura_window()->GetProperty(kSnapChildrenToPixelBoundary));
49 } 49 }
50 50
51 WorkspaceLayoutManager::~WorkspaceLayoutManager() { 51 WorkspaceLayoutManager::~WorkspaceLayoutManager() {
52 if (root_window_) 52 if (root_window_)
53 root_window_->aura_window()->RemoveObserver(this); 53 root_window_->aura_window()->RemoveObserver(this);
54 for (WmWindow* window : windows_) { 54 for (WmWindow* window : windows_) {
55 wm::WindowState* window_state = window->GetWindowState(); 55 wm::WindowState* window_state = window->GetWindowState();
56 window_state->RemoveObserver(this); 56 window_state->RemoveObserver(this);
57 window->aura_window()->RemoveObserver(this); 57 window->aura_window()->RemoveObserver(this);
58 } 58 }
59 display::Screen::GetScreen()->RemoveObserver(this); 59 display::Screen::GetScreen()->RemoveObserver(this);
60 Shell::GetInstance()->activation_client()->RemoveObserver(this); 60 Shell::GetInstance()->activation_client()->RemoveObserver(this);
61 shell_->RemoveShellObserver(this); 61 Shell::GetInstance()->RemoveShellObserver(this);
62 } 62 }
63 63
64 void WorkspaceLayoutManager::SetMaximizeBackdropDelegate( 64 void WorkspaceLayoutManager::SetMaximizeBackdropDelegate(
65 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) { 65 std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> delegate) {
66 backdrop_delegate_ = std::move(delegate); 66 backdrop_delegate_ = std::move(delegate);
67 } 67 }
68 68
69 ////////////////////////////////////////////////////////////////////////////// 69 //////////////////////////////////////////////////////////////////////////////
70 // WorkspaceLayoutManager, aura::LayoutManager implementation: 70 // WorkspaceLayoutManager, aura::LayoutManager implementation:
71 71
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 void WorkspaceLayoutManager::UpdateFullscreenState() { 361 void WorkspaceLayoutManager::UpdateFullscreenState() {
362 // TODO(flackr): The fullscreen state is currently tracked per workspace 362 // TODO(flackr): The fullscreen state is currently tracked per workspace
363 // but the shell notification implies a per root window state. Currently 363 // but the shell notification implies a per root window state. Currently
364 // only windows in the default workspace container will go fullscreen but 364 // only windows in the default workspace container will go fullscreen but
365 // this should really be tracked by the RootWindowController since 365 // this should really be tracked by the RootWindowController since
366 // technically any container could get a fullscreen window. 366 // technically any container could get a fullscreen window.
367 if (window_->GetShellWindowId() != kShellWindowId_DefaultContainer) 367 if (window_->GetShellWindowId() != kShellWindowId_DefaultContainer)
368 return; 368 return;
369 bool is_fullscreen = wm::GetWindowForFullscreenMode(window_) != nullptr; 369 bool is_fullscreen = wm::GetWindowForFullscreenMode(window_) != nullptr;
370 if (is_fullscreen != is_fullscreen_) { 370 if (is_fullscreen != is_fullscreen_) {
371 WmShell::Get()->NotifyFullscreenStateChanged(is_fullscreen, root_window_); 371 Shell::GetInstance()->NotifyFullscreenStateChanged(is_fullscreen,
372 root_window_);
372 is_fullscreen_ = is_fullscreen; 373 is_fullscreen_ = is_fullscreen;
373 } 374 }
374 } 375 }
375 376
376 void WorkspaceLayoutManager::UpdateAlwaysOnTop(WmWindow* window_on_top) { 377 void WorkspaceLayoutManager::UpdateAlwaysOnTop(WmWindow* window_on_top) {
377 // Changing always on top state may change window's parent. Iterate on a copy 378 // Changing always on top state may change window's parent. Iterate on a copy
378 // of |windows_| to avoid invalidating an iterator. Since both workspace and 379 // of |windows_| to avoid invalidating an iterator. Since both workspace and
379 // always_on_top containers' layouts are managed by this class all the 380 // always_on_top containers' layouts are managed by this class all the
380 // appropriate windows will be included in the iteration. 381 // appropriate windows will be included in the iteration.
381 WindowSet windows(windows_); 382 WindowSet windows(windows_);
382 for (auto* window : windows) { 383 for (auto* window : windows) {
383 wm::WindowState* window_state = window->GetWindowState(); 384 wm::WindowState* window_state = window->GetWindowState();
384 if (window_on_top) 385 if (window_on_top)
385 window_state->DisableAlwaysOnTop(window_on_top); 386 window_state->DisableAlwaysOnTop(window_on_top);
386 else 387 else
387 window_state->RestoreAlwaysOnTop(); 388 window_state->RestoreAlwaysOnTop();
388 } 389 }
389 } 390 }
390 391
391 } // namespace ash 392 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/screen_dimmer.cc ('k') | ash/common/wm/workspace/workspace_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698