Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Unified Diff: ui/wm/core/focus_controller.cc

Issue 2809073002: cros: allow aura window not considered activatable for pointer event (Closed)
Patch Set: ui::Event* Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/wm/core/focus_controller.cc
diff --git a/ui/wm/core/focus_controller.cc b/ui/wm/core/focus_controller.cc
index 594e66ee94db2655a9a8064e0c57e69141603ee3..7095bf1d710b902eff4c6a83aa825ecf081174d5 100644
--- a/ui/wm/core/focus_controller.cc
+++ b/ui/wm/core/focus_controller.cc
@@ -38,8 +38,8 @@ void StackTransientParentsBelowModalWindow(aura::Window* window) {
// FocusController, public:
FocusController::FocusController(FocusRules* rules)
- : active_window_(NULL),
- focused_window_(NULL),
+ : active_window_(nullptr),
+ focused_window_(nullptr),
updating_focus_(false),
updating_activation_(false),
rules_(rules),
@@ -47,8 +47,7 @@ FocusController::FocusController(FocusRules* rules)
DCHECK(rules);
}
-FocusController::~FocusController() {
-}
+FocusController::~FocusController() = default;
////////////////////////////////////////////////////////////////////////////////
// FocusController, aura::client::ActivationClient implementation:
@@ -127,7 +126,8 @@ void FocusController::OnKeyEvent(ui::KeyEvent* event) {
void FocusController::OnMouseEvent(ui::MouseEvent* event) {
if (event->type() == ui::ET_MOUSE_PRESSED && !event->handled())
- WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target()));
+ WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target()),
+ event);
}
void FocusController::OnScrollEvent(ui::ScrollEvent* event) {
@@ -140,7 +140,8 @@ void FocusController::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_BEGIN &&
event->details().touch_points() == 1 &&
!event->handled()) {
- WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target()));
+ WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target()),
+ event);
}
}
@@ -196,7 +197,7 @@ void FocusController::FocusAndActivateWindow(
// that the rules could redirect activation activation and/or focus.
aura::Window* focusable = rules_->GetFocusableWindow(window);
aura::Window* activatable =
- focusable ? rules_->GetActivatableWindow(focusable) : NULL;
+ focusable ? rules_->GetActivatableWindow(focusable) : nullptr;
// We need valid focusable/activatable windows in the event we're not clearing
// focus. "Clearing focus" is inferred by whether or not |window| passed to
@@ -224,7 +225,7 @@ void FocusController::FocusAndActivateWindow(
void FocusController::SetFocusedWindow(aura::Window* window) {
if (updating_focus_ || window == focused_window_)
return;
- DCHECK(rules_->CanFocusWindow(window));
+ DCHECK(rules_->CanFocusWindow(window, nullptr));
if (window)
DCHECK_EQ(window, rules_->GetFocusableWindow(window));
@@ -247,7 +248,7 @@ void FocusController::SetFocusedWindow(aura::Window* window) {
for (auto& observer : focus_observers_) {
observer.OnWindowFocused(
focused_window_,
- window_tracker.Contains(lost_focus) ? lost_focus : NULL);
+ window_tracker.Contains(lost_focus) ? lost_focus : nullptr);
}
if (window_tracker.Contains(lost_focus)) {
aura::client::FocusChangeObserver* observer =
@@ -260,7 +261,7 @@ void FocusController::SetFocusedWindow(aura::Window* window) {
if (observer) {
observer->OnWindowFocused(
focused_window_,
- window_tracker.Contains(lost_focus) ? lost_focus : NULL);
+ window_tracker.Contains(lost_focus) ? lost_focus : nullptr);
}
}
@@ -300,7 +301,7 @@ void FocusController::SetActiveWindow(
if (active_window_)
StackActiveWindow();
- aura::client::ActivationChangeObserver* observer = NULL;
+ aura::client::ActivationChangeObserver* observer = nullptr;
if (window_tracker.Contains(lost_activation)) {
observer = aura::client::GetActivationChangeObserver(lost_activation);
if (observer)
@@ -310,12 +311,12 @@ void FocusController::SetActiveWindow(
if (observer) {
observer->OnWindowActivated(
reason, active_window_,
- window_tracker.Contains(lost_activation) ? lost_activation : NULL);
+ window_tracker.Contains(lost_activation) ? lost_activation : nullptr);
}
for (auto& observer : activation_observers_) {
observer.OnWindowActivated(
reason, active_window_,
- window_tracker.Contains(lost_activation) ? lost_activation : NULL);
+ window_tracker.Contains(lost_activation) ? lost_activation : nullptr);
}
}
@@ -338,7 +339,7 @@ void FocusController::WindowLostFocusFromDispositionChange(
aura::Window* next_activatable = rules_->GetNextActivatableWindow(window);
SetActiveWindow(aura::client::ActivationChangeObserver::ActivationReason::
WINDOW_DISPOSITION_CHANGED,
- NULL, next_activatable);
+ nullptr, next_activatable);
if (!(active_window_ && active_window_->Contains(focused_window_)))
SetFocusedWindow(next_activatable);
} else if (window->Contains(focused_window_)) {
@@ -347,11 +348,12 @@ void FocusController::WindowLostFocusFromDispositionChange(
}
}
-void FocusController::WindowFocusedFromInputEvent(aura::Window* window) {
+void FocusController::WindowFocusedFromInputEvent(aura::Window* window,
+ ui::Event* event) {
// Only focus |window| if it or any of its parents can be focused. Otherwise
// FocusWindow() will focus the topmost window, which may not be the
// currently focused one.
- if (rules_->CanFocusWindow(GetToplevelWindow(window))) {
+ if (rules_->CanFocusWindow(GetToplevelWindow(window), event)) {
FocusAndActivateWindow(
aura::client::ActivationChangeObserver::ActivationReason::INPUT_EVENT,
window);

Powered by Google App Engine
This is Rietveld 408576698