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; |
55 const int kTimeToSwitchBackgroundMs = 1000; | |
oshima
2013/12/05 18:47:04
does this have to be same as the duration used in
varkha
2013/12/05 21:14:16
Done.
| |
50 | 56 |
51 namespace { | 57 class DockedWindowLayoutManager::DockedBackgroundWidget |
oshima
2013/12/05 18:47:04
Do we really need widget for background? Can't we
varkha
2013/12/05 21:14:16
I wanted to keep the implementation in sync with t
| |
58 : public views::Widget, | |
59 public internal::BackgroundAnimatorDelegate { | |
60 public: | |
61 explicit DockedBackgroundWidget(aura::Window* container) | |
62 : alignment_(DOCKED_ALIGNMENT_NONE), | |
63 background_animator_(this, 0, kLauncherBackgroundAlpha), | |
64 alpha_(0), | |
65 opaque_background_(ui::LAYER_SOLID_COLOR) { | |
66 InitWidget(container); | |
67 } | |
52 | 68 |
53 const SkColor kDockBackgroundColor = SkColorSetARGB(0xff, 0x10, 0x10, 0x10); | 69 // Sets widget bounds and sizes opaque background layer to fill the widget. |
54 const float kDockBackgroundOpacity = 0.5f; | 70 void SetBackgroundBounds(const gfx::Rect bounds, DockedAlignment alignment) { |
71 SetBounds(bounds); | |
72 opaque_background_.SetBounds(gfx::Rect(bounds.size())); | |
73 alignment_ = alignment; | |
74 } | |
55 | 75 |
56 class DockedBackgroundWidget : public views::Widget { | 76 // Sets the docked area background type and starts transition animation. |
57 public: | 77 void SetPaintsBackground( |
58 explicit DockedBackgroundWidget(aura::Window* container) { | 78 ShelfBackgroundType background_type, |
59 InitWidget(container); | 79 internal::BackgroundAnimator::ChangeType change_type) { |
80 float target_opacity = | |
81 (background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f; | |
82 scoped_ptr<ui::ScopedLayerAnimationSettings> opaque_background_animation; | |
83 if (change_type != internal::BackgroundAnimator::CHANGE_IMMEDIATE) { | |
84 opaque_background_animation.reset(new ui::ScopedLayerAnimationSettings( | |
85 opaque_background_.GetAnimator())); | |
86 opaque_background_animation->SetTransitionDuration( | |
87 base::TimeDelta::FromMilliseconds(kTimeToSwitchBackgroundMs)); | |
88 } | |
89 opaque_background_.SetOpacity(target_opacity); | |
90 background_animator_.SetPaintsBackground( | |
91 background_type != SHELF_BACKGROUND_DEFAULT, | |
92 change_type); | |
93 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); | |
94 } | |
95 | |
96 // views::Widget: | |
97 void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE { | |
98 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
99 gfx::ImageSkia launcher_background = | |
100 *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_BACKGROUND); | |
101 launcher_background = gfx::ImageSkiaOperations::CreateRotatedImage( | |
102 launcher_background, | |
103 alignment_ == DOCKED_ALIGNMENT_LEFT ? | |
104 SkBitmapOperations::ROTATION_90_CW : | |
105 SkBitmapOperations::ROTATION_270_CW); | |
oshima
2013/12/05 18:47:04
does this mean we rotate the image every time we r
varkha
2013/12/05 21:14:16
Done.
| |
106 gfx::Rect rect = gfx::Rect(GetWindowBoundsInScreen().size()); | |
107 SkPaint paint; | |
108 paint.setAlpha(alpha_); | |
109 canvas->DrawImageInt( | |
110 launcher_background, | |
111 0, 0, launcher_background.width(), launcher_background.height(), | |
112 0, 0, rect.width(), rect.height(), | |
113 false, | |
114 paint); | |
115 } | |
116 | |
117 // BackgroundAnimatorDelegate: | |
118 virtual void UpdateBackground(int alpha) OVERRIDE { | |
119 alpha_ = alpha; | |
120 SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); | |
60 } | 121 } |
61 | 122 |
62 private: | 123 private: |
63 void InitWidget(aura::Window* parent) { | 124 void InitWidget(aura::Window* parent) { |
64 views::Widget::InitParams params; | 125 views::Widget::InitParams params; |
65 params.type = views::Widget::InitParams::TYPE_POPUP; | 126 params.type = views::Widget::InitParams::TYPE_POPUP; |
66 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; | 127 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
67 params.can_activate = false; | 128 params.can_activate = false; |
68 params.keep_on_top = false; | 129 params.keep_on_top = false; |
69 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 130 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
70 params.parent = parent; | 131 params.parent = parent; |
71 params.accept_events = false; | 132 params.accept_events = false; |
72 set_focus_on_creation(false); | 133 set_focus_on_creation(false); |
73 Init(params); | 134 Init(params); |
74 GetNativeWindow()->SetProperty(internal::kStayInSameRootWindowKey, true); | 135 GetNativeWindow()->SetProperty(internal::kStayInSameRootWindowKey, true); |
75 DCHECK_EQ(GetNativeView()->GetRootWindow(), parent->GetRootWindow()); | 136 opaque_background_.SetColor(SK_ColorBLACK); |
76 views::View* content_view = new views::View; | 137 opaque_background_.SetBounds(gfx::Rect(GetWindowBoundsInScreen().size())); |
77 content_view->set_background( | 138 opaque_background_.SetOpacity(0.0f); |
78 views::Background::CreateSolidBackground(kDockBackgroundColor)); | 139 GetNativeWindow()->layer()->Add(&opaque_background_); |
79 SetContentsView(content_view); | |
80 Hide(); | 140 Hide(); |
81 } | 141 } |
82 | 142 |
143 DockedAlignment alignment_; | |
144 | |
145 // The animator for the background transitions. | |
146 internal::BackgroundAnimator background_animator_; | |
147 | |
148 // The alpha to use for drawing image assets covering the docked background. | |
149 int alpha_; | |
150 | |
151 // Solid black background that can be made fully opaque. | |
152 ui::Layer opaque_background_; | |
153 | |
83 DISALLOW_COPY_AND_ASSIGN(DockedBackgroundWidget); | 154 DISALLOW_COPY_AND_ASSIGN(DockedBackgroundWidget); |
84 }; | 155 }; |
85 | 156 |
157 namespace { | |
158 | |
86 // Returns true if a window is a popup or a transient child. | 159 // Returns true if a window is a popup or a transient child. |
87 bool IsPopupOrTransient(const aura::Window* window) { | 160 bool IsPopupOrTransient(const aura::Window* window) { |
88 return (window->type() == aura::client::WINDOW_TYPE_POPUP || | 161 return (window->type() == aura::client::WINDOW_TYPE_POPUP || |
89 window->transient_parent()); | 162 window->transient_parent()); |
90 } | 163 } |
91 | 164 |
92 // Certain windows (minimized, hidden or popups) do not matter to docking. | 165 // Certain windows (minimized, hidden or popups) do not matter to docking. |
93 bool IsUsedByLayout(const aura::Window* window) { | 166 bool IsUsedByLayout(const aura::Window* window) { |
94 return (window->IsVisible() && | 167 return (window->IsVisible() && |
95 !wm::GetWindowState(window)->IsMinimized() && | 168 !wm::GetWindowState(window)->IsMinimized() && |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 } | 291 } |
219 | 292 |
220 private: | 293 private: |
221 aura::Window* dragged_window_; | 294 aura::Window* dragged_window_; |
222 float delta_; | 295 float delta_; |
223 }; | 296 }; |
224 | 297 |
225 } // namespace | 298 } // namespace |
226 | 299 |
227 //////////////////////////////////////////////////////////////////////////////// | 300 //////////////////////////////////////////////////////////////////////////////// |
228 // DockLayoutManager public implementation: | 301 // DockedWindowLayoutManager public implementation: |
229 DockedWindowLayoutManager::DockedWindowLayoutManager( | 302 DockedWindowLayoutManager::DockedWindowLayoutManager( |
230 aura::Window* dock_container, WorkspaceController* workspace_controller) | 303 aura::Window* dock_container, WorkspaceController* workspace_controller) |
231 : dock_container_(dock_container), | 304 : dock_container_(dock_container), |
232 in_layout_(false), | 305 in_layout_(false), |
233 dragged_window_(NULL), | 306 dragged_window_(NULL), |
234 is_dragged_window_docked_(false), | 307 is_dragged_window_docked_(false), |
235 is_dragged_from_dock_(false), | 308 is_dragged_from_dock_(false), |
236 launcher_(NULL), | 309 launcher_(NULL), |
310 shelf_layout_manager_(NULL), | |
237 workspace_controller_(workspace_controller), | 311 workspace_controller_(workspace_controller), |
238 in_fullscreen_(workspace_controller_->GetWindowState() == | 312 in_fullscreen_(workspace_controller_->GetWindowState() == |
239 WORKSPACE_WINDOW_STATE_FULL_SCREEN), | 313 WORKSPACE_WINDOW_STATE_FULL_SCREEN), |
240 docked_width_(0), | 314 docked_width_(0), |
241 alignment_(DOCKED_ALIGNMENT_NONE), | 315 alignment_(DOCKED_ALIGNMENT_NONE), |
242 last_active_window_(NULL), | 316 last_active_window_(NULL), |
243 last_action_time_(base::Time::Now()), | 317 last_action_time_(base::Time::Now()), |
244 background_widget_(new DockedBackgroundWidget(dock_container_)) { | 318 background_widget_(new DockedBackgroundWidget(dock_container_)) { |
245 DCHECK(dock_container); | 319 DCHECK(dock_container); |
246 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 320 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
247 AddObserver(this); | 321 AddObserver(this); |
248 Shell::GetInstance()->AddShellObserver(this); | 322 Shell::GetInstance()->AddShellObserver(this); |
249 } | 323 } |
250 | 324 |
251 DockedWindowLayoutManager::~DockedWindowLayoutManager() { | 325 DockedWindowLayoutManager::~DockedWindowLayoutManager() { |
252 Shutdown(); | 326 Shutdown(); |
253 } | 327 } |
254 | 328 |
255 void DockedWindowLayoutManager::Shutdown() { | 329 void DockedWindowLayoutManager::Shutdown() { |
330 if (shelf_layout_manager_) | |
331 shelf_layout_manager_->RemoveObserver(this); | |
332 shelf_layout_manager_ = NULL; | |
oshima
2013/12/05 18:47:04
do we need to keep shelf_layout_manager_, or we ca
varkha
2013/12/05 21:14:16
Done.
| |
256 launcher_ = NULL; | 333 launcher_ = NULL; |
257 for (size_t i = 0; i < dock_container_->children().size(); ++i) { | 334 for (size_t i = 0; i < dock_container_->children().size(); ++i) { |
258 aura::Window* child = dock_container_->children()[i]; | 335 aura::Window* child = dock_container_->children()[i]; |
259 child->RemoveObserver(this); | 336 child->RemoveObserver(this); |
260 wm::GetWindowState(child)->RemoveObserver(this); | 337 wm::GetWindowState(child)->RemoveObserver(this); |
261 } | 338 } |
262 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 339 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
263 RemoveObserver(this); | 340 RemoveObserver(this); |
264 Shell::GetInstance()->RemoveShellObserver(this); | 341 Shell::GetInstance()->RemoveShellObserver(this); |
265 } | 342 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 dragged_window_ = NULL; | 403 dragged_window_ = NULL; |
327 dragged_bounds_ = gfx::Rect(); | 404 dragged_bounds_ = gfx::Rect(); |
328 Relayout(); | 405 Relayout(); |
329 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 406 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
330 RecordUmaAction(action, source); | 407 RecordUmaAction(action, source); |
331 } | 408 } |
332 | 409 |
333 void DockedWindowLayoutManager::SetLauncher(ash::Launcher* launcher) { | 410 void DockedWindowLayoutManager::SetLauncher(ash::Launcher* launcher) { |
334 DCHECK(!launcher_); | 411 DCHECK(!launcher_); |
335 launcher_ = launcher; | 412 launcher_ = launcher; |
413 if (launcher_->shelf_widget()) { | |
414 shelf_layout_manager_ = ash::internal::ShelfLayoutManager::ForLauncher( | |
415 launcher_->shelf_widget()->GetNativeWindow()); | |
416 shelf_layout_manager_->AddObserver(this); | |
417 } | |
336 } | 418 } |
337 | 419 |
338 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( | 420 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( |
339 const aura::Window* window) const { | 421 const aura::Window* window) const { |
340 const gfx::Rect& bounds(window->GetBoundsInScreen()); | 422 const gfx::Rect& bounds(window->GetBoundsInScreen()); |
341 | 423 |
342 // Test overlap with an existing docked area first. | 424 // Test overlap with an existing docked area first. |
343 if (docked_bounds_.Intersects(bounds) && | 425 if (docked_bounds_.Intersects(bounds) && |
344 alignment_ != DOCKED_ALIGNMENT_NONE) { | 426 alignment_ != DOCKED_ALIGNMENT_NONE) { |
345 // A window is being added to other docked windows (on the same side). | 427 // 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_) | 493 if (launcher_) |
412 shelf_alignment = launcher_->alignment(); | 494 shelf_alignment = launcher_->alignment(); |
413 if ((edge == SNAP_LEFT && shelf_alignment == SHELF_ALIGNMENT_LEFT) || | 495 if ((edge == SNAP_LEFT && shelf_alignment == SHELF_ALIGNMENT_LEFT) || |
414 (edge == SNAP_RIGHT && shelf_alignment == SHELF_ALIGNMENT_RIGHT)) { | 496 (edge == SNAP_RIGHT && shelf_alignment == SHELF_ALIGNMENT_RIGHT)) { |
415 return false; | 497 return false; |
416 } | 498 } |
417 return true; | 499 return true; |
418 } | 500 } |
419 | 501 |
420 //////////////////////////////////////////////////////////////////////////////// | 502 //////////////////////////////////////////////////////////////////////////////// |
421 // DockLayoutManager, aura::LayoutManager implementation: | 503 // DockedWindowLayoutManager, aura::LayoutManager implementation: |
422 void DockedWindowLayoutManager::OnWindowResized() { | 504 void DockedWindowLayoutManager::OnWindowResized() { |
423 MaybeMinimizeChildrenExcept(dragged_window_); | 505 MaybeMinimizeChildrenExcept(dragged_window_); |
424 Relayout(); | 506 Relayout(); |
425 // When screen resizes update the insets even when dock width or alignment | 507 // When screen resizes update the insets even when dock width or alignment |
426 // does not change. | 508 // does not change. |
427 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_RESIZED); | 509 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_RESIZED); |
428 } | 510 } |
429 | 511 |
430 void DockedWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 512 void DockedWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
431 if (IsPopupOrTransient(child)) | 513 if (IsPopupOrTransient(child)) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 SetChildBoundsDirect(child, requested_bounds); | 567 SetChildBoundsDirect(child, requested_bounds); |
486 if (IsPopupOrTransient(child)) | 568 if (IsPopupOrTransient(child)) |
487 return; | 569 return; |
488 ShelfLayoutManager* shelf_layout = internal::ShelfLayoutManager::ForLauncher( | 570 ShelfLayoutManager* shelf_layout = internal::ShelfLayoutManager::ForLauncher( |
489 dock_container_); | 571 dock_container_); |
490 if (shelf_layout) | 572 if (shelf_layout) |
491 shelf_layout->UpdateVisibilityState(); | 573 shelf_layout->UpdateVisibilityState(); |
492 } | 574 } |
493 | 575 |
494 //////////////////////////////////////////////////////////////////////////////// | 576 //////////////////////////////////////////////////////////////////////////////// |
495 // DockLayoutManager, ash::ShellObserver implementation: | 577 // DockedWindowLayoutManager, ash::ShellObserver implementation: |
496 | 578 |
497 void DockedWindowLayoutManager::OnDisplayWorkAreaInsetsChanged() { | 579 void DockedWindowLayoutManager::OnDisplayWorkAreaInsetsChanged() { |
498 Relayout(); | 580 Relayout(); |
499 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); | 581 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); |
500 MaybeMinimizeChildrenExcept(dragged_window_); | 582 MaybeMinimizeChildrenExcept(dragged_window_); |
501 } | 583 } |
502 | 584 |
503 void DockedWindowLayoutManager::OnFullscreenStateChanged( | 585 void DockedWindowLayoutManager::OnFullscreenStateChanged( |
504 bool is_fullscreen, aura::Window* root_window) { | 586 bool is_fullscreen, aura::Window* root_window) { |
505 if (dock_container_->GetRootWindow() != root_window) | 587 if (dock_container_->GetRootWindow() != root_window) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 alignment_ = DOCKED_ALIGNMENT_RIGHT; | 633 alignment_ = DOCKED_ALIGNMENT_RIGHT; |
552 } else if (alignment_ == DOCKED_ALIGNMENT_RIGHT && | 634 } else if (alignment_ == DOCKED_ALIGNMENT_RIGHT && |
553 shelf_alignment == SHELF_ALIGNMENT_RIGHT) { | 635 shelf_alignment == SHELF_ALIGNMENT_RIGHT) { |
554 alignment_ = DOCKED_ALIGNMENT_LEFT; | 636 alignment_ = DOCKED_ALIGNMENT_LEFT; |
555 } | 637 } |
556 Relayout(); | 638 Relayout(); |
557 UpdateDockBounds(DockedWindowLayoutManagerObserver::SHELF_ALIGNMENT_CHANGED); | 639 UpdateDockBounds(DockedWindowLayoutManagerObserver::SHELF_ALIGNMENT_CHANGED); |
558 } | 640 } |
559 | 641 |
560 ///////////////////////////////////////////////////////////////////////////// | 642 ///////////////////////////////////////////////////////////////////////////// |
561 // DockLayoutManager, WindowStateObserver implementation: | 643 // DockedWindowLayoutManager, ShelfLayoutManagerObserver implementation: |
644 void DockedWindowLayoutManager::OnBackgroundUpdated( | |
645 ShelfBackgroundType background_type, | |
646 internal::BackgroundAnimator::ChangeType change_type) { | |
647 background_widget_->SetPaintsBackground(background_type, change_type); | |
648 } | |
649 | |
650 ///////////////////////////////////////////////////////////////////////////// | |
651 // DockedWindowLayoutManager, WindowStateObserver implementation: | |
562 | 652 |
563 void DockedWindowLayoutManager::OnWindowShowTypeChanged( | 653 void DockedWindowLayoutManager::OnWindowShowTypeChanged( |
564 wm::WindowState* window_state, | 654 wm::WindowState* window_state, |
565 wm::WindowShowType old_type) { | 655 wm::WindowShowType old_type) { |
566 aura::Window* window = window_state->window(); | 656 aura::Window* window = window_state->window(); |
567 if (IsPopupOrTransient(window)) | 657 if (IsPopupOrTransient(window)) |
568 return; | 658 return; |
569 // The window property will still be set, but no actual change will occur | 659 // The window property will still be set, but no actual change will occur |
570 // until OnFullscreenStateChange is called when exiting fullscreen. | 660 // until OnFullscreenStateChange is called when exiting fullscreen. |
571 if (in_fullscreen_) | 661 if (in_fullscreen_) |
572 return; | 662 return; |
573 if (window_state->IsMinimized()) { | 663 if (window_state->IsMinimized()) { |
574 MinimizeDockedWindow(window_state); | 664 MinimizeDockedWindow(window_state); |
575 } else if (window_state->IsMaximizedOrFullscreen() || | 665 } else if (window_state->IsMaximizedOrFullscreen() || |
576 window_state->IsSnapped()) { | 666 window_state->IsSnapped()) { |
577 if (window != dragged_window_) { | 667 if (window != dragged_window_) { |
578 UndockWindow(window); | 668 UndockWindow(window); |
579 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); | 669 RecordUmaAction(DOCKED_ACTION_MAXIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN); |
580 } | 670 } |
581 } else if (old_type == wm::SHOW_TYPE_MINIMIZED) { | 671 } else if (old_type == wm::SHOW_TYPE_MINIMIZED) { |
582 RestoreDockedWindow(window_state); | 672 RestoreDockedWindow(window_state); |
583 } | 673 } |
584 } | 674 } |
585 | 675 |
586 ///////////////////////////////////////////////////////////////////////////// | 676 ///////////////////////////////////////////////////////////////////////////// |
587 // DockLayoutManager, WindowObserver implementation: | 677 // DockedWindowLayoutManager, WindowObserver implementation: |
588 | 678 |
589 void DockedWindowLayoutManager::OnWindowBoundsChanged( | 679 void DockedWindowLayoutManager::OnWindowBoundsChanged( |
590 aura::Window* window, | 680 aura::Window* window, |
591 const gfx::Rect& old_bounds, | 681 const gfx::Rect& old_bounds, |
592 const gfx::Rect& new_bounds) { | 682 const gfx::Rect& new_bounds) { |
593 // Only relayout if the dragged window would get docked. | 683 // Only relayout if the dragged window would get docked. |
594 if (window == dragged_window_ && is_dragged_window_docked_) | 684 if (window == dragged_window_ && is_dragged_window_docked_) |
595 Relayout(); | 685 Relayout(); |
596 } | 686 } |
597 | 687 |
(...skipping 18 matching lines...) Expand all Loading... | |
616 DCHECK(!dragged_window_); | 706 DCHECK(!dragged_window_); |
617 DCHECK (!is_dragged_window_docked_); | 707 DCHECK (!is_dragged_window_docked_); |
618 } | 708 } |
619 if (window == last_active_window_) | 709 if (window == last_active_window_) |
620 last_active_window_ = NULL; | 710 last_active_window_ = NULL; |
621 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN); | 711 RecordUmaAction(DOCKED_ACTION_CLOSE, DOCKED_ACTION_SOURCE_UNKNOWN); |
622 } | 712 } |
623 | 713 |
624 | 714 |
625 //////////////////////////////////////////////////////////////////////////////// | 715 //////////////////////////////////////////////////////////////////////////////// |
626 // DockLayoutManager, aura::client::ActivationChangeObserver implementation: | 716 // DockedWindowLayoutManager, aura::client::ActivationChangeObserver |
717 // implementation: | |
627 | 718 |
628 void DockedWindowLayoutManager::OnWindowActivated(aura::Window* gained_active, | 719 void DockedWindowLayoutManager::OnWindowActivated(aura::Window* gained_active, |
629 aura::Window* lost_active) { | 720 aura::Window* lost_active) { |
630 if (gained_active && IsPopupOrTransient(gained_active)) | 721 if (gained_active && IsPopupOrTransient(gained_active)) |
631 return; | 722 return; |
632 // Ignore if the window that is not managed by this was activated. | 723 // Ignore if the window that is not managed by this was activated. |
633 aura::Window* ancestor = NULL; | 724 aura::Window* ancestor = NULL; |
634 for (aura::Window* parent = gained_active; | 725 for (aura::Window* parent = gained_active; |
635 parent; parent = parent->parent()) { | 726 parent; parent = parent->parent()) { |
636 if (parent->parent() == dock_container_) { | 727 if (parent->parent() == dock_container_) { |
637 ancestor = parent; | 728 ancestor = parent; |
638 break; | 729 break; |
639 } | 730 } |
640 } | 731 } |
641 if (ancestor) | 732 if (ancestor) |
642 UpdateStacking(ancestor); | 733 UpdateStacking(ancestor); |
643 } | 734 } |
644 | 735 |
645 //////////////////////////////////////////////////////////////////////////////// | 736 //////////////////////////////////////////////////////////////////////////////// |
646 // DockLayoutManager private implementation: | 737 // DockedWindowLayoutManager private implementation: |
647 | 738 |
648 void DockedWindowLayoutManager::MaybeMinimizeChildrenExcept( | 739 void DockedWindowLayoutManager::MaybeMinimizeChildrenExcept( |
649 aura::Window* child) { | 740 aura::Window* child) { |
650 // Minimize any windows that don't fit without overlap. | 741 // Minimize any windows that don't fit without overlap. |
651 const gfx::Rect work_area = | 742 const gfx::Rect work_area = |
652 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); | 743 Shell::GetScreen()->GetDisplayNearestWindow(dock_container_).work_area(); |
653 int available_room = work_area.height() - kMinDockGap; | 744 int available_room = work_area.height() - kMinDockGap; |
654 if (child) | 745 if (child) |
655 available_room -= (GetWindowHeightCloseTo(child, 0) + kMinDockGap); | 746 available_room -= (GetWindowHeightCloseTo(child, 0) + kMinDockGap); |
656 // Use a copy of children array because a call to Minimize can change order. | 747 // 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(), | 1082 dock_container_->bounds().y(), |
992 dock_inset, | 1083 dock_inset, |
993 work_area.height()); | 1084 work_area.height()); |
994 docked_bounds_ = bounds + | 1085 docked_bounds_ = bounds + |
995 dock_container_->GetBoundsInScreen().OffsetFromOrigin(); | 1086 dock_container_->GetBoundsInScreen().OffsetFromOrigin(); |
996 FOR_EACH_OBSERVER( | 1087 FOR_EACH_OBSERVER( |
997 DockedWindowLayoutManagerObserver, | 1088 DockedWindowLayoutManagerObserver, |
998 observer_list_, | 1089 observer_list_, |
999 OnDockBoundsChanging(bounds, reason)); | 1090 OnDockBoundsChanging(bounds, reason)); |
1000 // Show or hide background for docked area. | 1091 // Show or hide background for docked area. |
1001 background_widget_->SetBounds(docked_bounds_); | 1092 background_widget_->SetBackgroundBounds(docked_bounds_, alignment_); |
1002 if (docked_width_ > 0) { | 1093 if (docked_width_ > 0) |
1003 background_widget_->Show(); | 1094 background_widget_->Show(); |
1004 background_widget_->GetNativeWindow()->layer()->SetOpacity( | 1095 else |
1005 kDockBackgroundOpacity); | |
1006 } else { | |
1007 background_widget_->Hide(); | 1096 background_widget_->Hide(); |
1008 } | |
1009 } | 1097 } |
1010 | 1098 |
1011 void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) { | 1099 void DockedWindowLayoutManager::UpdateStacking(aura::Window* active_window) { |
1012 if (!active_window) { | 1100 if (!active_window) { |
1013 if (!last_active_window_) | 1101 if (!last_active_window_) |
1014 return; | 1102 return; |
1015 active_window = last_active_window_; | 1103 active_window = last_active_window_; |
1016 } | 1104 } |
1017 | 1105 |
1018 // Windows are stacked like a deck of cards: | 1106 // 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( | 1157 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
1070 const gfx::Rect& keyboard_bounds) { | 1158 const gfx::Rect& keyboard_bounds) { |
1071 // This bounds change will have caused a change to the Shelf which does not | 1159 // This bounds change will have caused a change to the Shelf which does not |
1072 // propagate automatically to this class, so manually recalculate bounds. | 1160 // propagate automatically to this class, so manually recalculate bounds. |
1073 Relayout(); | 1161 Relayout(); |
1074 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1162 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
1075 } | 1163 } |
1076 | 1164 |
1077 } // namespace internal | 1165 } // namespace internal |
1078 } // namespace ash | 1166 } // namespace ash |
OLD | NEW |