OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/immersive_fullscreen_controller.h" | 5 #include "ash/wm/immersive_fullscreen_controller.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "ui/aura/client/activation_client.h" | 12 #include "ui/aura/client/activation_client.h" |
13 #include "ui/aura/client/aura_constants.h" | 13 #include "ui/aura/client/aura_constants.h" |
14 #include "ui/aura/client/capture_client.h" | 14 #include "ui/aura/client/capture_client.h" |
15 #include "ui/aura/client/cursor_client.h" | 15 #include "ui/aura/client/cursor_client.h" |
16 #include "ui/aura/client/screen_position_client.h" | 16 #include "ui/aura/client/screen_position_client.h" |
17 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
18 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
19 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
20 #include "ui/gfx/animation/slide_animation.h" | 20 #include "ui/gfx/animation/slide_animation.h" |
21 #include "ui/gfx/display.h" | 21 #include "ui/gfx/display.h" |
22 #include "ui/gfx/point.h" | 22 #include "ui/gfx/point.h" |
23 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
24 #include "ui/gfx/screen.h" | 24 #include "ui/gfx/screen.h" |
25 #include "ui/views/bubble/bubble_delegate.h" | 25 #include "ui/views/bubble/bubble_delegate.h" |
| 26 #include "ui/views/corewm/window_util.h" |
26 #include "ui/views/view.h" | 27 #include "ui/views/view.h" |
27 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
28 | 29 |
29 using views::View; | 30 using views::View; |
30 | 31 |
31 namespace ash { | 32 namespace ash { |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 // Duration for the reveal show/hide slide animation. The slower duration is | 36 // Duration for the reveal show/hide slide animation. The slower duration is |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 return widget->widget_delegate()->AsBubbleDelegate(); | 82 return widget->widget_delegate()->AsBubbleDelegate(); |
82 } | 83 } |
83 | 84 |
84 // Returns true if |maybe_transient| is a transient child of |toplevel|. | 85 // Returns true if |maybe_transient| is a transient child of |toplevel|. |
85 bool IsWindowTransientChildOf(aura::Window* maybe_transient, | 86 bool IsWindowTransientChildOf(aura::Window* maybe_transient, |
86 aura::Window* toplevel) { | 87 aura::Window* toplevel) { |
87 if (!maybe_transient || !toplevel) | 88 if (!maybe_transient || !toplevel) |
88 return false; | 89 return false; |
89 | 90 |
90 for (aura::Window* window = maybe_transient; window; | 91 for (aura::Window* window = maybe_transient; window; |
91 window = window->transient_parent()) { | 92 window = views::corewm::GetTransientParent(window)) { |
92 if (window == toplevel) | 93 if (window == toplevel) |
93 return true; | 94 return true; |
94 } | 95 } |
95 return false; | 96 return false; |
96 } | 97 } |
97 | 98 |
98 // Returns the location of |event| in screen coordinates. | 99 // Returns the location of |event| in screen coordinates. |
99 gfx::Point GetEventLocationInScreen(const ui::LocatedEvent& event) { | 100 gfx::Point GetEventLocationInScreen(const ui::LocatedEvent& event) { |
100 gfx::Point location_in_screen = event.location(); | 101 gfx::Point location_in_screen = event.location(); |
101 aura::Window* target = static_cast<aura::Window*>(event.target()); | 102 aura::Window* target = static_cast<aura::Window*>(event.target()); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 } | 466 } |
466 | 467 |
467 void ImmersiveFullscreenController::AnimationProgressed( | 468 void ImmersiveFullscreenController::AnimationProgressed( |
468 const gfx::Animation* animation) { | 469 const gfx::Animation* animation) { |
469 delegate_->SetVisibleFraction(animation->GetCurrentValue()); | 470 delegate_->SetVisibleFraction(animation->GetCurrentValue()); |
470 } | 471 } |
471 | 472 |
472 //////////////////////////////////////////////////////////////////////////////// | 473 //////////////////////////////////////////////////////////////////////////////// |
473 // aura::WindowObserver overrides: | 474 // aura::WindowObserver overrides: |
474 | 475 |
475 void ImmersiveFullscreenController::OnAddTransientChild(aura::Window* window, | 476 void ImmersiveFullscreenController::OnAddTransientChild( |
476 aura::Window* transient) { | 477 aura::Window* window, |
| 478 aura::Window* transient) { |
477 views::BubbleDelegateView* bubble_delegate = AsBubbleDelegate(transient); | 479 views::BubbleDelegateView* bubble_delegate = AsBubbleDelegate(transient); |
478 if (bubble_delegate && | 480 if (bubble_delegate && |
479 bubble_delegate->GetAnchorView() && | 481 bubble_delegate->GetAnchorView() && |
480 top_container_->Contains(bubble_delegate->GetAnchorView())) { | 482 top_container_->Contains(bubble_delegate->GetAnchorView())) { |
481 // Observe the aura::Window because the BubbleDelegateView may not be | 483 // Observe the aura::Window because the BubbleDelegateView may not be |
482 // parented to the widget's root view yet so |bubble_delegate->GetWidget()| | 484 // parented to the widget's root view yet so |bubble_delegate->GetWidget()| |
483 // may still return NULL. | 485 // may still return NULL. |
484 bubble_manager_->StartObserving(transient); | 486 bubble_manager_->StartObserving(transient); |
485 } | 487 } |
486 } | 488 } |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 Shell::GetScreen()->GetDisplayNearestPoint(location).bounds(); | 910 Shell::GetScreen()->GetDisplayNearestPoint(location).bounds(); |
909 return (!screen_bounds.Contains(location) && | 911 return (!screen_bounds.Contains(location) && |
910 location.y() < hit_bounds_in_screen.y() && | 912 location.y() < hit_bounds_in_screen.y() && |
911 location.x() >= hit_bounds_in_screen.x() && | 913 location.x() >= hit_bounds_in_screen.x() && |
912 location.x() < hit_bounds_in_screen.right()); | 914 location.x() < hit_bounds_in_screen.right()); |
913 } | 915 } |
914 | 916 |
915 void ImmersiveFullscreenController::RecreateBubbleManager() { | 917 void ImmersiveFullscreenController::RecreateBubbleManager() { |
916 bubble_manager_.reset(new BubbleManager(this)); | 918 bubble_manager_.reset(new BubbleManager(this)); |
917 const std::vector<aura::Window*> transient_children = | 919 const std::vector<aura::Window*> transient_children = |
918 native_window_->transient_children(); | 920 views::corewm::GetTransientChildren(native_window_); |
919 for (size_t i = 0; i < transient_children.size(); ++i) { | 921 for (size_t i = 0; i < transient_children.size(); ++i) { |
920 aura::Window* transient_child = transient_children[i]; | 922 aura::Window* transient_child = transient_children[i]; |
921 views::BubbleDelegateView* bubble_delegate = | 923 views::BubbleDelegateView* bubble_delegate = |
922 AsBubbleDelegate(transient_child); | 924 AsBubbleDelegate(transient_child); |
923 if (bubble_delegate && | 925 if (bubble_delegate && |
924 bubble_delegate->GetAnchorView() && | 926 bubble_delegate->GetAnchorView() && |
925 top_container_->Contains(bubble_delegate->GetAnchorView())) { | 927 top_container_->Contains(bubble_delegate->GetAnchorView())) { |
926 bubble_manager_->StartObserving(transient_child); | 928 bubble_manager_->StartObserving(transient_child); |
927 } | 929 } |
928 } | 930 } |
929 } | 931 } |
930 | 932 |
931 } // namespace ash | 933 } // namespace ash |
OLD | NEW |