Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/dock/docked_window_layout_manager.h" | 5 #include "ash/wm/dock/docked_window_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
| 9 #include "ash/shelf/shelf_constants.h" | 9 #include "ash/shelf/shelf_constants.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 params.parent = parent; | 134 params.parent = parent; |
| 135 params.accept_events = false; | 135 params.accept_events = false; |
| 136 set_focus_on_creation(false); | 136 set_focus_on_creation(false); |
| 137 Init(params); | 137 Init(params); |
| 138 SetVisibilityChangedAnimationsEnabled(false); | 138 SetVisibilityChangedAnimationsEnabled(false); |
| 139 GetNativeWindow()->SetProperty(kStayInSameRootWindowKey, true); | 139 GetNativeWindow()->SetProperty(kStayInSameRootWindowKey, true); |
| 140 opaque_background_.SetColor(SK_ColorBLACK); | 140 opaque_background_.SetColor(SK_ColorBLACK); |
| 141 opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size())); | 141 opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size())); |
| 142 opaque_background_.SetOpacity(0.0f); | 142 opaque_background_.SetOpacity(0.0f); |
| 143 GetNativeWindow()->layer()->Add(&opaque_background_); | 143 GetNativeWindow()->layer()->Add(&opaque_background_); |
| 144 Hide(); | |
| 145 | 144 |
| 146 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 145 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 147 gfx::ImageSkia shelf_background = | 146 gfx::ImageSkia shelf_background = |
| 148 *rb.GetImageSkiaNamed(IDR_ASH_SHELF_BACKGROUND); | 147 *rb.GetImageSkiaNamed(IDR_ASH_SHELF_BACKGROUND); |
| 149 shelf_background_left_ = gfx::ImageSkiaOperations::CreateRotatedImage( | 148 shelf_background_left_ = gfx::ImageSkiaOperations::CreateRotatedImage( |
| 150 shelf_background, SkBitmapOperations::ROTATION_90_CW); | 149 shelf_background, SkBitmapOperations::ROTATION_90_CW); |
| 151 shelf_background_right_ = gfx::ImageSkiaOperations::CreateRotatedImage( | 150 shelf_background_right_ = gfx::ImageSkiaOperations::CreateRotatedImage( |
| 152 shelf_background, SkBitmapOperations::ROTATION_270_CW); | 151 shelf_background, SkBitmapOperations::ROTATION_270_CW); |
| 152 | |
| 153 parent->StackChildAtBottom(GetNativeWindow()); | |
| 154 Show(); | |
| 153 } | 155 } |
| 154 | 156 |
| 155 // Transitions to |visible_background_type_| if the widget is visible and to | 157 // Transitions to |visible_background_type_| if the widget is visible and to |
| 156 // SHELF_BACKGROUND_DEFAULT if it is not. | 158 // SHELF_BACKGROUND_DEFAULT if it is not. |
| 157 void UpdateBackground() { | 159 void UpdateBackground() { |
| 158 ShelfBackgroundType background_type = IsVisible() ? | 160 ShelfBackgroundType background_type = IsVisible() ? |
| 159 visible_background_type_ : SHELF_BACKGROUND_DEFAULT; | 161 visible_background_type_ : SHELF_BACKGROUND_DEFAULT; |
| 160 BackgroundAnimatorChangeType change_type = IsVisible() ? | 162 BackgroundAnimatorChangeType change_type = IsVisible() ? |
| 161 visible_background_change_type_ : BACKGROUND_CHANGE_IMMEDIATE; | 163 visible_background_change_type_ : BACKGROUND_CHANGE_IMMEDIATE; |
| 162 | 164 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 shelf_(NULL), | 409 shelf_(NULL), |
| 408 workspace_controller_(workspace_controller), | 410 workspace_controller_(workspace_controller), |
| 409 in_fullscreen_(workspace_controller_->GetWindowState() == | 411 in_fullscreen_(workspace_controller_->GetWindowState() == |
| 410 WORKSPACE_WINDOW_STATE_FULL_SCREEN), | 412 WORKSPACE_WINDOW_STATE_FULL_SCREEN), |
| 411 docked_width_(0), | 413 docked_width_(0), |
| 412 alignment_(DOCKED_ALIGNMENT_NONE), | 414 alignment_(DOCKED_ALIGNMENT_NONE), |
| 413 preferred_alignment_(DOCKED_ALIGNMENT_NONE), | 415 preferred_alignment_(DOCKED_ALIGNMENT_NONE), |
| 414 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN), | 416 event_source_(DOCKED_ACTION_SOURCE_UNKNOWN), |
| 415 last_active_window_(NULL), | 417 last_active_window_(NULL), |
| 416 last_action_time_(base::Time::Now()), | 418 last_action_time_(base::Time::Now()), |
| 417 background_widget_(new DockedBackgroundWidget(dock_container_)) { | 419 background_widget_(nullptr) { |
| 418 DCHECK(dock_container); | 420 DCHECK(dock_container); |
| 419 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 421 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
| 420 AddObserver(this); | 422 AddObserver(this); |
| 421 Shell::GetInstance()->AddShellObserver(this); | 423 Shell::GetInstance()->AddShellObserver(this); |
| 422 } | 424 } |
| 423 | 425 |
| 424 DockedWindowLayoutManager::~DockedWindowLayoutManager() { | 426 DockedWindowLayoutManager::~DockedWindowLayoutManager() { |
| 425 Shutdown(); | 427 Shutdown(); |
| 426 } | 428 } |
| 427 | 429 |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 } | 820 } |
| 819 Relayout(); | 821 Relayout(); |
| 820 UpdateDockBounds(DockedWindowLayoutManagerObserver::SHELF_ALIGNMENT_CHANGED); | 822 UpdateDockBounds(DockedWindowLayoutManagerObserver::SHELF_ALIGNMENT_CHANGED); |
| 821 } | 823 } |
| 822 | 824 |
| 823 ///////////////////////////////////////////////////////////////////////////// | 825 ///////////////////////////////////////////////////////////////////////////// |
| 824 // DockedWindowLayoutManager, ShelfLayoutManagerObserver implementation: | 826 // DockedWindowLayoutManager, ShelfLayoutManagerObserver implementation: |
| 825 void DockedWindowLayoutManager::OnBackgroundUpdated( | 827 void DockedWindowLayoutManager::OnBackgroundUpdated( |
| 826 ShelfBackgroundType background_type, | 828 ShelfBackgroundType background_type, |
| 827 BackgroundAnimatorChangeType change_type) { | 829 BackgroundAnimatorChangeType change_type) { |
| 828 background_widget_->SetBackgroundType(background_type, change_type); | 830 if (background_widget_) |
| 831 background_widget_->SetBackgroundType(background_type, change_type); | |
|
sky
2016/04/13 21:45:42
If you lazily create background_widget_ after this
msw
2016/04/13 23:07:04
Good point; I made DockedBackgroundWidget init the
| |
| 829 } | 832 } |
| 830 | 833 |
| 831 ///////////////////////////////////////////////////////////////////////////// | 834 ///////////////////////////////////////////////////////////////////////////// |
| 832 // DockedWindowLayoutManager, WindowStateObserver implementation: | 835 // DockedWindowLayoutManager, WindowStateObserver implementation: |
| 833 | 836 |
| 834 void DockedWindowLayoutManager::OnPreWindowStateTypeChange( | 837 void DockedWindowLayoutManager::OnPreWindowStateTypeChange( |
| 835 wm::WindowState* window_state, | 838 wm::WindowState* window_state, |
| 836 wm::WindowStateType old_type) { | 839 wm::WindowStateType old_type) { |
| 837 aura::Window* window = window_state->window(); | 840 aura::Window* window = window_state->window(); |
| 838 if (IsPopupOrTransient(window)) | 841 if (IsPopupOrTransient(window)) |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1285 docked_bounds_ = bounds + | 1288 docked_bounds_ = bounds + |
| 1286 dock_container_->GetBoundsInScreen().OffsetFromOrigin(); | 1289 dock_container_->GetBoundsInScreen().OffsetFromOrigin(); |
| 1287 FOR_EACH_OBSERVER( | 1290 FOR_EACH_OBSERVER( |
| 1288 DockedWindowLayoutManagerObserver, | 1291 DockedWindowLayoutManagerObserver, |
| 1289 observer_list_, | 1292 observer_list_, |
| 1290 OnDockBoundsChanging(bounds, reason)); | 1293 OnDockBoundsChanging(bounds, reason)); |
| 1291 // Show or hide background for docked area. | 1294 // Show or hide background for docked area. |
| 1292 gfx::Rect background_bounds(docked_bounds_); | 1295 gfx::Rect background_bounds(docked_bounds_); |
| 1293 if (shelf_observer_) | 1296 if (shelf_observer_) |
| 1294 background_bounds.Subtract(shelf_observer_->shelf_bounds_in_screen()); | 1297 background_bounds.Subtract(shelf_observer_->shelf_bounds_in_screen()); |
| 1295 background_widget_->SetBackgroundBounds(background_bounds, alignment_); | 1298 if (docked_width_ > 0) { |
| 1296 if (docked_width_ > 0) | 1299 if (!background_widget_) |
| 1297 background_widget_->Show(); | 1300 background_widget_.reset(new DockedBackgroundWidget(dock_container_)); |
| 1298 else | 1301 background_widget_->SetBackgroundBounds(background_bounds, alignment_); |
| 1299 background_widget_->Hide(); | 1302 } else if (background_widget_) { |
| 1303 background_widget_.reset(); | |
| 1304 } | |
| 1300 } | 1305 } |
| 1301 | 1306 |
| 1302 void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) { | 1307 void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) { |
| 1303 if (!active_window) { | 1308 if (!active_window) { |
| 1304 if (!last_active_window_) | 1309 if (!last_active_window_) |
| 1305 return; | 1310 return; |
| 1306 active_window = last_active_window_; | 1311 active_window = last_active_window_; |
| 1307 } | 1312 } |
| 1308 | 1313 |
| 1309 // Windows are stacked like a deck of cards: | 1314 // Windows are stacked like a deck of cards: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1359 | 1364 |
| 1360 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1365 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
| 1361 const gfx::Rect& keyboard_bounds) { | 1366 const gfx::Rect& keyboard_bounds) { |
| 1362 // This bounds change will have caused a change to the Shelf which does not | 1367 // This bounds change will have caused a change to the Shelf which does not |
| 1363 // propagate automatically to this class, so manually recalculate bounds. | 1368 // propagate automatically to this class, so manually recalculate bounds. |
| 1364 Relayout(); | 1369 Relayout(); |
| 1365 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1370 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
| 1366 } | 1371 } |
| 1367 | 1372 |
| 1368 } // namespace ash | 1373 } // namespace ash |
| OLD | NEW |