| OLD | NEW |
| 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/wm/workspace/workspace_layout_manager.h" | 5 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
| 10 #include "ash/session_state_delegate.h" | 10 #include "ash/session_state_delegate.h" |
| 11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/wm/always_on_top_controller.h" | 13 #include "ash/wm/always_on_top_controller.h" |
| 14 #include "ash/wm/window_animations.h" | 14 #include "ash/wm/window_animations.h" |
| 15 #include "ash/wm/window_positioner.h" | 15 #include "ash/wm/window_positioner.h" |
| 16 #include "ash/wm/window_properties.h" | 16 #include "ash/wm/window_properties.h" |
| 17 #include "ash/wm/window_state.h" | 17 #include "ash/wm/window_state.h" |
| 18 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
| 19 #include "ash/wm/wm_event.h" | 19 #include "ash/wm/wm_event.h" |
| 20 #include "ash/wm/workspace/workspace_layout_manager_delegate.h" |
| 20 #include "ui/aura/client/activation_client.h" | 21 #include "ui/aura/client/activation_client.h" |
| 21 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_observer.h" | 24 #include "ui/aura/window_observer.h" |
| 24 #include "ui/base/ui_base_types.h" | 25 #include "ui/base/ui_base_types.h" |
| 25 #include "ui/compositor/layer.h" | 26 #include "ui/compositor/layer.h" |
| 26 #include "ui/events/event.h" | 27 #include "ui/events/event.h" |
| 27 #include "ui/gfx/screen.h" | 28 #include "ui/gfx/screen.h" |
| 28 #include "ui/views/corewm/window_util.h" | 29 #include "ui/views/corewm/window_util.h" |
| 29 | 30 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 53 for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i) | 54 for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i) |
| 54 (*i)->RemoveObserver(this); | 55 (*i)->RemoveObserver(this); |
| 55 Shell::GetInstance()->RemoveShellObserver(this); | 56 Shell::GetInstance()->RemoveShellObserver(this); |
| 56 Shell::GetInstance()->activation_client()->RemoveObserver(this); | 57 Shell::GetInstance()->activation_client()->RemoveObserver(this); |
| 57 } | 58 } |
| 58 | 59 |
| 59 void WorkspaceLayoutManager::SetShelf(internal::ShelfLayoutManager* shelf) { | 60 void WorkspaceLayoutManager::SetShelf(internal::ShelfLayoutManager* shelf) { |
| 60 shelf_ = shelf; | 61 shelf_ = shelf; |
| 61 } | 62 } |
| 62 | 63 |
| 64 void WorkspaceLayoutManager::SetMaximizeBackdropDelegate( |
| 65 scoped_ptr<WorkspaceLayoutManagerDelegate> delegate) { |
| 66 backdrop_delegate_.reset(delegate.release()); |
| 67 } |
| 68 |
| 63 ////////////////////////////////////////////////////////////////////////////// | 69 ////////////////////////////////////////////////////////////////////////////// |
| 64 // WorkspaceLayoutManager, aura::LayoutManager implementation: | 70 // WorkspaceLayoutManager, aura::LayoutManager implementation: |
| 65 | 71 |
| 66 void WorkspaceLayoutManager::OnWindowAddedToLayout(Window* child) { | 72 void WorkspaceLayoutManager::OnWindowAddedToLayout(Window* child) { |
| 67 wm::WindowState* window_state = wm::GetWindowState(child); | 73 wm::WindowState* window_state = wm::GetWindowState(child); |
| 68 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); | 74 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE); |
| 69 window_state->OnWMEvent(&event); | 75 window_state->OnWMEvent(&event); |
| 70 windows_.insert(child); | 76 windows_.insert(child); |
| 71 child->AddObserver(this); | 77 child->AddObserver(this); |
| 72 window_state->AddObserver(this); | 78 window_state->AddObserver(this); |
| 73 UpdateShelfVisibility(); | 79 UpdateShelfVisibility(); |
| 74 UpdateFullscreenState(); | 80 UpdateFullscreenState(); |
| 81 if (backdrop_delegate_) |
| 82 backdrop_delegate_->OnWindowAddedToLayout(child); |
| 75 WindowPositioner::RearrangeVisibleWindowOnShow(child); | 83 WindowPositioner::RearrangeVisibleWindowOnShow(child); |
| 76 } | 84 } |
| 77 | 85 |
| 78 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) { | 86 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) { |
| 79 windows_.erase(child); | 87 windows_.erase(child); |
| 80 child->RemoveObserver(this); | 88 child->RemoveObserver(this); |
| 81 wm::GetWindowState(child)->RemoveObserver(this); | 89 wm::GetWindowState(child)->RemoveObserver(this); |
| 82 | 90 |
| 83 if (child->TargetVisibility()) | 91 if (child->TargetVisibility()) |
| 84 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); | 92 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); |
| 85 } | 93 } |
| 86 | 94 |
| 87 void WorkspaceLayoutManager::OnWindowRemovedFromLayout(Window* child) { | 95 void WorkspaceLayoutManager::OnWindowRemovedFromLayout(Window* child) { |
| 88 UpdateShelfVisibility(); | 96 UpdateShelfVisibility(); |
| 89 UpdateFullscreenState(); | 97 UpdateFullscreenState(); |
| 98 if (backdrop_delegate_) |
| 99 backdrop_delegate_->OnWindowRemovedFromLayout(child); |
| 90 } | 100 } |
| 91 | 101 |
| 92 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child, | 102 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child, |
| 93 bool visible) { | 103 bool visible) { |
| 94 wm::WindowState* window_state = wm::GetWindowState(child); | 104 wm::WindowState* window_state = wm::GetWindowState(child); |
| 95 // Attempting to show a minimized window. Unminimize it. | 105 // Attempting to show a minimized window. Unminimize it. |
| 96 if (visible && window_state->IsMinimized()) | 106 if (visible && window_state->IsMinimized()) |
| 97 window_state->Unminimize(); | 107 window_state->Unminimize(); |
| 98 | 108 |
| 99 if (child->TargetVisibility()) | 109 if (child->TargetVisibility()) |
| 100 WindowPositioner::RearrangeVisibleWindowOnShow(child); | 110 WindowPositioner::RearrangeVisibleWindowOnShow(child); |
| 101 else | 111 else |
| 102 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); | 112 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); |
| 103 UpdateFullscreenState(); | 113 UpdateFullscreenState(); |
| 104 UpdateShelfVisibility(); | 114 UpdateShelfVisibility(); |
| 115 if (backdrop_delegate_) |
| 116 backdrop_delegate_->OnChildWindowVisibilityChanged(child, visible); |
| 105 } | 117 } |
| 106 | 118 |
| 107 void WorkspaceLayoutManager::SetChildBounds( | 119 void WorkspaceLayoutManager::SetChildBounds( |
| 108 Window* child, | 120 Window* child, |
| 109 const gfx::Rect& requested_bounds) { | 121 const gfx::Rect& requested_bounds) { |
| 110 wm::WindowState* window_state = wm::GetWindowState(child); | 122 wm::WindowState* window_state = wm::GetWindowState(child); |
| 111 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds); | 123 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds); |
| 112 window_state->OnWMEvent(&event); | 124 window_state->OnWMEvent(&event); |
| 113 UpdateShelfVisibility(); | 125 UpdateShelfVisibility(); |
| 114 } | 126 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 if (key == aura::client::kAlwaysOnTopKey && | 167 if (key == aura::client::kAlwaysOnTopKey && |
| 156 window->GetProperty(aura::client::kAlwaysOnTopKey)) { | 168 window->GetProperty(aura::client::kAlwaysOnTopKey)) { |
| 157 GetRootWindowController(window->GetRootWindow())-> | 169 GetRootWindowController(window->GetRootWindow())-> |
| 158 always_on_top_controller()->GetContainer(window)->AddChild(window); | 170 always_on_top_controller()->GetContainer(window)->AddChild(window); |
| 159 } | 171 } |
| 160 } | 172 } |
| 161 | 173 |
| 162 void WorkspaceLayoutManager::OnWindowStackingChanged(aura::Window* window) { | 174 void WorkspaceLayoutManager::OnWindowStackingChanged(aura::Window* window) { |
| 163 UpdateShelfVisibility(); | 175 UpdateShelfVisibility(); |
| 164 UpdateFullscreenState(); | 176 UpdateFullscreenState(); |
| 177 if (backdrop_delegate_) |
| 178 backdrop_delegate_->OnWindowStackingChanged(window); |
| 165 } | 179 } |
| 166 | 180 |
| 167 void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) { | 181 void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) { |
| 168 if (root_window_ == window) { | 182 if (root_window_ == window) { |
| 169 root_window_->RemoveObserver(this); | 183 root_window_->RemoveObserver(this); |
| 170 root_window_ = NULL; | 184 root_window_ = NULL; |
| 171 } | 185 } |
| 172 } | 186 } |
| 173 | 187 |
| 174 void WorkspaceLayoutManager::OnWindowBoundsChanged(aura::Window* window, | 188 void WorkspaceLayoutManager::OnWindowBoundsChanged(aura::Window* window, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 203 wm::WindowState* window_state, | 217 wm::WindowState* window_state, |
| 204 wm::WindowStateType old_type) { | 218 wm::WindowStateType old_type) { |
| 205 | 219 |
| 206 // Notify observers that fullscreen state may be changing. | 220 // Notify observers that fullscreen state may be changing. |
| 207 if (window_state->IsFullscreen() || | 221 if (window_state->IsFullscreen() || |
| 208 old_type == wm::WINDOW_STATE_TYPE_FULLSCREEN) { | 222 old_type == wm::WINDOW_STATE_TYPE_FULLSCREEN) { |
| 209 UpdateFullscreenState(); | 223 UpdateFullscreenState(); |
| 210 } | 224 } |
| 211 | 225 |
| 212 UpdateShelfVisibility(); | 226 UpdateShelfVisibility(); |
| 227 if (backdrop_delegate_) |
| 228 backdrop_delegate_->OnPostWindowStateTypeChange(window_state, old_type); |
| 213 } | 229 } |
| 214 | 230 |
| 215 ////////////////////////////////////////////////////////////////////////////// | 231 ////////////////////////////////////////////////////////////////////////////// |
| 216 // WorkspaceLayoutManager, private: | 232 // WorkspaceLayoutManager, private: |
| 217 | 233 |
| 218 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( | 234 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( |
| 219 const wm::WMEvent* event) { | 235 const wm::WMEvent* event) { |
| 220 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED || | 236 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED || |
| 221 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); | 237 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); |
| 222 | 238 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; | 276 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; |
| 261 if (is_fullscreen != is_fullscreen_) { | 277 if (is_fullscreen != is_fullscreen_) { |
| 262 ash::Shell::GetInstance()->NotifyFullscreenStateChange( | 278 ash::Shell::GetInstance()->NotifyFullscreenStateChange( |
| 263 is_fullscreen, window_->GetRootWindow()); | 279 is_fullscreen, window_->GetRootWindow()); |
| 264 is_fullscreen_ = is_fullscreen; | 280 is_fullscreen_ = is_fullscreen; |
| 265 } | 281 } |
| 266 } | 282 } |
| 267 | 283 |
| 268 } // namespace internal | 284 } // namespace internal |
| 269 } // namespace ash | 285 } // namespace ash |
| OLD | NEW |