This source file includes following definitions.
- CanActivateWindow
- SupportsChildActivation
- IsWindowConsideredVisibleForActivation
- GetToplevelWindow
- GetNextActivatableWindow
#include "ui/views/widget/desktop_aura/desktop_focus_rules.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
namespace views {
DesktopFocusRules::DesktopFocusRules(aura::Window* content_window)
: content_window_(content_window) {}
DesktopFocusRules::~DesktopFocusRules() {}
bool DesktopFocusRules::CanActivateWindow(aura::Window* window) const {
if (!BaseFocusRules::CanActivateWindow(window))
return false;
return !window || content_window_->GetRootWindow()->Contains(window);
}
bool DesktopFocusRules::SupportsChildActivation(aura::Window* window) const {
return window == content_window_->parent() ||
window->GetRootWindow() == window;
}
bool DesktopFocusRules::IsWindowConsideredVisibleForActivation(
aura::Window* window) const {
return BaseFocusRules::IsWindowConsideredVisibleForActivation(window) ||
(window == content_window_);
}
aura::Window* DesktopFocusRules::GetToplevelWindow(
aura::Window* window) const {
aura::Window* top_level_window =
wm::BaseFocusRules::GetToplevelWindow(window);
if (top_level_window == content_window_->parent())
return content_window_;
return top_level_window;
}
aura::Window* DesktopFocusRules::GetNextActivatableWindow(
aura::Window* window) const {
aura::Window* next_activatable_window =
wm::BaseFocusRules::GetNextActivatableWindow(window);
if (next_activatable_window == content_window_->parent() &&
CanActivateWindow(content_window_))
return content_window_;
return next_activatable_window;
}
}