Commit c4b94296 authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

ws2: Wireup SetWindowTextInputState and SetImeVisibility

Text input state and IME visibility are indended for PlatformWindow.
WindowTree calls WindowServiceDelegate to update them.
WindowServiceDelegateImpl forwards the states to
AshWindowTreeHostPlatfom to update the underlying PlatformWindow
if the change comes from an active window.

Bug: 852440
Change-Id: Id584ba0f5a17768fddd3d54caa2e9da051b14ee7
Reviewed-on: https://chromium-review.googlesource.com/1112069
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569788}
parent b87c9121
...@@ -146,6 +146,9 @@ specific_include_rules = { ...@@ -146,6 +146,9 @@ specific_include_rules = {
"window_manager.cc": [ "window_manager.cc": [
"+ash/host/ash_window_tree_host.h" "+ash/host/ash_window_tree_host.h"
], ],
"window_service_delegate_impl.cc": [
"+ash/host/ash_window_tree_host.h"
],
"window_manager_service.cc": [ "window_manager_service.cc": [
"+chromeos/cryptohome", "+chromeos/cryptohome",
"+services/ui/service.h" "+services/ui/service.h"
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "services/ui/public/interfaces/ime/ime.mojom.h"
#include "ui/display/display.h" #include "ui/display/display.h"
namespace aura { namespace aura {
...@@ -62,6 +63,11 @@ class ASH_EXPORT AshWindowTreeHost { ...@@ -62,6 +63,11 @@ class ASH_EXPORT AshWindowTreeHost {
display::Display::Rotation rotation) = 0; display::Display::Rotation rotation) = 0;
virtual void ClearCursorConfig() = 0; virtual void ClearCursorConfig() = 0;
// Updates IME of underlying PlatformWindow.
virtual void UpdateTextInputState(ui::mojom::TextInputStatePtr state) {}
virtual void UpdateImeVisibility(bool visible,
ui::mojom::TextInputStatePtr state) {}
protected: protected:
// Returns true if cursor confinement should be allowed. For development // Returns true if cursor confinement should be allowed. For development
// builds this will return false, for ease of switching between windows, // builds this will return false, for ease of switching between windows,
......
...@@ -95,6 +95,17 @@ void AshWindowTreeHostPlatform::ClearCursorConfig() { ...@@ -95,6 +95,17 @@ void AshWindowTreeHostPlatform::ClearCursorConfig() {
GetAcceleratedWidget()); GetAcceleratedWidget());
} }
void AshWindowTreeHostPlatform::UpdateTextInputState(
ui::mojom::TextInputStatePtr state) {
SetTextInputState(std::move(state));
}
void AshWindowTreeHostPlatform::UpdateImeVisibility(
bool visible,
ui::mojom::TextInputStatePtr state) {
SetImeVisibility(visible, std::move(state));
}
void AshWindowTreeHostPlatform::SetRootWindowTransformer( void AshWindowTreeHostPlatform::SetRootWindowTransformer(
std::unique_ptr<RootWindowTransformer> transformer) { std::unique_ptr<RootWindowTransformer> transformer) {
transformer_helper_.SetRootWindowTransformer(std::move(transformer)); transformer_helper_.SetRootWindowTransformer(std::move(transformer));
......
...@@ -48,6 +48,9 @@ class ASH_EXPORT AshWindowTreeHostPlatform ...@@ -48,6 +48,9 @@ class ASH_EXPORT AshWindowTreeHostPlatform
void SetCursorConfig(const display::Display& display, void SetCursorConfig(const display::Display& display,
display::Display::Rotation rotation) override; display::Display::Rotation rotation) override;
void ClearCursorConfig() override; void ClearCursorConfig() override;
void UpdateTextInputState(ui::mojom::TextInputStatePtr state) override;
void UpdateImeVisibility(bool visible,
ui::mojom::TextInputStatePtr state) override;
// aura::WindowTreeHostPlatform: // aura::WindowTreeHostPlatform:
void SetRootTransform(const gfx::Transform& transform) override; void SetRootTransform(const gfx::Transform& transform) override;
......
...@@ -5,11 +5,14 @@ ...@@ -5,11 +5,14 @@
#include "ash/ws/window_service_delegate_impl.h" #include "ash/ws/window_service_delegate_impl.h"
#include "ash/accelerators/accelerator_controller.h" #include "ash/accelerators/accelerator_controller.h"
#include "ash/host/ash_window_tree_host.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/container_finder.h" #include "ash/wm/container_finder.h"
#include "ash/wm/non_client_frame_controller.h" #include "ash/wm/non_client_frame_controller.h"
#include "ash/wm/top_level_window_factory.h" #include "ash/wm/top_level_window_factory.h"
#include "ash/wm/toplevel_window_event_handler.h" #include "ash/wm/toplevel_window_event_handler.h"
#include "ash/wm/window_util.h"
#include "base/bind.h" #include "base/bind.h"
#include "mojo/public/cpp/bindings/map.h" #include "mojo/public/cpp/bindings/map.h"
#include "services/ui/public/interfaces/window_manager.mojom.h" #include "services/ui/public/interfaces/window_manager.mojom.h"
...@@ -159,4 +162,25 @@ void WindowServiceDelegateImpl::CancelDragLoop(aura::Window* window) { ...@@ -159,4 +162,25 @@ void WindowServiceDelegateImpl::CancelDragLoop(aura::Window* window) {
aura::client::GetDragDropClient(window->GetRootWindow())->DragCancel(); aura::client::GetDragDropClient(window->GetRootWindow())->DragCancel();
} }
void WindowServiceDelegateImpl::UpdateTextInputState(
aura::Window* window,
ui::mojom::TextInputStatePtr state) {
if (!wm::IsActiveWindow(window))
return;
RootWindowController::ForWindow(window)->ash_host()->UpdateTextInputState(
std::move(state));
}
void WindowServiceDelegateImpl::UpdateImeVisibility(
aura::Window* window,
bool visible,
ui::mojom::TextInputStatePtr state) {
if (!wm::IsActiveWindow(window))
return;
RootWindowController::ForWindow(window)->ash_host()->UpdateImeVisibility(
visible, std::move(state));
}
} // namespace ash } // namespace ash
...@@ -35,6 +35,11 @@ class WindowServiceDelegateImpl : public ui::ws2::WindowServiceDelegate { ...@@ -35,6 +35,11 @@ class WindowServiceDelegateImpl : public ui::ws2::WindowServiceDelegate {
ui::DragDropTypes::DragEventSource source, ui::DragDropTypes::DragEventSource source,
DragDropCompletedCallback callback) override; DragDropCompletedCallback callback) override;
void CancelDragLoop(aura::Window* window) override; void CancelDragLoop(aura::Window* window) override;
void UpdateTextInputState(aura::Window* window,
ui::mojom::TextInputStatePtr state) override;
void UpdateImeVisibility(aura::Window* window,
bool visible,
ui::mojom::TextInputStatePtr state) override;
private: private:
DISALLOW_COPY_AND_ASSIGN(WindowServiceDelegateImpl); DISALLOW_COPY_AND_ASSIGN(WindowServiceDelegateImpl);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/component_export.h" #include "base/component_export.h"
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "services/ui/public/interfaces/ime/ime.mojom.h"
#include "services/ui/public/interfaces/window_tree_constants.mojom.h" #include "services/ui/public/interfaces/window_tree_constants.mojom.h"
#include "ui/base/cursor/cursor.h" #include "ui/base/cursor/cursor.h"
#include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/dragdrop/drag_drop_types.h"
...@@ -87,6 +88,18 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowServiceDelegate { ...@@ -87,6 +88,18 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowServiceDelegate {
// Called to cancel an in-progress drag loop that was started by RunDragLoop. // Called to cancel an in-progress drag loop that was started by RunDragLoop.
virtual void CancelDragLoop(aura::Window* window) {} virtual void CancelDragLoop(aura::Window* window) {}
// Called to update the text input state of the PlatformWindow associated with
// |window|. It is a no-op if |window| is not focused.
virtual void UpdateTextInputState(aura::Window* window,
ui::mojom::TextInputStatePtr state) {}
// Called to update the IME visibility and text input state of the
// PlatformWindow associated with |window|. It is a no-op if |window| is not
// focused.
virtual void UpdateImeVisibility(aura::Window* window,
bool visible,
ui::mojom::TextInputStatePtr state) {}
protected: protected:
virtual ~WindowServiceDelegate() = default; virtual ~WindowServiceDelegate() = default;
}; };
......
...@@ -1457,13 +1457,34 @@ void WindowTree::SetCursor(uint32_t change_id, ...@@ -1457,13 +1457,34 @@ void WindowTree::SetCursor(uint32_t change_id,
void WindowTree::SetWindowTextInputState(Id window_id, void WindowTree::SetWindowTextInputState(Id window_id,
::ui::mojom::TextInputStatePtr state) { ::ui::mojom::TextInputStatePtr state) {
NOTIMPLEMENTED_LOG_ONCE(); aura::Window* window = GetWindowByTransportId(window_id);
if (!window) {
DVLOG(1) << "SetWindowTextInputState failed (no window)";
return;
}
if (!IsClientCreatedWindow(window)) {
DVLOG(1) << "SetWindowTextInputState failed (access denied)";
return;
}
window_service_->delegate()->UpdateTextInputState(window, std::move(state));
} }
void WindowTree::SetImeVisibility(Id window_id, void WindowTree::SetImeVisibility(Id window_id,
bool visible, bool visible,
::ui::mojom::TextInputStatePtr state) { ::ui::mojom::TextInputStatePtr state) {
NOTIMPLEMENTED_LOG_ONCE(); aura::Window* window = GetWindowByTransportId(window_id);
if (!window) {
DVLOG(1) << "SetImeVisibility failed (no window)";
return;
}
if (!IsClientCreatedWindow(window)) {
DVLOG(1) << "SetImeVisibility failed (access denied)";
return;
}
window_service_->delegate()->UpdateImeVisibility(window, visible,
std::move(state));
} }
void WindowTree::SetEventTargetingPolicy( void WindowTree::SetEventTargetingPolicy(
......
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