Commit e046a6ea authored by Yuichiro Hanada's avatar Yuichiro Hanada Committed by Commit Bot

Revert "Cleanup IsArcAppWindow() in ArcWindowDelegateImpl."

This reverts commit ce0157f4.

Reason for revert: This change breaks text input on ARC windows.
Bug: 866784

Original change's description:
> Cleanup IsArcAppWindow() in ArcWindowDelegateImpl.
> 
> Now aura::client::kAppType property is set for an ARC notification
> window. We can use it for check.
> 
> Change-Id: Id27f5ab83492a4c1a517b1350ae1fc30bfbf8fae
> Reviewed-on: https://chromium-review.googlesource.com/1146626
> Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
> Reviewed-by: Yusuke Sato <yusukes@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#577422}

TBR=yusukes@chromium.org,yhanada@chromium.org

Change-Id: I9a58768a0ae0d84d13d9943674ed60954a9b39d5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/1148120Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Commit-Queue: Yuichiro Hanada <yhanada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577451}
parent 182500b6
......@@ -31,6 +31,9 @@ namespace arc {
namespace {
constexpr char kArcNotificationAppId[] =
"org.chromium.arc.ArcNotificationService";
base::Optional<double> g_override_default_device_scale_factor;
double GetDefaultDeviceScaleFactor() {
......@@ -48,10 +51,29 @@ class ArcWindowDelegateImpl : public ArcImeService::ArcWindowDelegate {
~ArcWindowDelegateImpl() override = default;
bool IsInArcAppWindow(const aura::Window* window) const override {
for (; window; window = window->parent()) {
if (IsArcAppWindow(window))
return true;
bool IsExoWindow(const aura::Window* window) const override {
return exo::Surface::AsSurface(window) ||
exo::ShellSurface::GetMainSurface(window);
}
bool IsArcWindow(const aura::Window* window) const override {
if (!IsExoWindow(window))
return false;
aura::Window* active = exo::WMHelper::GetInstance()->GetActiveWindow();
if (!active || !active->Contains(window))
return false;
// If the ARC app is focused, the active window should be ARC app window.
if (IsArcAppWindow(active))
return true;
// If the ARC notification is focused, the active window is not ARC app
// window. Find an app id set to the window and check if it is the ARC
// notification app id.
for (; window && window != active; window = window->parent()) {
const std::string* app_id = exo::ShellSurface::GetApplicationId(window);
if (app_id)
return *app_id == kArcNotificationAppId;
}
return false;
}
......@@ -180,10 +202,13 @@ void ArcImeService::ReattachInputMethod(aura::Window* old_window,
// Overridden from aura::EnvObserver:
void ArcImeService::OnWindowInitialized(aura::Window* new_window) {
if (arc_window_delegate_->IsInArcAppWindow(new_window) &&
!is_focus_observer_installed_) {
arc_window_delegate_->RegisterFocusObserver();
is_focus_observer_installed_ = true;
// Register the focus observer when every exo window is created because an
// application id might not be set here yet.
if (arc_window_delegate_->IsExoWindow(new_window)) {
if (!is_focus_observer_installed_) {
arc_window_delegate_->RegisterFocusObserver();
is_focus_observer_installed_ = true;
}
}
// TODO(mash): Support virtual keyboard under MASH. There is no
......@@ -226,7 +251,7 @@ void ArcImeService::OnWindowFocused(aura::Window* gained_focus,
const bool detach = (lost_focus && focused_arc_window_ == lost_focus);
const bool attach =
(gained_focus && arc_window_delegate_->IsInArcAppWindow(gained_focus));
(gained_focus && arc_window_delegate_->IsArcWindow(gained_focus));
if (detach) {
focused_arc_window_->RemoveObserver(this);
......
......@@ -55,9 +55,9 @@ class ArcImeService : public KeyedService,
class ArcWindowDelegate {
public:
virtual ~ArcWindowDelegate() = default;
// Check the |window| is a transient child of an ARC window.
virtual bool IsInArcAppWindow(const aura::Window* window) const = 0;
virtual ~ArcWindowDelegate() {}
virtual bool IsExoWindow(const aura::Window* window) const = 0;
virtual bool IsArcWindow(const aura::Window* window) const = 0;
virtual void RegisterFocusObserver() = 0;
virtual void UnregisterFocusObserver() = 0;
virtual ui::InputMethod* GetInputMethodForWindow(
......
......@@ -124,7 +124,11 @@ class FakeArcWindowDelegate : public ArcImeService::ArcWindowDelegate {
explicit FakeArcWindowDelegate(ui::InputMethod* input_method)
: next_id_(0), test_input_method_(input_method) {}
bool IsInArcAppWindow(const aura::Window* window) const override {
bool IsExoWindow(const aura::Window* window) const override {
return IsArcWindow(window);
}
bool IsArcWindow(const aura::Window* window) const override {
return arc_window_id_.count(window->id());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment