forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ime_focus_handler.cc
42 lines (32 loc) · 1.33 KB
/
ime_focus_handler.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/ime/ime_focus_handler.h"
#include "base/logging.h"
#include "services/ws/window_service.h"
#include "ui/aura/client/focus_client.h"
#include "ui/base/ime/input_method.h"
namespace ash {
ImeFocusHandler::ImeFocusHandler(aura::client::FocusClient* focus_client,
ui::InputMethod* input_method)
: focus_client_(focus_client), input_method_(input_method) {
DCHECK(input_method_);
focus_client_->AddObserver(this);
}
ImeFocusHandler::~ImeFocusHandler() {
focus_client_->RemoveObserver(this);
}
void ImeFocusHandler::OnWindowFocused(aura::Window* gained_focus,
aura::Window* lost_focus) {
const bool proxy_window_gaining_focus =
ws::WindowService::IsProxyWindow(gained_focus);
const bool proxy_window_losing_focus =
ws::WindowService::IsProxyWindow(lost_focus);
// Focus moves to a ProxyWindow from an ash window.
if (proxy_window_gaining_focus && !proxy_window_losing_focus)
input_method_->OnBlur();
// Focus moves to an ash window from a ProxyWindow.
if (!proxy_window_gaining_focus && proxy_window_losing_focus)
input_method_->OnFocus();
}
} // namespace ash