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

Unified Diff: ash/wm/ash_focus_rules.cc

Issue 2809073002: cros: allow aura window not considered activatable for pointer event (Closed)
Patch Set: feedback from oshima and bugtracker 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: ash/wm/ash_focus_rules.cc
diff --git a/ash/wm/ash_focus_rules.cc b/ash/wm/ash_focus_rules.cc
index ac4d9a8d5632563c6275db5b47a2fa061bc2e870..10c81fd6373a1465230cec353884a2cc56096dd9 100644
--- a/ash/wm/ash_focus_rules.cc
+++ b/ash/wm/ash_focus_rules.cc
@@ -14,11 +14,15 @@
#include "ash/wm/window_state_aura.h"
#include "ash/wm_window.h"
#include "ui/aura/window.h"
+#include "ui/events/event.h"
namespace ash {
namespace wm {
namespace {
+// A property key to store whether activation on pointer is enabled or not.
+DEFINE_UI_CLASS_PROPERTY_KEY(bool, kActivateOnPointerKey, true);
+
bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window,
int container_id) {
for (; window; window = window->parent()) {
@@ -30,16 +34,19 @@ bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window,
} // namespace
+// static
+void AshFocusRules::SetActivateOnPointer(aura::Window* window,
+ bool activate_on_pointer) {
+ DCHECK(window);
+ window->SetProperty(kActivateOnPointerKey, activate_on_pointer);
+}
+
////////////////////////////////////////////////////////////////////////////////
// AshFocusRules, public:
-AshFocusRules::AshFocusRules() {}
+AshFocusRules::AshFocusRules() = default;
-AshFocusRules::~AshFocusRules() {}
-
-bool AshFocusRules::IsWindowConsideredActivatable(aura::Window* window) const {
- return ash::IsWindowConsideredActivatable(WmWindow::Get(window));
-}
+AshFocusRules::~AshFocusRules() = default;
////////////////////////////////////////////////////////////////////////////////
// AshFocusRules, ::wm::FocusRules:
@@ -73,6 +80,19 @@ bool AshFocusRules::CanActivateWindow(aura::Window* window) const {
return true;
}
+bool AshFocusRules::CanFocusWindow(aura::Window* window,
+ ui::Event* event) const {
+ if (!window)
+ return true;
+
+ if (event && (event->IsMouseEvent() || event->IsGestureEvent()) &&
+ !window->GetProperty(kActivateOnPointerKey)) {
+ return false;
+ }
+
+ return BaseFocusRules::CanFocusWindow(window, event);
+}
+
aura::Window* AshFocusRules::GetNextActivatableWindow(
aura::Window* ignore) const {
DCHECK(ignore);
@@ -141,7 +161,7 @@ aura::Window* AshFocusRules::GetTopmostWindowToActivateInContainer(
!window_state->IsMinimized())
return *i;
}
- return NULL;
+ return nullptr;
}
} // namespace wm

Powered by Google App Engine
This is Rietveld 408576698