| 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/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 return widget->widget_delegate()->AsBubbleDelegate(); | 80 return widget->widget_delegate()->AsBubbleDelegate(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Returns true if |maybe_transient| is a transient child of |toplevel|. | 83 // Returns true if |maybe_transient| is a transient child of |toplevel|. |
| 84 bool IsWindowTransientChildOf(aura::Window* maybe_transient, | 84 bool IsWindowTransientChildOf(aura::Window* maybe_transient, |
| 85 aura::Window* toplevel) { | 85 aura::Window* toplevel) { |
| 86 if (!maybe_transient || !toplevel) | 86 if (!maybe_transient || !toplevel) |
| 87 return false; | 87 return false; |
| 88 | 88 |
| 89 for (aura::Window* window = maybe_transient; window; | 89 for (aura::Window* window = maybe_transient; window; |
| 90 window = views::corewm::GetTransientParent(window)) { | 90 window = ::wm::GetTransientParent(window)) { |
| 91 if (window == toplevel) | 91 if (window == toplevel) |
| 92 return true; | 92 return true; |
| 93 } | 93 } |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Returns the location of |event| in screen coordinates. | 97 // Returns the location of |event| in screen coordinates. |
| 98 gfx::Point GetEventLocationInScreen(const ui::LocatedEvent& event) { | 98 gfx::Point GetEventLocationInScreen(const ui::LocatedEvent& event) { |
| 99 gfx::Point location_in_screen = event.location(); | 99 gfx::Point location_in_screen = event.location(); |
| 100 aura::Window* target = static_cast<aura::Window*>(event.target()); | 100 aura::Window* target = static_cast<aura::Window*>(event.target()); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 if (observers_enabled_ == enable) | 520 if (observers_enabled_ == enable) |
| 521 return; | 521 return; |
| 522 observers_enabled_ = enable; | 522 observers_enabled_ = enable; |
| 523 | 523 |
| 524 views::FocusManager* focus_manager = widget_->GetFocusManager(); | 524 views::FocusManager* focus_manager = widget_->GetFocusManager(); |
| 525 | 525 |
| 526 if (enable) { | 526 if (enable) { |
| 527 widget_->AddObserver(this); | 527 widget_->AddObserver(this); |
| 528 focus_manager->AddFocusChangeListener(this); | 528 focus_manager->AddFocusChangeListener(this); |
| 529 Shell::GetInstance()->AddPreTargetHandler(this); | 529 Shell::GetInstance()->AddPreTargetHandler(this); |
| 530 views::corewm::TransientWindowManager::Get(native_window_)-> | 530 ::wm::TransientWindowManager::Get(native_window_)-> |
| 531 AddObserver(this); | 531 AddObserver(this); |
| 532 | 532 |
| 533 RecreateBubbleManager(); | 533 RecreateBubbleManager(); |
| 534 } else { | 534 } else { |
| 535 widget_->RemoveObserver(this); | 535 widget_->RemoveObserver(this); |
| 536 focus_manager->RemoveFocusChangeListener(this); | 536 focus_manager->RemoveFocusChangeListener(this); |
| 537 Shell::GetInstance()->RemovePreTargetHandler(this); | 537 Shell::GetInstance()->RemovePreTargetHandler(this); |
| 538 views::corewm::TransientWindowManager::Get(native_window_)-> | 538 ::wm::TransientWindowManager::Get(native_window_)-> |
| 539 RemoveObserver(this); | 539 RemoveObserver(this); |
| 540 | 540 |
| 541 // We have stopped observing whether transient children are added or removed | 541 // We have stopped observing whether transient children are added or removed |
| 542 // to |native_window_|. The set of bubbles that BubbleManager is observing | 542 // to |native_window_|. The set of bubbles that BubbleManager is observing |
| 543 // will become stale really quickly. Destroy BubbleManager and recreate it | 543 // will become stale really quickly. Destroy BubbleManager and recreate it |
| 544 // when we start observing |native_window_| again. | 544 // when we start observing |native_window_| again. |
| 545 bubble_manager_.reset(); | 545 bubble_manager_.reset(); |
| 546 | 546 |
| 547 animation_->Stop(); | 547 animation_->Stop(); |
| 548 } | 548 } |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 Shell::GetScreen()->GetDisplayNearestPoint(location).bounds(); | 912 Shell::GetScreen()->GetDisplayNearestPoint(location).bounds(); |
| 913 return (!screen_bounds.Contains(location) && | 913 return (!screen_bounds.Contains(location) && |
| 914 location.y() < hit_bounds_in_screen.y() && | 914 location.y() < hit_bounds_in_screen.y() && |
| 915 location.x() >= hit_bounds_in_screen.x() && | 915 location.x() >= hit_bounds_in_screen.x() && |
| 916 location.x() < hit_bounds_in_screen.right()); | 916 location.x() < hit_bounds_in_screen.right()); |
| 917 } | 917 } |
| 918 | 918 |
| 919 void ImmersiveFullscreenController::RecreateBubbleManager() { | 919 void ImmersiveFullscreenController::RecreateBubbleManager() { |
| 920 bubble_manager_.reset(new BubbleManager(this)); | 920 bubble_manager_.reset(new BubbleManager(this)); |
| 921 const std::vector<aura::Window*> transient_children = | 921 const std::vector<aura::Window*> transient_children = |
| 922 views::corewm::GetTransientChildren(native_window_); | 922 ::wm::GetTransientChildren(native_window_); |
| 923 for (size_t i = 0; i < transient_children.size(); ++i) { | 923 for (size_t i = 0; i < transient_children.size(); ++i) { |
| 924 aura::Window* transient_child = transient_children[i]; | 924 aura::Window* transient_child = transient_children[i]; |
| 925 views::BubbleDelegateView* bubble_delegate = | 925 views::BubbleDelegateView* bubble_delegate = |
| 926 AsBubbleDelegate(transient_child); | 926 AsBubbleDelegate(transient_child); |
| 927 if (bubble_delegate && | 927 if (bubble_delegate && |
| 928 bubble_delegate->GetAnchorView() && | 928 bubble_delegate->GetAnchorView() && |
| 929 top_container_->Contains(bubble_delegate->GetAnchorView())) { | 929 top_container_->Contains(bubble_delegate->GetAnchorView())) { |
| 930 bubble_manager_->StartObserving(transient_child); | 930 bubble_manager_->StartObserving(transient_child); |
| 931 } | 931 } |
| 932 } | 932 } |
| 933 } | 933 } |
| 934 | 934 |
| 935 } // namespace ash | 935 } // namespace ash |
| OLD | NEW |