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" | |
9 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shelf/shelf.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" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // background retire background_animator_ at all. It would be simpler. | 91 // background retire background_animator_ at all. It would be simpler. |
92 // See also ShelfWidget::SetPaintsBackground. | 92 // See also ShelfWidget::SetPaintsBackground. |
93 background_animator_.SetPaintsBackground( | 93 background_animator_.SetPaintsBackground( |
94 background_type != SHELF_BACKGROUND_DEFAULT, | 94 background_type != SHELF_BACKGROUND_DEFAULT, |
95 change_type); | 95 change_type); |
96 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); | 96 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); |
97 } | 97 } |
98 | 98 |
99 // views::Widget: | 99 // views::Widget: |
100 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE { | 100 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE { |
101 const gfx::ImageSkia& launcher_background( | 101 const gfx::ImageSkia& shelf_background( |
102 alignment_ == DOCKED_ALIGNMENT_LEFT ? | 102 alignment_ == DOCKED_ALIGNMENT_LEFT ? |
103 launcher_background_left_ : launcher_background_right_); | 103 shelf_background_left_ : shelf_background_right_); |
104 gfx::Rect rect = gfx::Rect(GetWindowBoundsInScreen().size()); | 104 gfx::Rect rect = gfx::Rect(GetWindowBoundsInScreen().size()); |
105 SkPaint paint; | 105 SkPaint paint; |
106 paint.setAlpha(alpha_); | 106 paint.setAlpha(alpha_); |
| 107 canvas->DrawImageInt(shelf_background, |
| 108 0, |
| 109 0, |
| 110 shelf_background.width(), |
| 111 shelf_background.height(), |
| 112 alignment_ == DOCKED_ALIGNMENT_LEFT |
| 113 ? rect.width() - shelf_background.width() |
| 114 : 0, |
| 115 0, |
| 116 shelf_background.width(), |
| 117 rect.height(), |
| 118 false, |
| 119 paint); |
107 canvas->DrawImageInt( | 120 canvas->DrawImageInt( |
108 launcher_background, | 121 shelf_background, |
109 0, 0, launcher_background.width(), launcher_background.height(), | 122 alignment_ == DOCKED_ALIGNMENT_LEFT ? 0 : shelf_background.width() - 1, |
110 alignment_ == DOCKED_ALIGNMENT_LEFT ? | 123 0, |
111 rect.width() - launcher_background.width() : 0, 0, | 124 1, |
112 launcher_background.width(), rect.height(), | 125 shelf_background.height(), |
113 false, | 126 alignment_ == DOCKED_ALIGNMENT_LEFT ? 0 : shelf_background.width(), |
114 paint); | 127 0, |
115 canvas->DrawImageInt( | 128 rect.width() - shelf_background.width(), |
116 launcher_background, | 129 rect.height(), |
117 alignment_ == DOCKED_ALIGNMENT_LEFT ? | |
118 0 : launcher_background.width() - 1, 0, | |
119 1, launcher_background.height(), | |
120 alignment_ == DOCKED_ALIGNMENT_LEFT ? | |
121 0 : launcher_background.width(), 0, | |
122 rect.width() - launcher_background.width(), rect.height(), | |
123 false, | 130 false, |
124 paint); | 131 paint); |
125 } | 132 } |
126 | 133 |
127 // BackgroundAnimatorDelegate: | 134 // BackgroundAnimatorDelegate: |
128 virtual void UpdateBackground(int alpha) OVERRIDE { | 135 virtual void UpdateBackground(int alpha) OVERRIDE { |
129 alpha_ = alpha; | 136 alpha_ = alpha; |
130 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); | 137 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); |
131 } | 138 } |
132 | 139 |
(...skipping 10 matching lines...) Expand all Loading... |
143 set_focus_on_creation(false); | 150 set_focus_on_creation(false); |
144 Init(params); | 151 Init(params); |
145 GetNativeWindow()->SetProperty(internal::kStayInSameRootWindowKey, true); | 152 GetNativeWindow()->SetProperty(internal::kStayInSameRootWindowKey, true); |
146 opaque_background_.SetColor(SK_ColorBLACK); | 153 opaque_background_.SetColor(SK_ColorBLACK); |
147 opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size())); | 154 opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size())); |
148 opaque_background_.SetOpacity(0.0f); | 155 opaque_background_.SetOpacity(0.0f); |
149 GetNativeWindow()->layer()->Add(&opaque_background_); | 156 GetNativeWindow()->layer()->Add(&opaque_background_); |
150 Hide(); | 157 Hide(); |
151 | 158 |
152 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 159 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
153 gfx::ImageSkia launcher_background = | 160 gfx::ImageSkia shelf_background = |
154 *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND); | 161 *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND); |
155 launcher_background_left_ = gfx::ImageSkiaOperations::CreateRotatedImage( | 162 shelf_background_left_ = gfx::ImageSkiaOperations::CreateRotatedImage( |
156 launcher_background, SkBitmapOperations::ROTATION_90_CW); | 163 shelf_background, SkBitmapOperations::ROTATION_90_CW); |
157 launcher_background_right_ = gfx::ImageSkiaOperations::CreateRotatedImage( | 164 shelf_background_right_ = gfx::ImageSkiaOperations::CreateRotatedImage( |
158 launcher_background, SkBitmapOperations::ROTATION_270_CW); | 165 shelf_background, SkBitmapOperations::ROTATION_270_CW); |
159 } | 166 } |
160 | 167 |
161 DockedAlignment alignment_; | 168 DockedAlignment alignment_; |
162 | 169 |
163 // The animator for the background transitions. | 170 // The animator for the background transitions. |
164 internal::BackgroundAnimator background_animator_; | 171 internal::BackgroundAnimator background_animator_; |
165 | 172 |
166 // The alpha to use for drawing image assets covering the docked background. | 173 // The alpha to use for drawing image assets covering the docked background. |
167 int alpha_; | 174 int alpha_; |
168 | 175 |
169 // Solid black background that can be made fully opaque. | 176 // Solid black background that can be made fully opaque. |
170 ui::Layer opaque_background_; | 177 ui::Layer opaque_background_; |
171 | 178 |
172 // Backgrounds created from shelf background by 90 or 270 degree rotation. | 179 // Backgrounds created from shelf background by 90 or 270 degree rotation. |
173 gfx::ImageSkia launcher_background_left_; | 180 gfx::ImageSkia shelf_background_left_; |
174 gfx::ImageSkia launcher_background_right_; | 181 gfx::ImageSkia shelf_background_right_; |
175 | 182 |
176 DISALLOW_COPY_AND_ASSIGN(DockedBackgroundWidget); | 183 DISALLOW_COPY_AND_ASSIGN(DockedBackgroundWidget); |
177 }; | 184 }; |
178 | 185 |
179 namespace { | 186 namespace { |
180 | 187 |
181 // Returns true if a window is a popup or a transient child. | 188 // Returns true if a window is a popup or a transient child. |
182 bool IsPopupOrTransient(const aura::Window* window) { | 189 bool IsPopupOrTransient(const aura::Window* window) { |
183 return (window->type() == aura::client::WINDOW_TYPE_POPUP || | 190 return (window->type() == aura::client::WINDOW_TYPE_POPUP || |
184 window->transient_parent()); | 191 window->transient_parent()); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 } | 320 } |
314 | 321 |
315 private: | 322 private: |
316 aura::Window* dragged_window_; | 323 aura::Window* dragged_window_; |
317 float delta_; | 324 float delta_; |
318 }; | 325 }; |
319 | 326 |
320 } // namespace | 327 } // namespace |
321 | 328 |
322 //////////////////////////////////////////////////////////////////////////////// | 329 //////////////////////////////////////////////////////////////////////////////// |
323 // A class that observes launcher shelf for bounds changes. | 330 // A class that observes shelf for bounds changes. |
324 class DockedWindowLayoutManager::ShelfWindowObserver : public WindowObserver { | 331 class DockedWindowLayoutManager::ShelfWindowObserver : public WindowObserver { |
325 public: | 332 public: |
326 explicit ShelfWindowObserver( | 333 explicit ShelfWindowObserver( |
327 DockedWindowLayoutManager* docked_layout_manager) | 334 DockedWindowLayoutManager* docked_layout_manager) |
328 : docked_layout_manager_(docked_layout_manager) { | 335 : docked_layout_manager_(docked_layout_manager) { |
329 DCHECK(docked_layout_manager_->launcher()->shelf_widget()); | 336 DCHECK(docked_layout_manager_->shelf()->shelf_widget()); |
330 docked_layout_manager_->launcher()->shelf_widget()->GetNativeView() | 337 docked_layout_manager_->shelf()->shelf_widget()->GetNativeView() |
331 ->AddObserver(this); | 338 ->AddObserver(this); |
332 } | 339 } |
333 | 340 |
334 virtual ~ShelfWindowObserver() { | 341 virtual ~ShelfWindowObserver() { |
335 if (docked_layout_manager_->launcher() && | 342 if (docked_layout_manager_->shelf() && |
336 docked_layout_manager_->launcher()->shelf_widget()) | 343 docked_layout_manager_->shelf()->shelf_widget()) |
337 docked_layout_manager_->launcher()->shelf_widget()->GetNativeView() | 344 docked_layout_manager_->shelf()->shelf_widget()->GetNativeView() |
338 ->RemoveObserver(this); | 345 ->RemoveObserver(this); |
339 } | 346 } |
340 | 347 |
341 // aura::WindowObserver: | 348 // aura::WindowObserver: |
342 virtual void OnWindowBoundsChanged(aura::Window* window, | 349 virtual void OnWindowBoundsChanged(aura::Window* window, |
343 const gfx::Rect& old_bounds, | 350 const gfx::Rect& old_bounds, |
344 const gfx::Rect& new_bounds) OVERRIDE { | 351 const gfx::Rect& new_bounds) OVERRIDE { |
345 shelf_bounds_in_screen_ = ScreenAsh::ConvertRectToScreen( | 352 shelf_bounds_in_screen_ = ScreenAsh::ConvertRectToScreen( |
346 window->parent(), new_bounds); | 353 window->parent(), new_bounds); |
347 docked_layout_manager_->OnShelfBoundsChanged(); | 354 docked_layout_manager_->OnShelfBoundsChanged(); |
(...skipping 12 matching lines...) Expand all Loading... |
360 | 367 |
361 //////////////////////////////////////////////////////////////////////////////// | 368 //////////////////////////////////////////////////////////////////////////////// |
362 // DockedWindowLayoutManager public implementation: | 369 // DockedWindowLayoutManager public implementation: |
363 DockedWindowLayoutManager::DockedWindowLayoutManager( | 370 DockedWindowLayoutManager::DockedWindowLayoutManager( |
364 aura::Window* dock_container, WorkspaceController* workspace_controller) | 371 aura::Window* dock_container, WorkspaceController* workspace_controller) |
365 : dock_container_(dock_container), | 372 : dock_container_(dock_container), |
366 in_layout_(false), | 373 in_layout_(false), |
367 dragged_window_(NULL), | 374 dragged_window_(NULL), |
368 is_dragged_window_docked_(false), | 375 is_dragged_window_docked_(false), |
369 is_dragged_from_dock_(false), | 376 is_dragged_from_dock_(false), |
370 launcher_(NULL), | 377 shelf_(NULL), |
371 workspace_controller_(workspace_controller), | 378 workspace_controller_(workspace_controller), |
372 in_fullscreen_(workspace_controller_->GetWindowState() == | 379 in_fullscreen_(workspace_controller_->GetWindowState() == |
373 WORKSPACE_WINDOW_STATE_FULL_SCREEN), | 380 WORKSPACE_WINDOW_STATE_FULL_SCREEN), |
374 docked_width_(0), | 381 docked_width_(0), |
375 alignment_(DOCKED_ALIGNMENT_NONE), | 382 alignment_(DOCKED_ALIGNMENT_NONE), |
376 last_active_window_(NULL), | 383 last_active_window_(NULL), |
377 last_action_time_(base::Time::Now()), | 384 last_action_time_(base::Time::Now()), |
378 background_widget_(new DockedBackgroundWidget(dock_container_)) { | 385 background_widget_(new DockedBackgroundWidget(dock_container_)) { |
379 DCHECK(dock_container); | 386 DCHECK(dock_container); |
380 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 387 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
381 AddObserver(this); | 388 AddObserver(this); |
382 Shell::GetInstance()->AddShellObserver(this); | 389 Shell::GetInstance()->AddShellObserver(this); |
383 } | 390 } |
384 | 391 |
385 DockedWindowLayoutManager::~DockedWindowLayoutManager() { | 392 DockedWindowLayoutManager::~DockedWindowLayoutManager() { |
386 Shutdown(); | 393 Shutdown(); |
387 } | 394 } |
388 | 395 |
389 void DockedWindowLayoutManager::Shutdown() { | 396 void DockedWindowLayoutManager::Shutdown() { |
390 if (launcher_ && launcher_->shelf_widget()) { | 397 if (shelf_ && shelf_->shelf_widget()) { |
391 ShelfLayoutManager* shelf_layout_manager = ShelfLayoutManager::ForLauncher( | 398 ShelfLayoutManager* shelf_layout_manager = ShelfLayoutManager::ForShelf( |
392 launcher_->shelf_widget()->GetNativeWindow()); | 399 shelf_->shelf_widget()->GetNativeWindow()); |
393 shelf_layout_manager->RemoveObserver(this); | 400 shelf_layout_manager->RemoveObserver(this); |
394 shelf_observer_.reset(); | 401 shelf_observer_.reset(); |
395 } | 402 } |
396 launcher_ = NULL; | 403 shelf_ = NULL; |
397 for (size_t i = 0; i < dock_container_->children().size(); ++i) { | 404 for (size_t i = 0; i < dock_container_->children().size(); ++i) { |
398 aura::Window* child = dock_container_->children()[i]; | 405 aura::Window* child = dock_container_->children()[i]; |
399 child->RemoveObserver(this); | 406 child->RemoveObserver(this); |
400 wm::GetWindowState(child)->RemoveObserver(this); | 407 wm::GetWindowState(child)->RemoveObserver(this); |
401 } | 408 } |
402 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 409 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
403 RemoveObserver(this); | 410 RemoveObserver(this); |
404 Shell::GetInstance()->RemoveShellObserver(this); | 411 Shell::GetInstance()->RemoveShellObserver(this); |
405 } | 412 } |
406 | 413 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 // count limit so do it here. | 470 // count limit so do it here. |
464 MaybeMinimizeChildrenExcept(dragged_window_); | 471 MaybeMinimizeChildrenExcept(dragged_window_); |
465 } | 472 } |
466 dragged_window_ = NULL; | 473 dragged_window_ = NULL; |
467 dragged_bounds_ = gfx::Rect(); | 474 dragged_bounds_ = gfx::Rect(); |
468 Relayout(); | 475 Relayout(); |
469 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 476 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
470 RecordUmaAction(action, source); | 477 RecordUmaAction(action, source); |
471 } | 478 } |
472 | 479 |
473 void DockedWindowLayoutManager::SetLauncher(ash::Launcher* launcher) { | 480 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) { |
474 DCHECK(!launcher_); | 481 DCHECK(!shelf_); |
475 launcher_ = launcher; | 482 shelf_ = shelf; |
476 if (launcher_->shelf_widget()) { | 483 if (shelf_->shelf_widget()) { |
477 ShelfLayoutManager* shelf_layout_manager = ShelfLayoutManager::ForLauncher( | 484 ShelfLayoutManager* shelf_layout_manager = ShelfLayoutManager::ForShelf( |
478 launcher_->shelf_widget()->GetNativeWindow()); | 485 shelf_->shelf_widget()->GetNativeWindow()); |
479 shelf_layout_manager->AddObserver(this); | 486 shelf_layout_manager->AddObserver(this); |
480 shelf_observer_.reset(new ShelfWindowObserver(this)); | 487 shelf_observer_.reset(new ShelfWindowObserver(this)); |
481 } | 488 } |
482 } | 489 } |
483 | 490 |
484 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( | 491 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( |
485 const aura::Window* window) const { | 492 const aura::Window* window) const { |
486 const gfx::Rect& bounds(window->GetBoundsInScreen()); | 493 const gfx::Rect& bounds(window->GetBoundsInScreen()); |
487 | 494 |
488 // Test overlap with an existing docked area first. | 495 // Test overlap with an existing docked area first. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 if (GetWindowHeightCloseTo(window, work_area.height() - 2 * kMinDockGap) > | 552 if (GetWindowHeightCloseTo(window, work_area.height() - 2 * kMinDockGap) > |
546 work_area.height() - 2 * kMinDockGap) { | 553 work_area.height() - 2 * kMinDockGap) { |
547 return false; | 554 return false; |
548 } | 555 } |
549 // Cannot dock on the other size from an existing dock. | 556 // Cannot dock on the other size from an existing dock. |
550 const DockedAlignment alignment = CalculateAlignment(); | 557 const DockedAlignment alignment = CalculateAlignment(); |
551 if ((edge == SNAP_LEFT && alignment == DOCKED_ALIGNMENT_RIGHT) || | 558 if ((edge == SNAP_LEFT && alignment == DOCKED_ALIGNMENT_RIGHT) || |
552 (edge == SNAP_RIGHT && alignment == DOCKED_ALIGNMENT_LEFT)) { | 559 (edge == SNAP_RIGHT && alignment == DOCKED_ALIGNMENT_LEFT)) { |
553 return false; | 560 return false; |
554 } | 561 } |
555 // Do not allow docking on the same side as launcher shelf. | 562 // Do not allow docking on the same side as shelf. |
556 ShelfAlignment shelf_alignment = SHELF_ALIGNMENT_BOTTOM; | 563 ShelfAlignment shelf_alignment = SHELF_ALIGNMENT_BOTTOM; |
557 if (launcher_) | 564 if (shelf_) |
558 shelf_alignment = launcher_->alignment(); | 565 shelf_alignment = shelf_->alignment(); |
559 if ((edge == SNAP_LEFT && shelf_alignment == SHELF_ALIGNMENT_LEFT) || | 566 if ((edge == SNAP_LEFT && shelf_alignment == SHELF_ALIGNMENT_LEFT) || |
560 (edge == SNAP_RIGHT && shelf_alignment == SHELF_ALIGNMENT_RIGHT)) { | 567 (edge == SNAP_RIGHT && shelf_alignment == SHELF_ALIGNMENT_RIGHT)) { |
561 return false; | 568 return false; |
562 } | 569 } |
563 return true; | 570 return true; |
564 } | 571 } |
565 | 572 |
566 void DockedWindowLayoutManager::OnShelfBoundsChanged() { | 573 void DockedWindowLayoutManager::OnShelfBoundsChanged() { |
567 Relayout(); | 574 Relayout(); |
568 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); | 575 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 636 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
630 } | 637 } |
631 | 638 |
632 void DockedWindowLayoutManager::SetChildBounds( | 639 void DockedWindowLayoutManager::SetChildBounds( |
633 aura::Window* child, | 640 aura::Window* child, |
634 const gfx::Rect& requested_bounds) { | 641 const gfx::Rect& requested_bounds) { |
635 // Whenever one of our windows is moved or resized enforce layout. | 642 // Whenever one of our windows is moved or resized enforce layout. |
636 SetChildBoundsDirect(child, requested_bounds); | 643 SetChildBoundsDirect(child, requested_bounds); |
637 if (IsPopupOrTransient(child)) | 644 if (IsPopupOrTransient(child)) |
638 return; | 645 return; |
639 ShelfLayoutManager* shelf_layout = internal::ShelfLayoutManager::ForLauncher( | 646 ShelfLayoutManager* shelf_layout = internal::ShelfLayoutManager::ForShelf( |
640 dock_container_); | 647 dock_container_); |
641 if (shelf_layout) | 648 if (shelf_layout) |
642 shelf_layout->UpdateVisibilityState(); | 649 shelf_layout->UpdateVisibilityState(); |
643 } | 650 } |
644 | 651 |
645 //////////////////////////////////////////////////////////////////////////////// | 652 //////////////////////////////////////////////////////////////////////////////// |
646 // DockedWindowLayoutManager, ash::ShellObserver implementation: | 653 // DockedWindowLayoutManager, ash::ShellObserver implementation: |
647 | 654 |
648 void DockedWindowLayoutManager::OnDisplayWorkAreaInsetsChanged() { | 655 void DockedWindowLayoutManager::OnDisplayWorkAreaInsetsChanged() { |
649 Relayout(); | 656 Relayout(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 } | 688 } |
682 Relayout(); | 689 Relayout(); |
683 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 690 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
684 } | 691 } |
685 | 692 |
686 void DockedWindowLayoutManager::OnShelfAlignmentChanged( | 693 void DockedWindowLayoutManager::OnShelfAlignmentChanged( |
687 aura::Window* root_window) { | 694 aura::Window* root_window) { |
688 if (dock_container_->GetRootWindow() != root_window) | 695 if (dock_container_->GetRootWindow() != root_window) |
689 return; | 696 return; |
690 | 697 |
691 if (!launcher_ || !launcher_->shelf_widget()) | 698 if (!shelf_ || !shelf_->shelf_widget()) |
692 return; | 699 return; |
693 | 700 |
694 if (alignment_ == DOCKED_ALIGNMENT_NONE) | 701 if (alignment_ == DOCKED_ALIGNMENT_NONE) |
695 return; | 702 return; |
696 | 703 |
697 // Do not allow launcher and dock on the same side. Switch side that | 704 // Do not allow shelf and dock on the same side. Switch side that |
698 // the dock is attached to and move all dock windows to that new side. | 705 // the dock is attached to and move all dock windows to that new side. |
699 ShelfAlignment shelf_alignment = launcher_->shelf_widget()->GetAlignment(); | 706 ShelfAlignment shelf_alignment = shelf_->shelf_widget()->GetAlignment(); |
700 if (alignment_ == DOCKED_ALIGNMENT_LEFT && | 707 if (alignment_ == DOCKED_ALIGNMENT_LEFT && |
701 shelf_alignment == SHELF_ALIGNMENT_LEFT) { | 708 shelf_alignment == SHELF_ALIGNMENT_LEFT) { |
702 alignment_ = DOCKED_ALIGNMENT_RIGHT; | 709 alignment_ = DOCKED_ALIGNMENT_RIGHT; |
703 } else if (alignment_ == DOCKED_ALIGNMENT_RIGHT && | 710 } else if (alignment_ == DOCKED_ALIGNMENT_RIGHT && |
704 shelf_alignment == SHELF_ALIGNMENT_RIGHT) { | 711 shelf_alignment == SHELF_ALIGNMENT_RIGHT) { |
705 alignment_ = DOCKED_ALIGNMENT_LEFT; | 712 alignment_ = DOCKED_ALIGNMENT_LEFT; |
706 } | 713 } |
707 Relayout(); | 714 Relayout(); |
708 UpdateDockBounds(DockedWindowLayoutManagerObserver::SHELF_ALIGNMENT_CHANGED); | 715 UpdateDockBounds(DockedWindowLayoutManagerObserver::SHELF_ALIGNMENT_CHANGED); |
709 } | 716 } |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1238 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
1232 const gfx::Rect& keyboard_bounds) { | 1239 const gfx::Rect& keyboard_bounds) { |
1233 // This bounds change will have caused a change to the Shelf which does not | 1240 // This bounds change will have caused a change to the Shelf which does not |
1234 // propagate automatically to this class, so manually recalculate bounds. | 1241 // propagate automatically to this class, so manually recalculate bounds. |
1235 Relayout(); | 1242 Relayout(); |
1236 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1243 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
1237 } | 1244 } |
1238 | 1245 |
1239 } // namespace internal | 1246 } // namespace internal |
1240 } // namespace ash | 1247 } // namespace ash |
OLD | NEW |