| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
| 9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| 11 #include "ash/shelf/shelf_types.h" | 11 #include "ash/shelf/shelf_types.h" |
| 12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
| 15 #include "ash/wm/coordinate_conversion.h" | 15 #include "ash/wm/coordinate_conversion.h" |
| 16 #include "ash/wm/window_animations.h" | 16 #include "ash/wm/window_animations.h" |
| 17 #include "ash/wm/window_properties.h" | 17 #include "ash/wm/window_properties.h" |
| 18 #include "ash/wm/window_state.h" | 18 #include "ash/wm/window_state.h" |
| 19 #include "ash/wm/window_util.h" | 19 #include "ash/wm/window_util.h" |
| 20 #include "ash/wm/workspace_controller.h" | 20 #include "ash/wm/workspace_controller.h" |
| 21 #include "base/auto_reset.h" | 21 #include "base/auto_reset.h" |
| 22 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 23 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
| 24 #include "grit/ash_resources.h" |
| 24 #include "third_party/skia/include/core/SkColor.h" | 25 #include "third_party/skia/include/core/SkColor.h" |
| 26 #include "third_party/skia/include/core/SkPaint.h" |
| 25 #include "ui/aura/client/activation_client.h" | 27 #include "ui/aura/client/activation_client.h" |
| 26 #include "ui/aura/client/focus_client.h" | 28 #include "ui/aura/client/focus_client.h" |
| 27 #include "ui/aura/client/window_tree_client.h" | 29 #include "ui/aura/client/window_tree_client.h" |
| 28 #include "ui/aura/root_window.h" | 30 #include "ui/aura/root_window.h" |
| 29 #include "ui/aura/window.h" | 31 #include "ui/aura/window.h" |
| 30 #include "ui/aura/window_delegate.h" | 32 #include "ui/aura/window_delegate.h" |
| 33 #include "ui/base/resource/resource_bundle.h" |
| 31 #include "ui/compositor/scoped_layer_animation_settings.h" | 34 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 35 #include "ui/gfx/canvas.h" |
| 36 #include "ui/gfx/image/image_skia_operations.h" |
| 32 #include "ui/gfx/rect.h" | 37 #include "ui/gfx/rect.h" |
| 33 | 38 |
| 34 namespace ash { | 39 namespace ash { |
| 35 namespace internal { | 40 namespace internal { |
| 36 | 41 |
| 37 // Minimum, maximum width of the dock area and a width of the gap | 42 // Minimum, maximum width of the dock area and a width of the gap |
| 38 // static | 43 // static |
| 39 const int DockedWindowLayoutManager::kMaxDockWidth = 360; | 44 const int DockedWindowLayoutManager::kMaxDockWidth = 360; |
| 40 // static | 45 // static |
| 41 const int DockedWindowLayoutManager::kMinDockWidth = 200; | 46 const int DockedWindowLayoutManager::kMinDockWidth = 200; |
| 42 // static | 47 // static |
| 43 const int DockedWindowLayoutManager::kMinDockGap = 2; | 48 const int DockedWindowLayoutManager::kMinDockGap = 2; |
| 44 // static | 49 // static |
| 45 const int DockedWindowLayoutManager::kIdealWidth = 250; | 50 const int DockedWindowLayoutManager::kIdealWidth = 250; |
| 46 const int kMinimumHeight = 250; | 51 const int kMinimumHeight = 250; |
| 47 const int kSlideDurationMs = 120; | 52 const int kSlideDurationMs = 120; |
| 48 const int kFadeDurationMs = 60; | 53 const int kFadeDurationMs = 60; |
| 49 const int kMinimizeDurationMs = 720; | 54 const int kMinimizeDurationMs = 720; |
| 50 | 55 |
| 51 namespace { | 56 class DockedBackgroundWidget : public views::Widget, |
| 57 public internal::BackgroundAnimatorDelegate { |
| 58 public: |
| 59 explicit DockedBackgroundWidget(aura::Window* container) |
| 60 : alignment_(DOCKED_ALIGNMENT_NONE), |
| 61 background_animator_(this, 0, kLauncherBackgroundAlpha), |
| 62 alpha_(0), |
| 63 opaque_background_(ui::LAYER_SOLID_COLOR) { |
| 64 InitWidget(container); |
| 65 } |
| 52 | 66 |
| 53 const SkColor kDockBackgroundColor = SkColorSetARGB(0xff, 0x10, 0x10, 0x10); | 67 // Sets widget bounds and sizes opaque background layer to fill the widget. |
| 54 const float kDockBackgroundOpacity = 0.5f; | 68 void SetBackgroundBounds(const gfx::Rect bounds, DockedAlignment alignment) { |
| 69 SetBounds(bounds); |
| 70 opaque_background_.SetBounds(gfx::Rect(bounds.size())); |
| 71 alignment_ = alignment; |
| 72 } |
| 55 | 73 |
| 56 class DockedBackgroundWidget : public views::Widget { | 74 // Sets the docked area background type and starts transition animation. |
| 57 public: | 75 void SetPaintsBackground( |
| 58 explicit DockedBackgroundWidget(aura::Window* container) { | 76 ShelfBackgroundType background_type, |
| 59 InitWidget(container); | 77 BackgroundAnimatorChangeType change_type) { |
| 78 float target_opacity = |
| 79 (background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f; |
| 80 scoped_ptr<ui::ScopedLayerAnimationSettings> opaque_background_animation; |
| 81 if (change_type != CHANGE_IMMEDIATE) { |
| 82 opaque_background_animation.reset(new ui::ScopedLayerAnimationSettings( |
| 83 opaque_background_.GetAnimator())); |
| 84 opaque_background_animation->SetTransitionDuration( |
| 85 base::TimeDelta::FromMilliseconds(kTimeToSwitchBackgroundMs)); |
| 86 } |
| 87 opaque_background_.SetOpacity(target_opacity); |
| 88 |
| 89 // TODO(varkha): use ui::Layer on both opaque_background and normal |
| 90 // background retire background_animator_ at all. It would be simpler. |
| 91 // See also ShelfWidget::SetPaintsBackground. |
| 92 background_animator_.SetPaintsBackground( |
| 93 background_type != SHELF_BACKGROUND_DEFAULT, |
| 94 change_type); |
| 95 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); |
| 96 } |
| 97 |
| 98 // views::Widget: |
| 99 void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE { |
| 100 const gfx::ImageSkia& launcher_background( |
| 101 alignment_ == DOCKED_ALIGNMENT_LEFT ? |
| 102 launcher_background_left_ : launcher_background_right_); |
| 103 gfx::Rect rect = gfx::Rect(GetWindowBoundsInScreen().size()); |
| 104 SkPaint paint; |
| 105 paint.setAlpha(alpha_); |
| 106 canvas->DrawImageInt( |
| 107 launcher_background, |
| 108 0, 0, launcher_background.width(), launcher_background.height(), |
| 109 alignment_ == DOCKED_ALIGNMENT_LEFT ? |
| 110 rect.width() - launcher_background.width() : 0, 0, |
| 111 launcher_background.width(), rect.height(), |
| 112 false, |
| 113 paint); |
| 114 canvas->DrawImageInt( |
| 115 launcher_background, |
| 116 alignment_ == DOCKED_ALIGNMENT_LEFT ? |
| 117 0 : launcher_background.width() - 1, 0, |
| 118 1, launcher_background.height(), |
| 119 alignment_ == DOCKED_ALIGNMENT_LEFT ? |
| 120 0 : launcher_background.width(), 0, |
| 121 rect.width() - launcher_background.width(), rect.height(), |
| 122 false, |
| 123 paint); |
| 124 } |
| 125 |
| 126 // BackgroundAnimatorDelegate: |
| 127 virtual void UpdateBackground(int alpha) OVERRIDE { |
| 128 alpha_ = alpha; |
| 129 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); |
| 60 } | 130 } |
| 61 | 131 |
| 62 private: | 132 private: |
| 63 void InitWidget(aura::Window* parent) { | 133 void InitWidget(aura::Window* parent) { |
| 64 views::Widget::InitParams params; | 134 views::Widget::InitParams params; |
| 65 params.type = views::Widget::InitParams::TYPE_POPUP; | 135 params.type = views::Widget::InitParams::TYPE_POPUP; |
| 66 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; | 136 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 67 params.can_activate = false; | 137 params.can_activate = false; |
| 68 params.keep_on_top = false; | 138 params.keep_on_top = false; |
| 69 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 139 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 70 params.parent = parent; | 140 params.parent = parent; |
| 71 params.accept_events = false; | 141 params.accept_events = false; |
| 72 set_focus_on_creation(false); | 142 set_focus_on_creation(false); |
| 73 Init(params); | 143 Init(params); |
| 74 GetNativeWindow()->SetProperty(internal::kStayInSameRootWindowKey, true); | 144 GetNativeWindow()->SetProperty(internal::kStayInSameRootWindowKey, true); |
| 75 DCHECK_EQ(GetNativeView()->GetRootWindow(), parent->GetRootWindow()); | 145 opaque_background_.SetColor(SK_ColorBLACK); |
| 76 views::View* content_view = new views::View; | 146 opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size())); |
| 77 content_view->set_background( | 147 opaque_background_.SetOpacity(0.0f); |
| 78 views::Background::CreateSolidBackground(kDockBackgroundColor)); | 148 GetNativeWindow()->layer()->Add(&opaque_background_); |
| 79 SetContentsView(content_view); | |
| 80 Hide(); | 149 Hide(); |
| 150 |
| 151 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 152 gfx::ImageSkia launcher_background = |
| 153 *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND); |
| 154 launcher_background_left_ = gfx::ImageSkiaOperations::CreateRotatedImage( |
| 155 launcher_background, SkBitmapOperations::ROTATION_90_CW); |
| 156 launcher_background_right_ = gfx::ImageSkiaOperations::CreateRotatedImage( |
| 157 launcher_background, SkBitmapOperations::ROTATION_270_CW); |
| 81 } | 158 } |
| 82 | 159 |
| 160 DockedAlignment alignment_; |
| 161 |
| 162 // The animator for the background transitions. |
| 163 internal::BackgroundAnimator background_animator_; |
| 164 |
| 165 // The alpha to use for drawing image assets covering the docked background. |
| 166 int alpha_; |
| 167 |
| 168 // Solid black background that can be made fully opaque. |
| 169 ui::Layer opaque_background_; |
| 170 |
| 171 // Backgrounds created from shelf background by 90 or 270 degree rotation. |
| 172 gfx::ImageSkia launcher_background_left_; |
| 173 gfx::ImageSkia launcher_background_right_; |
| 174 |
| 83 DISALLOW_COPY_AND_ASSIGN(DockedBackgroundWidget); | 175 DISALLOW_COPY_AND_ASSIGN(DockedBackgroundWidget); |
| 84 }; | 176 }; |
| 85 | 177 |
| 178 namespace { |
| 179 |
| 86 // Returns true if a window is a popup or a transient child. | 180 // Returns true if a window is a popup or a transient child. |
| 87 bool IsPopupOrTransient(const aura::Window* window) { | 181 bool IsPopupOrTransient(const aura::Window* window) { |
| 88 return (window->type() == aura::client::WINDOW_TYPE_POPUP || | 182 return (window->type() == aura::client::WINDOW_TYPE_POPUP || |
| 89 window->transient_parent()); | 183 window->transient_parent()); |
| 90 } | 184 } |
| 91 | 185 |
| 92 // Certain windows (minimized, hidden or popups) do not matter to docking. | 186 // Certain windows (minimized, hidden or popups) do not matter to docking. |
| 93 bool IsUsedByLayout(const aura::Window* window) { | 187 bool IsUsedByLayout(const aura::Window* window) { |
| 94 return (window->IsVisible() && | 188 return (window->IsVisible() && |
| 95 !wm::GetWindowState(window)->IsMinimized() && | 189 !wm::GetWindowState(window)->IsMinimized() && |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 312 } |
| 219 | 313 |
| 220 private: | 314 private: |
| 221 aura::Window* dragged_window_; | 315 aura::Window* dragged_window_; |
| 222 float delta_; | 316 float delta_; |
| 223 }; | 317 }; |
| 224 | 318 |
| 225 } // namespace | 319 } // namespace |
| 226 | 320 |
| 227 //////////////////////////////////////////////////////////////////////////////// | 321 //////////////////////////////////////////////////////////////////////////////// |
| 228 // DockLayoutManager public implementation: | 322 // DockedWindowLayoutManager public implementation: |
| 229 DockedWindowLayoutManager::DockedWindowLayoutManager( | 323 DockedWindowLayoutManager::DockedWindowLayoutManager( |
| 230 aura::Window* dock_container, WorkspaceController* workspace_controller) | 324 aura::Window* dock_container, WorkspaceController* workspace_controller) |
| 231 : dock_container_(dock_container), | 325 : dock_container_(dock_container), |
| 232 in_layout_(false), | 326 in_layout_(false), |
| 233 dragged_window_(NULL), | 327 dragged_window_(NULL), |
| 234 is_dragged_window_docked_(false), | 328 is_dragged_window_docked_(false), |
| 235 is_dragged_from_dock_(false), | 329 is_dragged_from_dock_(false), |
| 236 launcher_(NULL), | 330 launcher_(NULL), |
| 237 workspace_controller_(workspace_controller), | 331 workspace_controller_(workspace_controller), |
| 238 in_fullscreen_(workspace_controller_->GetWindowState() == | 332 in_fullscreen_(workspace_controller_->GetWindowState() == |
| 239 WORKSPACE_WINDOW_STATE_FULL_SCREEN), | 333 WORKSPACE_WINDOW_STATE_FULL_SCREEN), |
| 240 docked_width_(0), | 334 docked_width_(0), |
| 241 alignment_(DOCKED_ALIGNMENT_NONE), | 335 alignment_(DOCKED_ALIGNMENT_NONE), |
| 242 last_active_window_(NULL), | 336 last_active_window_(NULL), |
| 243 last_action_time_(base::Time::Now()), | 337 last_action_time_(base::Time::Now()), |
| 244 background_widget_(new DockedBackgroundWidget(dock_container_)) { | 338 background_widget_(new DockedBackgroundWidget(dock_container_)) { |
| 245 DCHECK(dock_container); | 339 DCHECK(dock_container); |
| 246 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 340 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
| 247 AddObserver(this); | 341 AddObserver(this); |
| 248 Shell::GetInstance()->AddShellObserver(this); | 342 Shell::GetInstance()->AddShellObserver(this); |
| 249 } | 343 } |
| 250 | 344 |
| 251 DockedWindowLayoutManager::~DockedWindowLayoutManager() { | 345 DockedWindowLayoutManager::~DockedWindowLayoutManager() { |
| 252 Shutdown(); | 346 Shutdown(); |
| 253 } | 347 } |
| 254 | 348 |
| 255 void DockedWindowLayoutManager::Shutdown() { | 349 void DockedWindowLayoutManager::Shutdown() { |
| 350 if (launcher_ && launcher_->shelf_widget()) { |
| 351 ShelfLayoutManager* shelf_layout_manager = ShelfLayoutManager::ForLauncher( |
| 352 launcher_->shelf_widget()->GetNativeWindow()); |
| 353 shelf_layout_manager->RemoveObserver(this); |
| 354 } |
| 256 launcher_ = NULL; | 355 launcher_ = NULL; |
| 257 for (size_t i = 0; i < dock_container_->children().size(); ++i) { | 356 for (size_t i = 0; i < dock_container_->children().size(); ++i) { |
| 258 aura::Window* child = dock_container_->children()[i]; | 357 aura::Window* child = dock_container_->children()[i]; |
| 259 child->RemoveObserver(this); | 358 child->RemoveObserver(this); |
| 260 wm::GetWindowState(child)->RemoveObserver(this); | 359 wm::GetWindowState(child)->RemoveObserver(this); |
| 261 } | 360 } |
| 262 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 361 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
| 263 RemoveObserver(this); | 362 RemoveObserver(this); |
| 264 Shell::GetInstance()->RemoveShellObserver(this); | 363 Shell::GetInstance()->RemoveShellObserver(this); |
| 265 } | 364 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 dragged_window_ = NULL; | 425 dragged_window_ = NULL; |
| 327 dragged_bounds_ = gfx::Rect(); | 426 dragged_bounds_ = gfx::Rect(); |
| 328 Relayout(); | 427 Relayout(); |
| 329 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 428 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| 330 RecordUmaAction(action, source); | 429 RecordUmaAction(action, source); |
| 331 } | 430 } |
| 332 | 431 |
| 333 void DockedWindowLayoutManager::SetLauncher(ash::Launcher* launcher) { | 432 void DockedWindowLayoutManager::SetLauncher(ash::Launcher* launcher) { |
| 334 DCHECK(!launcher_); | 433 DCHECK(!launcher_); |
| 335 launcher_ = launcher; | 434 launcher_ = launcher; |
| 435 if (launcher_->shelf_widget()) { |
| 436 ShelfLayoutManager* shelf_layout_manager = ShelfLayoutManager::ForLauncher( |
| 437 launcher_->shelf_widget()->GetNativeWindow()); |
| 438 shelf_layout_manager->AddObserver(this); |
| 439 } |
| 336 } | 440 } |
| 337 | 441 |
| 338 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( | 442 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( |
| 339 const aura::Window* window) const { | 443 const aura::Window* window) const { |
| 340 const gfx::Rect& bounds(window->GetBoundsInScreen()); | 444 const gfx::Rect& bounds(window->GetBoundsInScreen()); |
| 341 | 445 |
| 342 // Test overlap with an existing docked area first. | 446 // Test overlap with an existing docked area first. |
| 343 if (docked_bounds_.Intersects(bounds) && | 447 if (docked_bounds_.Intersects(bounds) && |
| 344 alignment_ != DOCKED_ALIGNMENT_NONE) { | 448 alignment_ != DOCKED_ALIGNMENT_NONE) { |
| 345 // A window is being added to other docked windows (on the same side). | 449 // A window is being added to other docked windows (on the same side). |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 if (launcher_) | 515 if (launcher_) |
| 412 shelf_alignment = launcher_->alignment(); | 516 shelf_alignment = launcher_->alignment(); |
| 413 if ((edge == SNAP_LEFT && shelf_alignment == SHELF_ALIGNMENT_LEFT) || | 517 if ((edge == SNAP_LEFT && shelf_alignment == SHELF_ALIGNMENT_LEFT) || |
| 414 (edge == SNAP_RIGHT && shelf_alignment == SHELF_ALIGNMENT_RIGHT)) { | 518 (edge == SNAP_RIGHT && shelf_alignment == SHELF_ALIGNMENT_RIGHT)) { |
| 415 return false; | 519 return false; |
| 416 } | 520 } |
| 417 return true; | 521 return true; |
| 418 } | 522 } |
| 419 | 523 |
| 420 //////////////////////////////////////////////////////////////////////////////// | 524 //////////////////////////////////////////////////////////////////////////////// |
| 421 // DockLayoutManager, aura::LayoutManager implementation: | 525 // DockedWindowLayoutManager, aura::LayoutManager implementation: |
| 422 void DockedWindowLayoutManager::OnWindowResized() { | 526 void DockedWindowLayoutManager::OnWindowResized() { |
| 423 MaybeMinimizeChildrenExcept(dragged_window_); | 527 MaybeMinimizeChildrenExcept(dragged_window_); |
| 424 Relayout(); | 528 Relayout(); |
| 425 // When screen resizes update the insets even when dock width or alignment | 529 // When screen resizes update the insets even when dock width or alignment |
| 426 // does not change. | 530 // does not change. |
| 427 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_RESIZED); | 531 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_RESIZED); |
| 428 } | 532 } |
| 429 | 533 |
| 430 void DockedWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 534 void DockedWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| 431 if (IsPopupOrTransient(child)) | 535 if (IsPopupOrTransient(child)) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 SetChildBoundsDirect(child, requested_bounds); | 589 SetChildBoundsDirect(child, requested_bounds); |
| 486 if (IsPopupOrTransient(child)) | 590 if (IsPopupOrTransient(child)) |
| 487 return; | 591 return; |
| 488 ShelfLayoutManager* shelf_layout = internal::ShelfLayoutManager::ForLauncher( | 592 ShelfLayoutManager* shelf_layout = internal::ShelfLayoutManager::ForLauncher( |
| 489 dock_container_); | 593 dock_container_); |
| 490 if (shelf_layout) | 594 if (shelf_layout) |
| 491 shelf_layout->UpdateVisibilityState(); | 595 shelf_layout->UpdateVisibilityState(); |
| 492 } | 596 } |
| 493 | 597 |
| 494 //////////////////////////////////////////////////////////////////////////////// | 598 //////////////////////////////////////////////////////////////////////////////// |
| 495 // DockLayoutManager, ash::ShellObserver implementation: | 599 // DockedWindowLayoutManager, ash::ShellObserver implementation: |
| 496 | 600 |
| 497 void DockedWindowLayoutManager::OnDisplayWorkAreaInsetsChanged() { | 601 void DockedWindowLayoutManager::OnDisplayWorkAreaInsetsChanged() { |
| 498 Relayout(); | 602 Relayout(); |
| 499 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); | 603 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); |
| 500 MaybeMinimizeChildrenExcept(dragged_window_); | 604 MaybeMinimizeChildrenExcept(dragged_window_); |
| 501 } | 605 } |
| 502 | 606 |
| 503 void DockedWindowLayoutManager::OnFullscreenStateChanged( | 607 void DockedWindowLayoutManager::OnFullscreenStateChanged( |
| 504 bool is_fullscreen, aura::Window* root_window) { | 608 bool is_fullscreen, aura::Window* root_window) { |
| 505 if (dock_container_->GetRootWindow() != root_window) | 609 if (dock_container_->GetRootWindow() != root_window) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 alignment_ = DOCKED_ALIGNMENT_RIGHT; | 655 alignment_ = DOCKED_ALIGNMENT_RIGHT; |
| 552 } else if (alignment_ == DOCKED_ALIGNMENT_RIGHT && | 656 } else if (alignment_ == DOCKED_ALIGNMENT_RIGHT && |
| 553 shelf_alignment == SHELF_ALIGNMENT_RIGHT) { | 657 shelf_alignment == SHELF_ALIGNMENT_RIGHT) { |
| 554 alignment_ = DOCKED_ALIGNMENT_LEFT; | 658 alignment_ = DOCKED_ALIGNMENT_LEFT; |
| 555 } | 659 } |
| 556 Relayout(); | 660 Relayout(); |
| 557 UpdateDockBounds(DockedWindowLayoutManagerObserver::SHELF_ALIGNMENT_CHANGED); | 661 UpdateDockBounds(DockedWindowLayoutManagerObserver::SHELF_ALIGNMENT_CHANGED); |
| 558 } | 662 } |
| 559 | 663 |
| 560 ///////////////////////////////////////////////////////////////////////////// | 664 ///////////////////////////////////////////////////////////////////////////// |
| 561 // DockLayoutManager, WindowStateObserver implementation: | 665 // DockedWindowLayoutManager, ShelfLayoutManagerObserver implementation: |
| 666 void DockedWindowLayoutManager::OnBackgroundUpdated( |
| 667 ShelfBackgroundType background_type, |
| 668 BackgroundAnimatorChangeType change_type) { |
| 669 background_widget_->SetPaintsBackground(background_type, change_type); |
| 670 } |
| 671 |
| 672 ///////////////////////////////////////////////////////////////////////////// |
| 673 // DockedWindowLayoutManager, WindowStateObserver implementation: |
| 562 | 674 |
| 563 void DockedWindowLayoutManager::OnWindowShowTypeChanged( | 675 void DockedWindowLayoutManager::OnWindowShowTypeChanged( |
| 564 wm::WindowState* window_state, | 676 wm::WindowState* window_state, |
| 565 wm::WindowShowType old_type) { | 677 wm::WindowShowType old_type) { |
| 566 aura::Window* window = window_state->window(); | 678 aura::Window* window = window_state->window(); |
| 567 if (IsPopupOrTransient(window)) | 679 if (IsPopupOrTransient(window)) |
| 568 return; | 680 return; |
| 569 // The window property will still be set, but no actual change will occur | 681 // The window property will still be set, but no actual change will occur |
| 570 // until OnFullscreenStateChange is called when exiting fullscreen. | 682 // until OnFullscreenStateChange is called when exiting fullscreen. |
| 571 if (in_fullscreen_) | 683 if (in_fullscreen_) |
| 572 return; | 684 return; |
| 573 if (window_state->IsMinimized()) { | 685 if (window_state->IsMinimized()) { |
| 574 MinimizeDockedWindow(window_state); | 686 MinimizeDockedWindow(window_state); |
| 575 } else if (window_state->IsMaximizedOrFullscreen() || | 687 } else if (window_state->IsMaximizedOrFullscreen() || |
| 576 window_state->IsSnapped()) { | 688 window_state->IsSnapped()) { |
| 577 if (window != dragged_window_) { | 689 if (window != dragged_window_) { |
| 578 UndockWindow(window); | 690 UndockWindow(window); |
| 579 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); | 691 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
| 580 } | 692 } |
| 581 } else if (old_type == wm::SHOW_TYPE_MINIMIZED) { | 693 } else if (old_type == wm::SHOW_TYPE_MINIMIZED) { |
| 582 RestoreDockedWindow(window_state); | 694 RestoreDockedWindow(window_state); |
| 583 } | 695 } |
| 584 } | 696 } |
| 585 | 697 |
| 586 ///////////////////////////////////////////////////////////////////////////// | 698 ///////////////////////////////////////////////////////////////////////////// |
| 587 // DockLayoutManager, WindowObserver implementation: | 699 // DockedWindowLayoutManager, WindowObserver implementation: |
| 588 | 700 |
| 589 void DockedWindowLayoutManager::OnWindowBoundsChanged( | 701 void DockedWindowLayoutManager::OnWindowBoundsChanged( |
| 590 aura::Window* window, | 702 aura::Window* window, |
| 591 const gfx::Rect& old_bounds, | 703 const gfx::Rect& old_bounds, |
| 592 const gfx::Rect& new_bounds) { | 704 const gfx::Rect& new_bounds) { |
| 593 // Only relayout if the dragged window would get docked. | 705 // Only relayout if the dragged window would get docked. |
| 594 if (window == dragged_window_ && is_dragged_window_docked_) | 706 if (window == dragged_window_ && is_dragged_window_docked_) |
| 595 Relayout(); | 707 Relayout(); |
| 596 } | 708 } |
| 597 | 709 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 616 DCHECK(!dragged_window_); | 728 DCHECK(!dragged_window_); |
| 617 DCHECK (!is_dragged_window_docked_); | 729 DCHECK (!is_dragged_window_docked_); |
| 618 } | 730 } |
| 619 if (window == last_active_window_) | 731 if (window == last_active_window_) |
| 620 last_active_window_ = NULL; | 732 last_active_window_ = NULL; |
| 621 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN); | 733 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN); |
| 622 } | 734 } |
| 623 | 735 |
| 624 | 736 |
| 625 //////////////////////////////////////////////////////////////////////////////// | 737 //////////////////////////////////////////////////////////////////////////////// |
| 626 // DockLayoutManager, aura::client::ActivationChangeObserver implementation: | 738 // DockedWindowLayoutManager, aura::client::ActivationChangeObserver |
| 739 // implementation: |
| 627 | 740 |
| 628 void DockedWindowLayoutManager::OnWindowActivated(aura::Window* gained_active, | 741 void DockedWindowLayoutManager::OnWindowActivated(aura::Window* gained_active, |
| 629 aura::Window* lost_active) { | 742 aura::Window* lost_active) { |
| 630 if (gained_active && IsPopupOrTransient(gained_active)) | 743 if (gained_active && IsPopupOrTransient(gained_active)) |
| 631 return; | 744 return; |
| 632 // Ignore if the window that is not managed by this was activated. | 745 // Ignore if the window that is not managed by this was activated. |
| 633 aura::Window* ancestor = NULL; | 746 aura::Window* ancestor = NULL; |
| 634 for (aura::Window* parent = gained_active; | 747 for (aura::Window* parent = gained_active; |
| 635 parent; parent = parent->parent()) { | 748 parent; parent = parent->parent()) { |
| 636 if (parent->parent() == dock_container_) { | 749 if (parent->parent() == dock_container_) { |
| 637 ancestor = parent; | 750 ancestor = parent; |
| 638 break; | 751 break; |
| 639 } | 752 } |
| 640 } | 753 } |
| 641 if (ancestor) | 754 if (ancestor) |
| 642 UpdateStacking(ancestor); | 755 UpdateStacking(ancestor); |
| 643 } | 756 } |
| 644 | 757 |
| 645 //////////////////////////////////////////////////////////////////////////////// | 758 //////////////////////////////////////////////////////////////////////////////// |
| 646 // DockLayoutManager private implementation: | 759 // DockedWindowLayoutManager private implementation: |
| 647 | 760 |
| 648 void DockedWindowLayoutManager::MaybeMinimizeChildrenExcept( | 761 void DockedWindowLayoutManager::MaybeMinimizeChildrenExcept( |
| 649 aura::Window* child) { | 762 aura::Window* child) { |
| 650 // Minimize any windows that don't fit without overlap. | 763 // Minimize any windows that don't fit without overlap. |
| 651 const gfx::Rect work_area = | 764 const gfx::Rect work_area = |
| 652 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); | 765 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); |
| 653 int available_room = work_area.height() - kMinDockGap; | 766 int available_room = work_area.height() - kMinDockGap; |
| 654 if (child) | 767 if (child) |
| 655 available_room -= (GetWindowHeightCloseTo(child, 0) + kMinDockGap); | 768 available_room -= (GetWindowHeightCloseTo(child, 0) + kMinDockGap); |
| 656 // Use a copy of children array because a call to Minimize can change order. | 769 // Use a copy of children array because a call to Minimize can change order. |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 dock_container_->bounds().y(), | 1104 dock_container_->bounds().y(), |
| 992 dock_inset, | 1105 dock_inset, |
| 993 work_area.height()); | 1106 work_area.height()); |
| 994 docked_bounds_ = bounds + | 1107 docked_bounds_ = bounds + |
| 995 dock_container_->GetBoundsInScreen().OffsetFromOrigin(); | 1108 dock_container_->GetBoundsInScreen().OffsetFromOrigin(); |
| 996 FOR_EACH_OBSERVER( | 1109 FOR_EACH_OBSERVER( |
| 997 DockedWindowLayoutManagerObserver, | 1110 DockedWindowLayoutManagerObserver, |
| 998 observer_list_, | 1111 observer_list_, |
| 999 OnDockBoundsChanging(bounds, reason)); | 1112 OnDockBoundsChanging(bounds, reason)); |
| 1000 // Show or hide background for docked area. | 1113 // Show or hide background for docked area. |
| 1001 background_widget_->SetBounds(docked_bounds_); | 1114 background_widget_->SetBackgroundBounds(docked_bounds_, alignment_); |
| 1002 if (docked_width_ > 0) { | 1115 if (docked_width_ > 0) |
| 1003 background_widget_->Show(); | 1116 background_widget_->Show(); |
| 1004 background_widget_->GetNativeWindow()->layer()->SetOpacity( | 1117 else |
| 1005 kDockBackgroundOpacity); | |
| 1006 } else { | |
| 1007 background_widget_->Hide(); | 1118 background_widget_->Hide(); |
| 1008 } | |
| 1009 } | 1119 } |
| 1010 | 1120 |
| 1011 void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) { | 1121 void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) { |
| 1012 if (!active_window) { | 1122 if (!active_window) { |
| 1013 if (!last_active_window_) | 1123 if (!last_active_window_) |
| 1014 return; | 1124 return; |
| 1015 active_window = last_active_window_; | 1125 active_window = last_active_window_; |
| 1016 } | 1126 } |
| 1017 | 1127 |
| 1018 // Windows are stacked like a deck of cards: | 1128 // Windows are stacked like a deck of cards: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1179 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
| 1070 const gfx::Rect& keyboard_bounds) { | 1180 const gfx::Rect& keyboard_bounds) { |
| 1071 // This bounds change will have caused a change to the Shelf which does not | 1181 // This bounds change will have caused a change to the Shelf which does not |
| 1072 // propagate automatically to this class, so manually recalculate bounds. | 1182 // propagate automatically to this class, so manually recalculate bounds. |
| 1073 Relayout(); | 1183 Relayout(); |
| 1074 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1184 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
| 1075 } | 1185 } |
| 1076 | 1186 |
| 1077 } // namespace internal | 1187 } // namespace internal |
| 1078 } // namespace ash | 1188 } // namespace ash |
| OLD | NEW |