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..1dda1cd9a4f69bec98c738d0bcf76c16545d59f5 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 mouse click is enabled or not. |
+DEFINE_UI_CLASS_PROPERTY_KEY(bool, kActivateOnClickKey, 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::SetActivateOnClick(aura::Window* window, |
+ bool activate_on_click) { |
+ DCHECK(window); |
+ window->SetProperty(kActivateOnClickKey, activate_on_click); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// 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,18 @@ bool AshFocusRules::CanActivateWindow(aura::Window* window) const { |
return true; |
} |
+bool AshFocusRules::IsWindowConsideredActivatableForEvent( |
+ aura::Window* window, |
+ ui::Event* event) const { |
+ if (!window) |
+ return true; |
+ |
+ if (event->IsMouseEvent()) |
oshima
2017/04/11 20:54:40
don't we need to filter other events such as touch
Qiang(Joe) Xu
2017/04/12 19:00:02
Touch event should be handled on OnGestureEvent. F
|
+ return window->GetProperty(kActivateOnClickKey); |
+ |
+ return true; |
+} |
+ |
aura::Window* AshFocusRules::GetNextActivatableWindow( |
aura::Window* ignore) const { |
DCHECK(ignore); |
@@ -141,7 +160,7 @@ aura::Window* AshFocusRules::GetTopmostWindowToActivateInContainer( |
!window_state->IsMinimized()) |
return *i; |
} |
- return NULL; |
+ return nullptr; |
} |
} // namespace wm |