0

Start adapting remoting for mushrome.

This moves some files in ozone which can be used more generally
to //ui/events/, and makes a mus implementation of the
InputInjector. Sharing a screen in remoting no longer instantly crashes,
and the remote host is able to send keyboard events, but isn't able to
send any mouse events because the sending of frame data isn't working
yet.

Bug: 734671
Change-Id: I18a7ec80af3ac9d17db4bfd8eb44d57a440649de
Reviewed-on: https://chromium-review.googlesource.com/653596
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Gary Kacmarcik <garykac@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Elliot Glaysher <erg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502324}
This commit is contained in:
Elliot Glaysher
2017-09-15 19:02:14 +00:00
committed by Commit Bot
parent c41c1d1739
commit aa763fabc4
71 changed files with 738 additions and 286 deletions
chrome/browser/extensions/api/messaging
remoting
services/ui
ui

@ -29,6 +29,7 @@
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/it2me/it2me_native_messaging_host.h"
#include "remoting/host/policy_watcher.h"
#include "ui/events/system_input_injector.h"
#include "ui/gfx/native_widget_types.h"
#include "url/gurl.h"
@ -107,7 +108,8 @@ std::unique_ptr<NativeMessageHost> CreateIt2MeHost() {
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI),
base::CreateSingleThreadTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BACKGROUND}));
{base::MayBlock(), base::TaskPriority::BACKGROUND}),
ui::GetSystemInputInjectorFactory());
std::unique_ptr<remoting::PolicyWatcher> policy_watcher =
remoting::PolicyWatcher::CreateWithPolicyService(
g_browser_process->policy_service());

@ -19,7 +19,12 @@ include_rules = [
"+third_party/skia",
"+third_party/webrtc",
"+third_party/libjingle_xmpp/xmpp",
"+ui",
"+ui/aura",
"+ui/base",
"+ui/compositor",
"+ui/events",
"+ui/gfx",
"+ui/views",
]
specific_include_rules = {

@ -40,7 +40,8 @@ std::unique_ptr<AudioCapturer> BasicDesktopEnvironment::CreateAudioCapturer() {
std::unique_ptr<InputInjector> BasicDesktopEnvironment::CreateInputInjector() {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
return InputInjector::Create(input_task_runner(), ui_task_runner());
return InputInjector::Create(input_task_runner(), ui_task_runner(),
system_input_injector_factory());
}
std::unique_ptr<ScreenControls>
@ -87,11 +88,13 @@ BasicDesktopEnvironment::BasicDesktopEnvironment(
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
const DesktopEnvironmentOptions& options)
: caller_task_runner_(caller_task_runner),
video_capture_task_runner_(video_capture_task_runner),
input_task_runner_(input_task_runner),
ui_task_runner_(ui_task_runner),
system_input_injector_factory_(system_input_injector_factory),
options_(options) {
DCHECK(caller_task_runner_->BelongsToCurrentThread());
#if defined(USE_X11)
@ -103,11 +106,13 @@ BasicDesktopEnvironmentFactory::BasicDesktopEnvironmentFactory(
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory)
: caller_task_runner_(caller_task_runner),
video_capture_task_runner_(video_capture_task_runner),
input_task_runner_(input_task_runner),
ui_task_runner_(ui_task_runner) {}
ui_task_runner_(ui_task_runner),
system_input_injector_factory_(system_input_injector_factory) {}
BasicDesktopEnvironmentFactory::~BasicDesktopEnvironmentFactory() {}

@ -18,6 +18,10 @@ namespace base {
class SingleThreadTaskRunner;
}
namespace ui {
class SystemInputInjectorFactory;
}
namespace webrtc {
class DesktopCaptureOptions;
@ -52,6 +56,7 @@ class BasicDesktopEnvironment : public DesktopEnvironment {
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
const DesktopEnvironmentOptions& options);
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const {
@ -79,6 +84,10 @@ class BasicDesktopEnvironment : public DesktopEnvironment {
return *options_.desktop_capture_options();
}
ui::SystemInputInjectorFactory* system_input_injector_factory() const {
return system_input_injector_factory_;
}
const DesktopEnvironmentOptions& desktop_environment_options() const {
return options_;
}
@ -97,6 +106,9 @@ class BasicDesktopEnvironment : public DesktopEnvironment {
// Used to run UI code.
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
// Passed to InputInjector.
ui::SystemInputInjectorFactory* system_input_injector_factory_;
DesktopEnvironmentOptions options_;
DISALLOW_COPY_AND_ASSIGN(BasicDesktopEnvironment);
@ -109,7 +121,8 @@ class BasicDesktopEnvironmentFactory : public DesktopEnvironmentFactory {
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory);
~BasicDesktopEnvironmentFactory() override;
// DesktopEnvironmentFactory implementation.
@ -133,6 +146,10 @@ class BasicDesktopEnvironmentFactory : public DesktopEnvironmentFactory {
return ui_task_runner_;
}
ui::SystemInputInjectorFactory* system_input_injector_factory() const {
return system_input_injector_factory_;
}
private:
// Task runner on which methods of DesktopEnvironmentFactory interface should
// be called.
@ -147,6 +164,9 @@ class BasicDesktopEnvironmentFactory : public DesktopEnvironmentFactory {
// Used to run UI code.
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
// Passed to the environments built.
ui::SystemInputInjectorFactory* system_input_injector_factory_;
DISALLOW_COPY_AND_ASSIGN(BasicDesktopEnvironmentFactory);
};

@ -32,7 +32,8 @@ ChromotingHostContext::ChromotingHostContext(
scoped_refptr<AutoThreadTaskRunner> network_task_runner,
scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner,
scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner,
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter)
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
ui::SystemInputInjectorFactory* system_input_injector_factory)
: ui_task_runner_(ui_task_runner),
audio_task_runner_(audio_task_runner),
file_task_runner_(file_task_runner),
@ -40,8 +41,8 @@ ChromotingHostContext::ChromotingHostContext(
network_task_runner_(network_task_runner),
video_capture_task_runner_(video_capture_task_runner),
video_encode_task_runner_(video_encode_task_runner),
url_request_context_getter_(url_request_context_getter) {
}
url_request_context_getter_(url_request_context_getter),
system_input_injector_factory_(system_input_injector_factory) {}
ChromotingHostContext::~ChromotingHostContext() {
}
@ -50,7 +51,8 @@ std::unique_ptr<ChromotingHostContext> ChromotingHostContext::Copy() {
return base::WrapUnique(new ChromotingHostContext(
ui_task_runner_, audio_task_runner_, file_task_runner_,
input_task_runner_, network_task_runner_, video_capture_task_runner_,
video_encode_task_runner_, url_request_context_getter_));
video_encode_task_runner_, url_request_context_getter_,
system_input_injector_factory_));
}
scoped_refptr<AutoThreadTaskRunner> ChromotingHostContext::audio_task_runner()
@ -93,6 +95,11 @@ ChromotingHostContext::url_request_context_getter() const {
return url_request_context_getter_;
}
ui::SystemInputInjectorFactory*
ChromotingHostContext::system_input_injector_factory() const {
return system_input_injector_factory_;
}
std::unique_ptr<ChromotingHostContext> ChromotingHostContext::Create(
scoped_refptr<AutoThreadTaskRunner> ui_task_runner) {
#if defined(OS_WIN)
@ -125,7 +132,8 @@ std::unique_ptr<ChromotingHostContext> ChromotingHostContext::Create(
AutoThread::Create("ChromotingCaptureThread", ui_task_runner),
AutoThread::Create("ChromotingEncodeThread", ui_task_runner),
make_scoped_refptr(
new URLRequestContextGetter(network_task_runner, file_task_runner))));
new URLRequestContextGetter(network_task_runner, file_task_runner)),
nullptr));
}
#if defined(OS_CHROMEOS)
@ -135,10 +143,10 @@ std::unique_ptr<ChromotingHostContext> ChromotingHostContext::CreateForChromeOS(
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) {
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory) {
DCHECK(url_request_context_getter.get());
// AutoThreadTaskRunner is a TaskRunner with the special property that it will
// continue to process tasks until no references remain, at least. The
// QuitClosure we usually pass does the simple thing of stopping the
@ -162,7 +170,7 @@ std::unique_ptr<ChromotingHostContext> ChromotingHostContext::CreateForChromeOS(
io_auto_task_runner, // network_task_runner
ui_auto_task_runner, // video_capture_task_runner
AutoThread::Create("ChromotingEncodeThread", file_auto_task_runner),
url_request_context_getter));
url_request_context_getter, system_input_injector_factory));
}
#endif // defined(OS_CHROMEOS)

@ -19,6 +19,10 @@ namespace net {
class URLRequestContextGetter;
} // namespace net
namespace ui {
class SystemInputInjectorFactory;
} // namespace ui
namespace remoting {
class AutoThreadTaskRunner;
@ -48,7 +52,8 @@ class ChromotingHostContext {
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory);
#endif // defined(OS_CHROMEOS)
~ChromotingHostContext();
@ -87,6 +92,13 @@ class ChromotingHostContext {
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter()
const;
// Gives the factory which builds the SystemInputInjector, which takes events
// and passes them to the system for dispatch.
//
// Currently only implemented on chromeos, but as mus usage comes to the
// desktop, this will be used everywhere.
ui::SystemInputInjectorFactory* system_input_injector_factory() const;
private:
ChromotingHostContext(
scoped_refptr<AutoThreadTaskRunner> ui_task_runner,
@ -96,7 +108,8 @@ class ChromotingHostContext {
scoped_refptr<AutoThreadTaskRunner> network_task_runner,
scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner,
scoped_refptr<AutoThreadTaskRunner> video_encode_task_runner,
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
ui::SystemInputInjectorFactory* system_input_injector_factory);
// Caller-supplied UI thread. This is usually the application main thread.
scoped_refptr<AutoThreadTaskRunner> ui_task_runner_;
@ -122,6 +135,10 @@ class ChromotingHostContext {
// Serves URLRequestContexts that use the network and UI task runners.
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
// A factory which makes a SystemInputInjector. Currently only non-null on
// chromeos, though it's intended to be set everywhere mus is used.
ui::SystemInputInjectorFactory* system_input_injector_factory_;
DISALLOW_COPY_AND_ASSIGN(ChromotingHostContext);
};

@ -87,11 +87,11 @@ int DesktopProcessMain() {
desktop_environment_factory.reset(new SessionDesktopEnvironmentFactory(
ui_task_runner, video_capture_task_runner, input_task_runner,
ui_task_runner, inject_sas_closure, lock_workstation_closure));
ui_task_runner, nullptr, inject_sas_closure, lock_workstation_closure));
#else // !defined(OS_WIN)
desktop_environment_factory.reset(new Me2MeDesktopEnvironmentFactory(
ui_task_runner, video_capture_task_runner, input_task_runner,
ui_task_runner));
ui_task_runner, nullptr));
#endif // !defined(OS_WIN)
if (!desktop_process.Start(std::move(desktop_environment_factory)))

@ -15,6 +15,10 @@ namespace base {
class SingleThreadTaskRunner;
} // namespace base
namespace ui {
class SystemInputInjectorFactory;
} // namespace ui
namespace remoting {
// TODO(sergeyu): Move ClipboardStub implementation to Clipboard.
@ -27,7 +31,8 @@ class InputInjector : public protocol::ClipboardStub,
// thread.
static std::unique_ptr<InputInjector> Create(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* chromeos_system_input_injector_factory);
// Returns true if the InputInjector returned by Create() supports
// InjectTouchEvent() on this platform.

@ -19,8 +19,7 @@
#include "ui/base/ime/chromeos/input_method_manager.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/system_input_injector.h"
#include "ui/events/system_input_injector.h"
namespace remoting {
@ -73,7 +72,7 @@ bool shouldSetLockStates(ui::DomCode dom_code, bool key_pressed) {
// This class is run exclusively on the UI thread of the browser process.
class InputInjectorChromeos::Core {
public:
Core();
Core(ui::SystemInputInjectorFactory* system_input_injector_factory);
// Mirrors the public InputInjectorChromeos interface.
void InjectClipboardEvent(const ClipboardEvent& event);
@ -93,11 +92,16 @@ class InputInjectorChromeos::Core {
// display rotation settings.
std::unique_ptr<PointTransformer> point_transformer_;
// Creates |delegate_|. We store this since Core is created on one thread,
// but then Start() is run on a different one.
ui::SystemInputInjectorFactory* system_input_injector_factory_;
DISALLOW_COPY_AND_ASSIGN(Core);
};
InputInjectorChromeos::Core::Core() {
}
InputInjectorChromeos::Core::Core(
ui::SystemInputInjectorFactory* system_input_injector_factory)
: system_input_injector_factory_(system_input_injector_factory) {}
void InputInjectorChromeos::Core::InjectClipboardEvent(
const ClipboardEvent& event) {
@ -144,8 +148,8 @@ void InputInjectorChromeos::Core::InjectMouseEvent(const MouseEvent& event) {
void InputInjectorChromeos::Core::Start(
std::unique_ptr<protocol::ClipboardStub> client_clipboard) {
ui::OzonePlatform* ozone_platform = ui::OzonePlatform::GetInstance();
delegate_ = ozone_platform->CreateSystemInputInjector();
// OK, so we now need to plumb from ChromotingHostContext to here.
delegate_ = system_input_injector_factory_->CreateSystemInputInjector();
DCHECK(delegate_);
// Implemented by remoting::ClipboardAura.
@ -162,9 +166,10 @@ void InputInjectorChromeos::Core::SetLockStates(uint32_t states) {
}
InputInjectorChromeos::InputInjectorChromeos(
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory)
: input_task_runner_(task_runner) {
core_.reset(new Core());
core_.reset(new Core(system_input_injector_factory));
}
InputInjectorChromeos::~InputInjectorChromeos() {
@ -209,10 +214,12 @@ void InputInjectorChromeos::Start(
// static
std::unique_ptr<InputInjector> InputInjector::Create(
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory) {
// The Ozone input injector must be called on the UI task runner of the
// browser process.
return base::WrapUnique(new InputInjectorChromeos(ui_task_runner));
return base::WrapUnique(
new InputInjectorChromeos(ui_task_runner, system_input_injector_factory));
}
// static

@ -16,7 +16,8 @@ namespace remoting {
class InputInjectorChromeos : public InputInjector {
public:
explicit InputInjectorChromeos(
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
ui::SystemInputInjectorFactory* chromeos_system_input_injector_factory);
~InputInjectorChromeos() override;
@ -45,4 +46,4 @@ class InputInjectorChromeos : public InputInjector {
} // namespace remoting
#endif // REMOTING_HOST_INPUT_INJECTOR_CHROMEOS_H_
#endif // REMOTING_HOST_INPUT_INJECTOR_CHROMEOS_H_

@ -392,7 +392,8 @@ InputInjectorMac::Core::~Core() {}
// static
std::unique_ptr<InputInjector> InputInjector::Create(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* chromeos_system_input_injector_factory) {
return base::WrapUnique(new InputInjectorMac(main_task_runner));
}

@ -424,7 +424,8 @@ void InputInjectorWin::Core::SetLockStates(uint32_t states) {
// static
std::unique_ptr<InputInjector> InputInjector::Create(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* chromeos_system_input_injector_factory) {
return base::WrapUnique(
new InputInjectorWin(main_task_runner, ui_task_runner));
}

@ -630,7 +630,8 @@ void InputInjectorX11::Core::Stop() {
// static
std::unique_ptr<InputInjector> InputInjector::Create(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* chromeos_system_input_injector_factory) {
std::unique_ptr<InputInjectorX11> injector(
new InputInjectorX11(main_task_runner));
if (!injector->Init())

@ -85,7 +85,8 @@ void It2MeHost::Connect(
desktop_environment_factory_.reset(new It2MeDesktopEnvironmentFactory(
host_context_->network_task_runner(),
host_context_->video_capture_task_runner(),
host_context_->input_task_runner(), host_context_->ui_task_runner()));
host_context_->input_task_runner(), host_context_->ui_task_runner(),
host_context_->system_input_injector_factory()));
// Switch to the network thread to start the actual connection.
host_context_->network_task_runner()->PostTask(

@ -31,12 +31,14 @@ It2MeDesktopEnvironment::It2MeDesktopEnvironment(
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
base::WeakPtr<ClientSessionControl> client_session_control,
const DesktopEnvironmentOptions& options)
: BasicDesktopEnvironment(caller_task_runner,
video_capture_task_runner,
input_task_runner,
ui_task_runner,
system_input_injector_factory,
options) {
DCHECK(caller_task_runner->BelongsToCurrentThread());
@ -75,11 +77,13 @@ It2MeDesktopEnvironmentFactory::It2MeDesktopEnvironmentFactory(
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory)
: BasicDesktopEnvironmentFactory(caller_task_runner,
video_capture_task_runner,
input_task_runner,
ui_task_runner) {}
ui_task_runner,
system_input_injector_factory) {}
It2MeDesktopEnvironmentFactory::~It2MeDesktopEnvironmentFactory() {}
@ -90,7 +94,8 @@ std::unique_ptr<DesktopEnvironment> It2MeDesktopEnvironmentFactory::Create(
return base::WrapUnique(new It2MeDesktopEnvironment(
caller_task_runner(), video_capture_task_runner(), input_task_runner(),
ui_task_runner(), client_session_control, options));
ui_task_runner(), system_input_injector_factory(), client_session_control,
options));
}
} // namespace remoting

@ -30,6 +30,7 @@ class It2MeDesktopEnvironment : public BasicDesktopEnvironment {
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
base::WeakPtr<ClientSessionControl> client_session_control,
const DesktopEnvironmentOptions& options);
@ -53,7 +54,8 @@ class It2MeDesktopEnvironmentFactory : public BasicDesktopEnvironmentFactory {
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory);
~It2MeDesktopEnvironmentFactory() override;
// DesktopEnvironmentFactory interface.

@ -91,12 +91,17 @@ LocalInputMonitorChromeos::Core::Core(
}
void LocalInputMonitorChromeos::Core::Start() {
ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
// TODO(erg): Need to handle the mus case where PlatformEventSource is null
// because we are in mus. This class looks like it can be rewritten with mus
// EventMatchers. (And if that doesn't work, maybe a PointerObserver.)
if (ui::PlatformEventSource::GetInstance())
ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
point_transformer_.reset(new PointTransformer());
}
LocalInputMonitorChromeos::Core::~Core() {
ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this);
if (ui::PlatformEventSource::GetInstance())
ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this);
}
void LocalInputMonitorChromeos::Core::WillProcessEvent(

@ -70,11 +70,13 @@ Me2MeDesktopEnvironment::Me2MeDesktopEnvironment(
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
const DesktopEnvironmentOptions& options)
: BasicDesktopEnvironment(caller_task_runner,
video_capture_task_runner,
input_task_runner,
ui_task_runner,
system_input_injector_factory,
options) {
DCHECK(caller_task_runner->BelongsToCurrentThread());
@ -141,11 +143,13 @@ Me2MeDesktopEnvironmentFactory::Me2MeDesktopEnvironmentFactory(
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory)
: BasicDesktopEnvironmentFactory(caller_task_runner,
video_capture_task_runner,
input_task_runner,
ui_task_runner) {}
ui_task_runner,
system_input_injector_factory) {}
Me2MeDesktopEnvironmentFactory::~Me2MeDesktopEnvironmentFactory() {
}
@ -159,7 +163,7 @@ std::unique_ptr<DesktopEnvironment> Me2MeDesktopEnvironmentFactory::Create(
new Me2MeDesktopEnvironment(caller_task_runner(),
video_capture_task_runner(),
input_task_runner(), ui_task_runner(),
options));
system_input_injector_factory(), options));
if (!desktop_environment->InitializeSecurity(client_session_control)) {
return nullptr;
}

@ -32,6 +32,7 @@ class Me2MeDesktopEnvironment : public BasicDesktopEnvironment {
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
const DesktopEnvironmentOptions& options);
// Initializes security features of the desktop environment (the curtain mode
@ -60,7 +61,8 @@ class Me2MeDesktopEnvironmentFactory : public BasicDesktopEnvironmentFactory {
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory);
~Me2MeDesktopEnvironmentFactory() override;
// DesktopEnvironmentFactory interface.

@ -884,11 +884,13 @@ void HostProcess::StartOnUiThread() {
if (enable_window_capture_) {
desktop_environment_factory = new SingleWindowDesktopEnvironmentFactory(
context_->network_task_runner(), context_->video_capture_task_runner(),
context_->input_task_runner(), context_->ui_task_runner(), window_id_);
context_->input_task_runner(), context_->ui_task_runner(),
context_->system_input_injector_factory(), window_id_);
} else {
desktop_environment_factory = new Me2MeDesktopEnvironmentFactory(
context_->network_task_runner(), context_->video_capture_task_runner(),
context_->input_task_runner(), context_->ui_task_runner());
context_->input_task_runner(), context_->ui_task_runner(),
context_->system_input_injector_factory());
}
#endif // !defined(REMOTING_MULTI_PROCESS)

@ -33,6 +33,7 @@ class SingleWindowDesktopEnvironment : public BasicDesktopEnvironment {
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
webrtc::DesktopCapturer::SourceId window_id,
base::WeakPtr<ClientSessionControl> client_session_control,
const DesktopEnvironmentOptions& options);
@ -64,8 +65,8 @@ std::unique_ptr<InputInjector>
SingleWindowDesktopEnvironment::CreateInputInjector() {
DCHECK(caller_task_runner()->BelongsToCurrentThread());
std::unique_ptr<InputInjector> input_injector(
InputInjector::Create(input_task_runner(), ui_task_runner()));
std::unique_ptr<InputInjector> input_injector(InputInjector::Create(
input_task_runner(), ui_task_runner(), system_input_injector_factory()));
return SingleWindowInputInjector::CreateForWindow(
window_id_, std::move(input_injector));
}
@ -75,6 +76,7 @@ SingleWindowDesktopEnvironment::SingleWindowDesktopEnvironment(
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
webrtc::WindowId window_id,
base::WeakPtr<ClientSessionControl> client_session_control,
const DesktopEnvironmentOptions& options)
@ -82,6 +84,7 @@ SingleWindowDesktopEnvironment::SingleWindowDesktopEnvironment(
video_capture_task_runner,
input_task_runner,
ui_task_runner,
system_input_injector_factory,
options),
window_id_(window_id) {}
@ -90,11 +93,13 @@ SingleWindowDesktopEnvironmentFactory::SingleWindowDesktopEnvironmentFactory(
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
webrtc::WindowId window_id)
: BasicDesktopEnvironmentFactory(caller_task_runner,
video_capture_task_runner,
input_task_runner,
ui_task_runner),
ui_task_runner,
system_input_injector_factory),
window_id_(window_id) {}
SingleWindowDesktopEnvironmentFactory::
@ -109,7 +114,8 @@ SingleWindowDesktopEnvironmentFactory::Create(
return base::WrapUnique(new SingleWindowDesktopEnvironment(
caller_task_runner(), video_capture_task_runner(), input_task_runner(),
ui_task_runner(), window_id_, client_session_control, options));
ui_task_runner(), system_input_injector_factory(), window_id_,
client_session_control, options));
}
} // namespace remoting

@ -22,6 +22,7 @@ class SingleWindowDesktopEnvironmentFactory
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
webrtc::WindowId window_id);
~SingleWindowDesktopEnvironmentFactory() override;

@ -25,7 +25,8 @@ SessionDesktopEnvironment::CreateInputInjector() {
return base::MakeUnique<SessionInputInjectorWin>(
input_task_runner(),
InputInjector::Create(input_task_runner(), ui_task_runner()),
InputInjector::Create(input_task_runner(), ui_task_runner(),
system_input_injector_factory()),
ui_task_runner(), inject_sas_, lock_workstation_);
}
@ -34,6 +35,7 @@ SessionDesktopEnvironment::SessionDesktopEnvironment(
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
const base::Closure& inject_sas,
const base::Closure& lock_workstation,
const DesktopEnvironmentOptions& options)
@ -41,6 +43,7 @@ SessionDesktopEnvironment::SessionDesktopEnvironment(
video_capture_task_runner,
input_task_runner,
ui_task_runner,
system_input_injector_factory,
options),
inject_sas_(inject_sas),
lock_workstation_(lock_workstation) {}
@ -50,12 +53,14 @@ SessionDesktopEnvironmentFactory::SessionDesktopEnvironmentFactory(
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
const base::Closure& inject_sas,
const base::Closure& lock_workstation)
: Me2MeDesktopEnvironmentFactory(caller_task_runner,
video_capture_task_runner,
input_task_runner,
ui_task_runner),
ui_task_runner,
system_input_injector_factory),
inject_sas_(inject_sas),
lock_workstation_(lock_workstation) {
DCHECK(caller_task_runner->BelongsToCurrentThread());
@ -72,8 +77,8 @@ std::unique_ptr<DesktopEnvironment> SessionDesktopEnvironmentFactory::Create(
new SessionDesktopEnvironment(caller_task_runner(),
video_capture_task_runner(),
input_task_runner(), ui_task_runner(),
inject_sas_, lock_workstation_,
options));
system_input_injector_factory(),
inject_sas_, lock_workstation_, options));
if (!desktop_environment->InitializeSecurity(client_session_control)) {
return nullptr;
}

@ -30,6 +30,7 @@ class SessionDesktopEnvironment : public Me2MeDesktopEnvironment {
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
const base::Closure& inject_sas,
const base::Closure& lock_workstation,
const DesktopEnvironmentOptions& options);
@ -51,6 +52,7 @@ class SessionDesktopEnvironmentFactory : public Me2MeDesktopEnvironmentFactory {
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
const base::Closure& inject_sas,
const base::Closure& lock_workstation);
~SessionDesktopEnvironmentFactory() override;

@ -46,7 +46,8 @@ It2MeStandaloneHost::It2MeStandaloneHost()
factory_(main_task_runner_,
context_->video_capture_task_runner(),
context_->input_task_runner(),
context_->ui_task_runner()),
context_->ui_task_runner(),
nullptr),
connection_(base::WrapUnique(new testing::NiceMock<MockSession>())),
session_jid_(kSessionJid),
#if defined(OS_LINUX)

@ -23,6 +23,7 @@
"ui::ozone::mojom::DrmDevice"
],
"test": [
"ui::mojom::RemoteEventDispatcher",
"ui::mojom::WindowServerTest"
],
"discardable_memory": [
@ -59,6 +60,7 @@
"ui::mojom::Gpu",
"ui::mojom::IMEDriver",
"ui::mojom::InputDeviceServer",
"ui::mojom::RemoteEventDispatcher",
"ui::mojom::TouchDeviceServer",
"ui::mojom::UserActivityMonitor",
"ui::mojom::WindowManagerWindowTreeFactory"

@ -13,6 +13,7 @@ mojom("interfaces") {
"event_matcher.mojom",
"gpu.mojom",
"mus_constants.mojom",
"remote_event_dispatcher.mojom",
"user_access_manager.mojom",
"user_activity_monitor.mojom",
"window_manager.mojom",

@ -0,0 +1,19 @@
// Copyright 2017 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.
module ui.mojom;
import "ui/events/mojo/event.mojom";
// An interface offered by the window server which allows clients to submit
// events which are dispatched as if they came from the system. Used for things
// like remoting, where the window manager is receiving input from a remote
// process, along with testing.
interface RemoteEventDispatcher {
// Takes an event and dispatches it as if it came from the native platform.
// Returns false on bad |display_id| or |event|; returns true if it reaches
// the event dispatch phase.
DispatchEvent(int64 display_id, ui.mojom.Event event)
=> (bool result);
};

@ -8,10 +8,4 @@ import "ui/events/mojo/event.mojom";
interface WindowServerTest {
EnsureClientHasDrawnWindow(string client_name) => (bool success);
// Takes an event and dispatches it as if it came from the native platform.
// Returns false on bad |display_id| or |event|; returns true if it reaches
// the event dispatch phase.
DispatchEvent(int64 display_id, ui.mojom.Event event)
=> (bool result);
};

@ -31,6 +31,7 @@
#include "services/ui/ws/display_creation_config.h"
#include "services/ui/ws/display_manager.h"
#include "services/ui/ws/gpu_host.h"
#include "services/ui/ws/remote_event_dispatcher.h"
#include "services/ui/ws/threaded_image_cursors.h"
#include "services/ui/ws/threaded_image_cursors_factory.h"
#include "services/ui/ws/user_activity_monitor.h"
@ -321,6 +322,8 @@ void Service::OnStart() {
registry_.AddInterface<WindowServerTest>(base::Bind(
&Service::BindWindowServerTestRequest, base::Unretained(this)));
}
registry_.AddInterface<mojom::RemoteEventDispatcher>(base::Bind(
&Service::BindRemoteEventDispatcherRequest, base::Unretained(this)));
// On non-Linux platforms there will be no DeviceDataManager instance and no
// purpose in adding the Mojo interface to connect to.
@ -531,5 +534,11 @@ void Service::BindWindowServerTestRequest(
std::move(request));
}
void Service::BindRemoteEventDispatcherRequest(
mojom::RemoteEventDispatcherRequest request) {
mojo::MakeStrongBinding(
base::MakeUnique<ws::RemoteEventDispatcherImpl>(window_server_.get()),
std::move(request));
}
} // namespace ui

@ -27,6 +27,7 @@
#include "services/ui/public/interfaces/display_manager.mojom.h"
#include "services/ui/public/interfaces/gpu.mojom.h"
#include "services/ui/public/interfaces/ime/ime.mojom.h"
#include "services/ui/public/interfaces/remote_event_dispatcher.mojom.h"
#include "services/ui/public/interfaces/user_access_manager.mojom.h"
#include "services/ui/public/interfaces/user_activity_monitor.mojom.h"
#include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom.h"
@ -170,6 +171,9 @@ class Service : public service_manager::Service,
void BindWindowServerTestRequest(mojom::WindowServerTestRequest request);
void BindRemoteEventDispatcherRequest(
mojom::RemoteEventDispatcherRequest request);
std::unique_ptr<ws::WindowServer> window_server_;
std::unique_ptr<PlatformEventSource> event_source_;
using PendingRequests = std::vector<std::unique_ptr<PendingRequest>>;

@ -73,6 +73,8 @@ static_library("lib") {
"platform_display_default.h",
"platform_display_delegate.h",
"platform_display_factory.h",
"remote_event_dispatcher.cc",
"remote_event_dispatcher.h",
"server_window.cc",
"server_window.h",
"server_window_delegate.h",

@ -12,9 +12,9 @@
#include "ui/display/types/native_display_delegate.h"
#include "ui/events/event.h"
#include "ui/events/event_sink.h"
#include "ui/events/system_input_injector.h"
#include "ui/gfx/geometry/point.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/system_input_injector.h"
#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/stub/stub_window.h"

@ -0,0 +1,43 @@
// Copyright 2017 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 "services/ui/ws/remote_event_dispatcher.h"
#include "services/ui/ws/display.h"
#include "services/ui/ws/display_manager.h"
#include "services/ui/ws/window_server.h"
namespace ui {
namespace ws {
RemoteEventDispatcherImpl::RemoteEventDispatcherImpl(WindowServer* server)
: window_server_(server) {}
RemoteEventDispatcherImpl::~RemoteEventDispatcherImpl() {}
void RemoteEventDispatcherImpl::DispatchEvent(int64_t display_id,
std::unique_ptr<ui::Event> event,
const DispatchEventCallback& cb) {
DisplayManager* manager = window_server_->display_manager();
if (!manager) {
DVLOG(1) << "No display manager in DispatchEvent.";
cb.Run(false);
return;
}
Display* display = manager->GetDisplayById(display_id);
if (!display) {
DVLOG(1) << "Invalid display_id in DispatchEvent.";
cb.Run(false);
return;
}
ignore_result(static_cast<PlatformDisplayDelegate*>(display)
->GetEventSink()
->OnEventFromSource(event.get()));
cb.Run(true);
}
} // namespace ws
} // namespace ui

@ -0,0 +1,34 @@
// Copyright 2017 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.
#ifndef SERVICES_UI_WS_REMOTE_EVENT_DISPATCHER_H_
#define SERVICES_UI_WS_REMOTE_EVENT_DISPATCHER_H_
#include "services/ui/public/interfaces/remote_event_dispatcher.mojom.h"
namespace ui {
namespace ws {
class WindowServer;
class RemoteEventDispatcherImpl : public mojom::RemoteEventDispatcher {
public:
explicit RemoteEventDispatcherImpl(WindowServer* server);
~RemoteEventDispatcherImpl() override;
private:
// mojom::RemoteEventDispatcher:
void DispatchEvent(int64_t display_id,
std::unique_ptr<ui::Event> event,
const DispatchEventCallback& cb) override;
WindowServer* window_server_;
DISALLOW_COPY_AND_ASSIGN(RemoteEventDispatcherImpl);
};
} // namespace ws
} // namespace ui
#endif // SERVICES_UI_WS_REMOTE_EVENT_DISPATCHER_H_

@ -5,8 +5,6 @@
#include "services/ui/ws/window_server_test_impl.h"
#include "services/ui/public/interfaces/window_tree.mojom.h"
#include "services/ui/ws/display.h"
#include "services/ui/ws/display_manager.h"
#include "services/ui/ws/server_window.h"
#include "services/ui/ws/window_server.h"
#include "services/ui/ws/window_tree.h"
@ -50,28 +48,5 @@ void WindowServerTestImpl::EnsureClientHasDrawnWindow(
client_name, std::move(callback)));
}
void WindowServerTestImpl::DispatchEvent(int64_t display_id,
std::unique_ptr<ui::Event> event,
const DispatchEventCallback& cb) {
DisplayManager* manager = window_server_->display_manager();
if (!manager) {
DVLOG(1) << "No display manager in DispatchEvent.";
cb.Run(false);
return;
}
Display* display = manager->GetDisplayById(display_id);
if (!display) {
DVLOG(1) << "Invalid display_id in DispatchEvent.";
cb.Run(false);
return;
}
ignore_result(static_cast<PlatformDisplayDelegate*>(display)
->GetEventSink()
->OnEventFromSource(event.get()));
cb.Run(true);
}
} // namespace ws
} // namespace ui

@ -27,9 +27,6 @@ class WindowServerTestImpl : public mojom::WindowServerTest {
void EnsureClientHasDrawnWindow(
const std::string& client_name,
const EnsureClientHasDrawnWindowCallback& callback) override;
void DispatchEvent(int64_t display_id,
std::unique_ptr<ui::Event> event,
const DispatchEventCallback& cb) override;
WindowServer* window_server_;

@ -53,6 +53,7 @@ component("aura") {
"mus/os_exchange_data_provider_mus.h",
"mus/property_converter.h",
"mus/property_utils.h",
"mus/system_input_injector_mus.h",
"mus/text_input_client_impl.h",
"mus/user_activity_forwarder.h",
"mus/window_manager_delegate.h",
@ -114,6 +115,7 @@ component("aura") {
"mus/os_exchange_data_provider_mus.cc",
"mus/property_converter.cc",
"mus/property_utils.cc",
"mus/system_input_injector_mus.cc",
"mus/text_input_client_impl.cc",
"mus/user_activity_forwarder.cc",
"mus/window_manager_delegate.cc",

@ -15,6 +15,7 @@
#include "ui/aura/local/window_port_local.h"
#include "ui/aura/mus/mus_types.h"
#include "ui/aura/mus/os_exchange_data_provider_mus.h"
#include "ui/aura/mus/system_input_injector_mus.h"
#include "ui/aura/mus/window_port_mus.h"
#include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/window.h"
@ -43,6 +44,8 @@ base::LazyInstance<base::ThreadLocalPointer<Env>>::Leaky lazy_tls_ptr =
Env::~Env() {
if (is_os_exchange_data_provider_factory_)
ui::OSExchangeDataProviderFactory::SetFactory(nullptr);
if (is_override_input_injector_factory_)
ui::SetOverrideInputInjectorFactory(nullptr);
#if defined(USE_OZONE)
gfx::ClientNativePixmapFactory::ResetInstance();
@ -163,6 +166,7 @@ Env::Env(Mode mode)
void Env::Init() {
if (mode_ == Mode::MUS) {
EnableMusOSExchangeDataProvider();
EnableMusOverrideInputInjector();
#if defined(USE_OZONE)
// Required by all Aura-using clients of services/ui
gfx::ClientNativePixmapFactory::SetInstance(native_pixmap_factory_.get());
@ -194,6 +198,13 @@ void Env::EnableMusOSExchangeDataProvider() {
}
}
void Env::EnableMusOverrideInputInjector() {
if (!is_override_input_injector_factory_) {
ui::SetOverrideInputInjectorFactory(this);
is_override_input_injector_factory_ = true;
}
}
void Env::NotifyWindowInitialized(Window* window) {
for (EnvObserver& observer : observers_)
observer.OnWindowInitialized(window);
@ -243,4 +254,8 @@ std::unique_ptr<ui::OSExchangeData::Provider> Env::BuildProvider() {
return base::MakeUnique<aura::OSExchangeDataProviderMus>();
}
std::unique_ptr<ui::SystemInputInjector> Env::CreateSystemInputInjector() {
return base::MakeUnique<SystemInputInjectorMus>(window_tree_client_);
}
} // namespace aura

@ -14,6 +14,7 @@
#include "ui/base/dragdrop/os_exchange_data_provider_factory.h"
#include "ui/events/event_handler.h"
#include "ui/events/event_target.h"
#include "ui/events/system_input_injector.h"
#include "ui/gfx/geometry/point.h"
#if defined(USE_OZONE)
@ -46,6 +47,7 @@ class WindowTreeHost;
// A singleton object that tracks general state within Aura.
class AURA_EXPORT Env : public ui::EventTarget,
public ui::OSExchangeDataProviderFactory::Factory,
public ui::SystemInputInjectorFactory,
public base::SupportsUserData {
public:
enum class Mode {
@ -129,6 +131,10 @@ class AURA_EXPORT Env : public ui::EventTarget,
// changed via the EnvTestHelper.
void EnableMusOSExchangeDataProvider();
// After calling this method, all SystemInputInjectors will go through mus
// instead of ozone.
void EnableMusOverrideInputInjector();
// Called by the Window when it is initialized. Notifies observers.
void NotifyWindowInitialized(Window* window);
@ -149,6 +155,9 @@ class AURA_EXPORT Env : public ui::EventTarget,
// Overridden from ui::OSExchangeDataProviderFactory::Factory:
std::unique_ptr<ui::OSExchangeData::Provider> BuildProvider() override;
// Overridden from SystemInputInjectorFactory:
std::unique_ptr<ui::SystemInputInjector> CreateSystemInputInjector() override;
// This is not const for tests, which may share Env across tests and so needs
// to reset the value.
Mode mode_;
@ -171,6 +180,8 @@ class AURA_EXPORT Env : public ui::EventTarget,
bool always_use_last_mouse_location_ = false;
// Whether we set ourselves as the OSExchangeDataProviderFactory.
bool is_os_exchange_data_provider_factory_ = false;
// Whether we set ourselves as the SystemInputInjectorFactory.
bool is_override_input_injector_factory_ = false;
std::unique_ptr<InputStateLookup> input_state_lookup_;
std::unique_ptr<ui::PlatformEventSource> event_source_;

@ -5,7 +5,7 @@
#ifndef UI_AURA_EVENT_INJECTOR_H_
#define UI_AURA_EVENT_INJECTOR_H_
#include "services/ui/public/interfaces/window_server_test.mojom.h"
#include "services/ui/public/interfaces/remote_event_dispatcher.mojom.h"
#include "ui/aura/aura_export.h"
namespace ui {
@ -28,7 +28,7 @@ class AURA_EXPORT EventInjector {
ui::EventDispatchDetails Inject(WindowTreeHost* host, ui::Event* event);
private:
ui::mojom::WindowServerTestPtr window_server_ptr_;
ui::mojom::RemoteEventDispatcherPtr window_server_ptr_;
DISALLOW_COPY_AND_ASSIGN(EventInjector);
};

@ -0,0 +1,98 @@
// Copyright 2017 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 "ui/aura/mus/system_input_injector_mus.h"
#include "ui/aura/mus/window_manager_delegate.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"
namespace aura {
namespace {
int KeyboardCodeToModifier(ui::KeyboardCode key) {
switch (key) {
case ui::VKEY_MENU:
case ui::VKEY_LMENU:
case ui::VKEY_RMENU:
return ui::MODIFIER_ALT;
case ui::VKEY_ALTGR:
return ui::MODIFIER_ALTGR;
case ui::VKEY_CAPITAL:
return ui::MODIFIER_CAPS_LOCK;
case ui::VKEY_CONTROL:
case ui::VKEY_LCONTROL:
case ui::VKEY_RCONTROL:
return ui::MODIFIER_CONTROL;
case ui::VKEY_LWIN:
case ui::VKEY_RWIN:
return ui::MODIFIER_COMMAND;
case ui::VKEY_SHIFT:
case ui::VKEY_LSHIFT:
case ui::VKEY_RSHIFT:
return ui::MODIFIER_SHIFT;
default:
return ui::MODIFIER_NONE;
}
}
} // namespace
SystemInputInjectorMus::SystemInputInjectorMus(WindowManagerClient* client)
: client_(client) {}
SystemInputInjectorMus::~SystemInputInjectorMus() {}
void SystemInputInjectorMus::MoveCursorTo(const gfx::PointF& location) {
// TODO(erg): This appears to never be receiving the events from the remote
// side of the connection. I think this is because it doesn't send mouse
// events before the first paint.
NOTIMPLEMENTED();
}
void SystemInputInjectorMus::InjectMouseButton(ui::EventFlags button,
bool down) {
NOTIMPLEMENTED();
}
void SystemInputInjectorMus::InjectMouseWheel(int delta_x, int delta_y) {
NOTIMPLEMENTED();
}
void SystemInputInjectorMus::InjectKeyEvent(ui::DomCode dom_code,
bool down,
bool suppress_auto_repeat) {
// |suppress_auto_repeat| is always true, and can be ignored.
ui::KeyboardCode key_code = ui::DomCodeToUsLayoutKeyboardCode(dom_code);
int modifier = KeyboardCodeToModifier(key_code);
if (modifier)
UpdateModifier(modifier, down);
ui::KeyEvent e(down ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED, key_code,
dom_code, modifiers_.GetModifierFlags());
// Even when we're dispatching a key event, we need to have a valid display
// for event targeting, so grab the display of where the cursor currently is.
display::Screen* screen = display::Screen::GetScreen();
display::Display display =
screen->GetDisplayNearestPoint(screen->GetCursorScreenPoint());
client_->InjectEvent(e, display.id());
}
void SystemInputInjectorMus::UpdateModifier(unsigned int modifier, bool down) {
if (modifier == ui::MODIFIER_NONE)
return;
if (modifier == ui::MODIFIER_CAPS_LOCK)
modifiers_.UpdateModifier(ui::MODIFIER_MOD3, down);
else
modifiers_.UpdateModifier(modifier, down);
}
} // namespace aura

@ -0,0 +1,42 @@
// Copyright 2017 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.
#ifndef UI_AURA_MUS_SYSTEM_INPUT_INJECTOR_MUS_H_
#define UI_AURA_MUS_SYSTEM_INPUT_INJECTOR_MUS_H_
#include "ui/events/event_modifiers.h"
#include "ui/events/system_input_injector.h"
namespace aura {
class WindowManagerClient;
class SystemInputInjectorMus : public ui::SystemInputInjector {
public:
explicit SystemInputInjectorMus(WindowManagerClient* client);
~SystemInputInjectorMus() override;
// Overridden from SystemInputInjector:
void MoveCursorTo(const gfx::PointF& location) override;
void InjectMouseButton(ui::EventFlags button, bool down) override;
void InjectMouseWheel(int delta_x, int delta_y) override;
void InjectKeyEvent(ui::DomCode physical_key,
bool down,
bool suppress_auto_repeat) override;
private:
// Updates |modifiers_| based on an incoming event.
void UpdateModifier(unsigned int modifier, bool down);
WindowManagerClient* client_;
// Shared modifier state.
ui::EventModifiers modifiers_;
DISALLOW_COPY_AND_ASSIGN(SystemInputInjectorMus);
};
} // namespace aura
#endif // UI_AURA_MUS_SYSTEM_INPUT_INJECTOR_MUS_H_

@ -91,6 +91,9 @@ class AURA_EXPORT WindowManagerClient {
// cleared when the mouse moves.
virtual void SetCursorTouchVisible(bool enabled) = 0;
// Sends |event| to mus to be dispatched.
virtual void InjectEvent(const ui::Event& event, int64_t display_id) = 0;
// Sets the list of keys which don't hide the cursor.
virtual void SetKeyEventsThatDontHideCursor(
std::vector<ui::mojom::EventMatcherPtr> cursor_key_list) = 0;

@ -2035,6 +2035,17 @@ void WindowTreeClient::SetCursorTouchVisible(bool enabled) {
window_manager_client_->WmSetCursorTouchVisible(enabled);
}
void WindowTreeClient::InjectEvent(const ui::Event& event, int64_t display_id) {
if (!event_injector_)
connector()->BindInterface(ui::mojom::kServiceName, &event_injector_);
// Check event_injector_ so we don't crash if access to the interface was
// refused.
if (event_injector_) {
event_injector_->DispatchEvent(display_id, ui::Event::Clone(event),
base::Bind([](bool result) {}));
}
}
void WindowTreeClient::SetKeyEventsThatDontHideCursor(
std::vector<ui::mojom::EventMatcherPtr> cursor_key_list) {
if (window_manager_client_) {

@ -22,6 +22,7 @@
#include "components/viz/common/surfaces/local_surface_id_allocator.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/ui/public/interfaces/remote_event_dispatcher.mojom.h"
#include "services/ui/public/interfaces/window_tree.mojom.h"
#include "ui/aura/aura_export.h"
#include "ui/aura/client/transient_window_client_observer.h"
@ -509,6 +510,7 @@ class AURA_EXPORT WindowTreeClient
void SetCursorSize(ui::CursorSize cursor_size) override;
void SetGlobalOverrideCursor(base::Optional<ui::CursorData> cursor) override;
void SetCursorTouchVisible(bool enabled) override;
void InjectEvent(const ui::Event& event, int64_t display_id) override;
void SetKeyEventsThatDontHideCursor(
std::vector<ui::mojom::EventMatcherPtr> cursor_key_list) override;
void RequestClose(Window* window) override;
@ -637,6 +639,8 @@ class AURA_EXPORT WindowTreeClient
// WindowManagerClient set this, but not |window_manager_internal_client_|.
ui::mojom::WindowManagerClient* window_manager_client_ = nullptr;
ui::mojom::RemoteEventDispatcherPtr event_injector_;
bool has_pointer_watcher_ = false;
// The current change id for the client.

@ -112,6 +112,8 @@ component("events") {
"event_dispatcher.h",
"event_handler.cc",
"event_handler.h",
"event_modifiers.cc",
"event_modifiers.h",
"event_processor.cc",
"event_processor.h",
"event_rewriter.h",
@ -134,6 +136,8 @@ component("events") {
"null_event_targeter.h",
"scoped_target_handler.cc",
"scoped_target_handler.h",
"system_input_injector.cc",
"system_input_injector.h",
"win/events_win.cc",
"win/system_event_state_lookup.cc",
"win/system_event_state_lookup.h",

@ -0,0 +1,100 @@
// Copyright 2014 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 "ui/events/event_modifiers.h"
#include "ui/events/event.h"
namespace ui {
namespace {
static const int kEventFlagFromModifiers[] = {
EF_NONE, // MODIFIER_NONE,
EF_SHIFT_DOWN, // MODIFIER_SHIFT
EF_CONTROL_DOWN, // MODIFIER_CONTROL
EF_ALT_DOWN, // MODIFIER_ALT
EF_COMMAND_DOWN, // MODIFIER_COMMAND
EF_ALTGR_DOWN, // MODIFIER_ALTGR
EF_MOD3_DOWN, // MODIFIER_MOD3
EF_CAPS_LOCK_ON, // MODIFIER_CAPS_LOCK
EF_LEFT_MOUSE_BUTTON, // MODIFIER_LEFT_MOUSE_BUTTON
EF_MIDDLE_MOUSE_BUTTON, // MODIFIER_MIDDLE_MOUSE_BUTTON
EF_RIGHT_MOUSE_BUTTON, // MODIFIER_RIGHT_MOUSE_BUTTON
EF_BACK_MOUSE_BUTTON, // MODIFIER_BACK_MOUSE_BUTTON
EF_FORWARD_MOUSE_BUTTON, // MODIFIER_FORWARD_MOUSE_BUTTON
};
} // namespace
EventModifiers::EventModifiers() {
memset(modifiers_down_, 0, sizeof(modifiers_down_));
}
EventModifiers::~EventModifiers() {}
void EventModifiers::UpdateModifier(unsigned int modifier, bool down) {
DCHECK_LT(modifier, static_cast<unsigned int>(MODIFIER_NUM_MODIFIERS));
if (down) {
modifiers_down_[modifier]++;
} else {
// Ignore spurious modifier "up" events. This might happen if the
// button is down during startup.
if (modifiers_down_[modifier])
modifiers_down_[modifier]--;
}
UpdateFlags(modifier);
}
void EventModifiers::UpdateModifierLock(unsigned int modifier, bool down) {
DCHECK_LT(modifier, static_cast<unsigned int>(MODIFIER_NUM_MODIFIERS));
if (down)
modifier_flags_locked_ ^= kEventFlagFromModifiers[modifier];
UpdateFlags(modifier);
}
void EventModifiers::SetModifierLock(unsigned int modifier, bool locked) {
DCHECK_LT(modifier, static_cast<unsigned int>(MODIFIER_NUM_MODIFIERS));
if (locked)
modifier_flags_locked_ |= kEventFlagFromModifiers[modifier];
else
modifier_flags_locked_ &= ~kEventFlagFromModifiers[modifier];
UpdateFlags(modifier);
}
void EventModifiers::UpdateFlags(unsigned int modifier) {
int mask = kEventFlagFromModifiers[modifier];
bool down = modifiers_down_[modifier] != 0;
bool locked = (modifier_flags_locked_ & mask) != 0;
if (down != locked)
modifier_flags_ |= mask;
else
modifier_flags_ &= ~mask;
}
int EventModifiers::GetModifierFlags() {
return modifier_flags_;
}
void EventModifiers::ResetKeyboardModifiers() {
static const int kKeyboardModifiers[] = {MODIFIER_SHIFT, MODIFIER_CONTROL,
MODIFIER_ALT, MODIFIER_COMMAND,
MODIFIER_ALTGR, MODIFIER_MOD3};
for (const int modifier : kKeyboardModifiers) {
modifiers_down_[modifier] = 0;
UpdateFlags(modifier);
}
}
// static
int EventModifiers::GetEventFlagFromModifier(unsigned int modifier) {
return kEventFlagFromModifiers[modifier];
}
} // namespace ui

@ -2,29 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_EVENTS_OZONE_EVDEV_EVENT_MODIFIERS_EVDEV_H_
#define UI_EVENTS_OZONE_EVDEV_EVENT_MODIFIERS_EVDEV_H_
#ifndef UI_EVENTS_EVENT_MODIFIERS_H_
#define UI_EVENTS_EVENT_MODIFIERS_H_
#include "base/macros.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
#include "ui/events/events_export.h"
namespace ui {
enum {
EVDEV_MODIFIER_NONE,
EVDEV_MODIFIER_SHIFT,
EVDEV_MODIFIER_CONTROL,
EVDEV_MODIFIER_ALT,
EVDEV_MODIFIER_COMMAND,
EVDEV_MODIFIER_ALTGR,
EVDEV_MODIFIER_MOD3,
EVDEV_MODIFIER_CAPS_LOCK,
EVDEV_MODIFIER_LEFT_MOUSE_BUTTON,
EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON,
EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON,
EVDEV_MODIFIER_BACK_MOUSE_BUTTON,
EVDEV_MODIFIER_FORWARD_MOUSE_BUTTON,
EVDEV_NUM_MODIFIERS
MODIFIER_NONE,
MODIFIER_SHIFT,
MODIFIER_CONTROL,
MODIFIER_ALT,
MODIFIER_COMMAND,
MODIFIER_ALTGR,
MODIFIER_MOD3,
MODIFIER_CAPS_LOCK,
MODIFIER_LEFT_MOUSE_BUTTON,
MODIFIER_MIDDLE_MOUSE_BUTTON,
MODIFIER_RIGHT_MOUSE_BUTTON,
MODIFIER_BACK_MOUSE_BUTTON,
MODIFIER_FORWARD_MOUSE_BUTTON,
MODIFIER_NUM_MODIFIERS
};
// Modifier key state for Evdev.
@ -42,10 +42,10 @@ enum {
// currently pressed. However some keys toggle a persistent "lock" for the
// modifier instead, such as CapsLock. If a modifier is "locked" then its state
// is inverted until it is unlocked.
class EVENTS_OZONE_EVDEV_EXPORT EventModifiersEvdev {
class EVENTS_EXPORT EventModifiers {
public:
EventModifiersEvdev();
~EventModifiersEvdev();
EventModifiers();
~EventModifiers();
// Record key press or release for regular modifier key (shift, alt, etc).
void UpdateModifier(unsigned int modifier, bool down);
@ -67,7 +67,7 @@ class EVENTS_OZONE_EVDEV_EXPORT EventModifiersEvdev {
private:
// Count of keys pressed for each modifier.
int modifiers_down_[EVDEV_NUM_MODIFIERS];
int modifiers_down_[MODIFIER_NUM_MODIFIERS];
// Mask of modifier flags currently "locked".
int modifier_flags_locked_ = 0;
@ -78,9 +78,9 @@ class EVENTS_OZONE_EVDEV_EXPORT EventModifiersEvdev {
// Update modifier_flags_ from modifiers_down_ and modifier_flags_locked_.
void UpdateFlags(unsigned int modifier);
DISALLOW_COPY_AND_ASSIGN(EventModifiersEvdev);
DISALLOW_COPY_AND_ASSIGN(EventModifiers);
};
} // namspace ui
} // namespace ui
#endif // UI_EVENTS_OZONE_EVDEV_EVENT_MODIFIERS_EVDEV_H_
#endif // UI_EVENTS_EVENT_MODIFIERS_H_

@ -78,8 +78,6 @@ if (use_ozone) {
"evdev/event_device_info.h",
"evdev/event_factory_evdev.cc",
"evdev/event_factory_evdev.h",
"evdev/event_modifiers_evdev.cc",
"evdev/event_modifiers_evdev.h",
"evdev/event_thread_evdev.cc",
"evdev/event_thread_evdev.h",
"evdev/events_ozone_evdev_export.h",

@ -12,10 +12,10 @@
#include "base/message_loop/message_pump_libevent.h"
#include "ui/events/devices/input_device.h"
#include "ui/events/event.h"
#include "ui/events/event_modifiers.h"
#include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
#include "ui/events/ozone/evdev/event_converter_evdev.h"
#include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/event_modifiers_evdev.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
#include "ui/events/ozone/evdev/keyboard_evdev.h"
#include "ui/events/ozone/evdev/mouse_button_map_evdev.h"

@ -247,22 +247,22 @@ void EventFactoryEvdev::DispatchMouseButtonEvent(
if (params.allow_remap)
button = button_map_.GetMappedButton(button);
int modifier = EVDEV_MODIFIER_NONE;
int modifier = MODIFIER_NONE;
switch (button) {
case BTN_LEFT:
modifier = EVDEV_MODIFIER_LEFT_MOUSE_BUTTON;
modifier = MODIFIER_LEFT_MOUSE_BUTTON;
break;
case BTN_RIGHT:
modifier = EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON;
modifier = MODIFIER_RIGHT_MOUSE_BUTTON;
break;
case BTN_MIDDLE:
modifier = EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON;
modifier = MODIFIER_MIDDLE_MOUSE_BUTTON;
break;
case BTN_BACK:
modifier = EVDEV_MODIFIER_BACK_MOUSE_BUTTON;
modifier = MODIFIER_BACK_MOUSE_BUTTON;
break;
case BTN_FORWARD:
modifier = EVDEV_MODIFIER_FORWARD_MOUSE_BUTTON;
modifier = MODIFIER_FORWARD_MOUSE_BUTTON;
break;
default:
return;
@ -273,7 +273,7 @@ void EventFactoryEvdev::DispatchMouseButtonEvent(
modifiers_.UpdateModifier(modifier, params.down);
bool down = modifiers_.GetModifierFlags() & flag;
// Suppress nested clicks. EventModifiersEvdev counts presses, we only
// Suppress nested clicks. EventModifiers counts presses, we only
// dispatch an event on 0-1 (first press) and 1-0 (last release) transitions.
if (down == was_down)
return;

@ -11,9 +11,9 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/task_runner.h"
#include "ui/events/event_modifiers.h"
#include "ui/events/ozone/device/device_event_observer.h"
#include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
#include "ui/events/ozone/evdev/event_modifiers_evdev.h"
#include "ui/events/ozone/evdev/event_thread_evdev.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
#include "ui/events/ozone/evdev/input_controller_evdev.h"
@ -21,9 +21,9 @@
#include "ui/events/ozone/evdev/mouse_button_map_evdev.h"
#include "ui/events/ozone/gamepad/gamepad_event.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/events/system_input_injector.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/sequential_id_generator.h"
#include "ui/ozone/public/system_input_injector.h"
namespace gfx {
class PointF;
@ -123,7 +123,7 @@ class EVENTS_OZONE_EVDEV_EXPORT EventFactoryEvdev : public DeviceEventObserver,
std::unique_ptr<InputDeviceFactoryEvdevProxy> input_device_factory_proxy_;
// Modifier key state (shift, ctrl, etc).
EventModifiersEvdev modifiers_;
EventModifiers modifiers_;
// Mouse button map.
MouseButtonMapEvdev button_map_;

@ -1,105 +0,0 @@
// Copyright 2014 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 "ui/events/ozone/evdev/event_modifiers_evdev.h"
#include <linux/input.h>
#include "ui/events/event.h"
namespace ui {
namespace {
static const int kEventFlagFromModifiers[] = {
EF_NONE, // EVDEV_MODIFIER_NONE,
EF_SHIFT_DOWN, // EVDEV_MODIFIER_SHIFT
EF_CONTROL_DOWN, // EVDEV_MODIFIER_CONTROL
EF_ALT_DOWN, // EVDEV_MODIFIER_ALT
EF_COMMAND_DOWN, // EVDEV_MODIFIER_COMMAND
EF_ALTGR_DOWN, // EVDEV_MODIFIER_ALTGR
EF_MOD3_DOWN, // EVDEV_MODIFIER_MOD3
EF_CAPS_LOCK_ON, // EVDEV_MODIFIER_CAPS_LOCK
EF_LEFT_MOUSE_BUTTON, // EVDEV_MODIFIER_LEFT_MOUSE_BUTTON
EF_MIDDLE_MOUSE_BUTTON, // EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON
EF_RIGHT_MOUSE_BUTTON, // EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON
EF_BACK_MOUSE_BUTTON, // EVDEV_MODIFIER_BACK_MOUSE_BUTTON
EF_FORWARD_MOUSE_BUTTON, // EVDEV_MODIFIER_FORWARD_MOUSE_BUTTON
};
} // namespace
EventModifiersEvdev::EventModifiersEvdev() {
memset(modifiers_down_, 0, sizeof(modifiers_down_));
}
EventModifiersEvdev::~EventModifiersEvdev() {}
void EventModifiersEvdev::UpdateModifier(unsigned int modifier, bool down) {
DCHECK_LT(modifier, EVDEV_NUM_MODIFIERS);
if (down) {
modifiers_down_[modifier]++;
} else {
// Ignore spurious modifier "up" events. This might happen if the
// button is down during startup.
if (modifiers_down_[modifier])
modifiers_down_[modifier]--;
}
UpdateFlags(modifier);
}
void EventModifiersEvdev::UpdateModifierLock(unsigned int modifier, bool down) {
DCHECK_LT(modifier, EVDEV_NUM_MODIFIERS);
if (down)
modifier_flags_locked_ ^= kEventFlagFromModifiers[modifier];
UpdateFlags(modifier);
}
void EventModifiersEvdev::SetModifierLock(unsigned int modifier, bool locked) {
DCHECK_LT(modifier, EVDEV_NUM_MODIFIERS);
if (locked)
modifier_flags_locked_ |= kEventFlagFromModifiers[modifier];
else
modifier_flags_locked_ &= ~kEventFlagFromModifiers[modifier];
UpdateFlags(modifier);
}
void EventModifiersEvdev::UpdateFlags(unsigned int modifier) {
int mask = kEventFlagFromModifiers[modifier];
bool down = modifiers_down_[modifier];
bool locked = (modifier_flags_locked_ & mask);
if (down != locked)
modifier_flags_ |= mask;
else
modifier_flags_ &= ~mask;
}
int EventModifiersEvdev::GetModifierFlags() { return modifier_flags_; }
void EventModifiersEvdev::ResetKeyboardModifiers() {
static const int kKeyboardModifiers[] = {
EVDEV_MODIFIER_SHIFT,
EVDEV_MODIFIER_CONTROL,
EVDEV_MODIFIER_ALT,
EVDEV_MODIFIER_COMMAND,
EVDEV_MODIFIER_ALTGR,
EVDEV_MODIFIER_MOD3
};
for (const int modifier : kKeyboardModifiers) {
modifiers_down_[modifier] = 0;
UpdateFlags(modifier);
}
}
// static
int EventModifiersEvdev::GetEventFlagFromModifier(unsigned int modifier) {
return kEventFlagFromModifiers[modifier];
}
} // namespace ui

@ -7,11 +7,11 @@
#include <utility>
#include "ui/events/event.h"
#include "ui/events/event_modifiers.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
#include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
#include "ui/events/ozone/evdev/event_modifiers_evdev.h"
#include "ui/events/ozone/evdev/keyboard_evdev.h"
#include "ui/events/ozone/evdev/keyboard_util_evdev.h"

@ -8,7 +8,7 @@
#include "base/macros.h"
#include "ui/events/ozone/evdev/event_dispatch_callback.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
#include "ui/ozone/public/system_input_injector.h"
#include "ui/events/system_input_injector.h"
namespace ui {

@ -8,10 +8,10 @@
#include "base/threading/thread_task_runner_handle.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_modifiers.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/ozone/evdev/event_modifiers_evdev.h"
#include "ui/events/ozone/evdev/keyboard_util_evdev.h"
#include "ui/events/ozone/layout/keyboard_layout_engine.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
@ -27,37 +27,37 @@ const int kRepeatIntervalMs = 50;
int EventFlagToEvdevModifier(int flag) {
switch (flag) {
case EF_SHIFT_DOWN:
return EVDEV_MODIFIER_SHIFT;
return MODIFIER_SHIFT;
case EF_CONTROL_DOWN:
return EVDEV_MODIFIER_CONTROL;
return MODIFIER_CONTROL;
case EF_ALT_DOWN:
return EVDEV_MODIFIER_ALT;
return MODIFIER_ALT;
case EF_COMMAND_DOWN:
return EVDEV_MODIFIER_COMMAND;
return MODIFIER_COMMAND;
case EF_ALTGR_DOWN:
return EVDEV_MODIFIER_ALTGR;
return MODIFIER_ALTGR;
case EF_MOD3_DOWN:
return EVDEV_MODIFIER_MOD3;
return MODIFIER_MOD3;
case EF_CAPS_LOCK_ON:
return EVDEV_MODIFIER_CAPS_LOCK;
return MODIFIER_CAPS_LOCK;
case EF_LEFT_MOUSE_BUTTON:
return EVDEV_MODIFIER_LEFT_MOUSE_BUTTON;
return MODIFIER_LEFT_MOUSE_BUTTON;
case EF_MIDDLE_MOUSE_BUTTON:
return EVDEV_MODIFIER_MIDDLE_MOUSE_BUTTON;
return MODIFIER_MIDDLE_MOUSE_BUTTON;
case EF_RIGHT_MOUSE_BUTTON:
return EVDEV_MODIFIER_RIGHT_MOUSE_BUTTON;
return MODIFIER_RIGHT_MOUSE_BUTTON;
case EF_BACK_MOUSE_BUTTON:
return EVDEV_MODIFIER_BACK_MOUSE_BUTTON;
return MODIFIER_BACK_MOUSE_BUTTON;
case EF_FORWARD_MOUSE_BUTTON:
return EVDEV_MODIFIER_FORWARD_MOUSE_BUTTON;
return MODIFIER_FORWARD_MOUSE_BUTTON;
default:
return EVDEV_MODIFIER_NONE;
return MODIFIER_NONE;
}
}
} // namespace
KeyboardEvdev::KeyboardEvdev(EventModifiersEvdev* modifiers,
KeyboardEvdev::KeyboardEvdev(EventModifiers* modifiers,
KeyboardLayoutEngine* keyboard_layout_engine,
const EventDispatchCallback& callback)
: callback_(callback),
@ -90,7 +90,7 @@ void KeyboardEvdev::OnKeyChange(unsigned int key,
}
void KeyboardEvdev::SetCapsLockEnabled(bool enabled) {
modifiers_->SetModifierLock(EVDEV_MODIFIER_CAPS_LOCK, enabled);
modifiers_->SetModifierLock(MODIFIER_CAPS_LOCK, enabled);
}
bool KeyboardEvdev::IsCapsLockEnabled() {
@ -128,7 +128,7 @@ void KeyboardEvdev::UpdateModifier(int modifier_flag, bool down) {
return;
int modifier = EventFlagToEvdevModifier(modifier_flag);
if (modifier == EVDEV_MODIFIER_NONE)
if (modifier == MODIFIER_NONE)
return;
// TODO post-X11: Revise remapping to not use EF_MOD3_DOWN.
@ -138,8 +138,8 @@ void KeyboardEvdev::UpdateModifier(int modifier_flag, bool down) {
// to be two different flags, since the physical CapsLock key is subject
// to remapping, but the caps lock state (which can be triggered in a
// variety of ways) is not.
if (modifier == EVDEV_MODIFIER_CAPS_LOCK)
modifiers_->UpdateModifier(EVDEV_MODIFIER_MOD3, down);
if (modifier == MODIFIER_CAPS_LOCK)
modifiers_->UpdateModifier(MODIFIER_MOD3, down);
else
modifiers_->UpdateModifier(modifier, down);
}

@ -19,7 +19,7 @@
namespace ui {
class EventModifiersEvdev;
class EventModifiers;
enum class DomCode;
// Keyboard for evdev.
@ -30,7 +30,7 @@ enum class DomCode;
// It also currently also applies the layout.
class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev {
public:
KeyboardEvdev(EventModifiersEvdev* modifiers,
KeyboardEvdev(EventModifiers* modifiers,
KeyboardLayoutEngine* keyboard_layout_engine,
const EventDispatchCallback& callback);
~KeyboardEvdev();
@ -93,7 +93,7 @@ class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev {
EventDispatchCallback callback_;
// Shared modifier state.
EventModifiersEvdev* modifiers_;
EventModifiers* modifiers_;
// Shared layout engine.
KeyboardLayoutEngine* keyboard_layout_engine_;

@ -9,10 +9,10 @@
#include "base/macros.h"
#include "base/message_loop/message_pump_libevent.h"
#include "ui/events/event.h"
#include "ui/events/event_modifiers.h"
#include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
#include "ui/events/ozone/evdev/event_converter_evdev.h"
#include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/event_modifiers_evdev.h"
#include "ui/events/ozone/evdev/events_ozone_evdev_export.h"
#include "ui/events/ozone/evdev/scoped_input_device.h"

@ -0,0 +1,34 @@
// Copyright 2017 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 "ui/events/system_input_injector.h"
#include "base/memory/ptr_util.h"
namespace ui {
namespace {
SystemInputInjectorFactory* override_factory_ = nullptr;
SystemInputInjectorFactory* native_factory_ = nullptr;
} // namespace
void SetOverrideInputInjectorFactory(SystemInputInjectorFactory* factory) {
DCHECK(!factory || !override_factory_);
override_factory_ = factory;
}
void SetNativeInputInjectorFactory(SystemInputInjectorFactory* factory) {
DCHECK(!factory || !native_factory_);
native_factory_ = factory;
}
SystemInputInjectorFactory* GetSystemInputInjectorFactory() {
if (override_factory_)
return override_factory_;
if (native_factory_)
return native_factory_;
return nullptr;
}
} // namespace ui

@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_OZONE_PUBLIC_SYSTEM_INPUT_INJECTOR_H_
#define UI_OZONE_PUBLIC_SYSTEM_INPUT_INJECTOR_H_
#ifndef UI_EVENTS_SYSTEM_INPUT_INJECTOR_H_
#define UI_EVENTS_SYSTEM_INPUT_INJECTOR_H_
#include <memory>
#include "base/macros.h"
#include "ui/events/event.h"
#include "ui/events/events_export.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/ozone/ozone_base_export.h"
namespace gfx {
class PointF;
@ -19,9 +19,9 @@ class PointF;
namespace ui {
// Interface for converting input into ui::Events and injecting them to the
// Ozone platform.
class OZONE_BASE_EXPORT SystemInputInjector {
// Interface exposed for remoting to convert its events from the network to
// native events.
class EVENTS_EXPORT SystemInputInjector {
public:
SystemInputInjector() {}
virtual ~SystemInputInjector() {}
@ -52,6 +52,34 @@ class OZONE_BASE_EXPORT SystemInputInjector {
DISALLOW_COPY_AND_ASSIGN(SystemInputInjector);
};
class EVENTS_EXPORT SystemInputInjectorFactory {
public:
virtual std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() = 0;
protected:
~SystemInputInjectorFactory() {}
};
// Sets a global SystemInputInjectorFactory which is used in remoting instead
// of requesting the usual Ozone version, as specified in
// SetNativeInputInjectorFactory().
//
// This is placed in //ui/events not just since it's event related, but also
// because its one of the few places that both //remoting/ and //ui/ozone can
// depend on.
EVENTS_EXPORT void SetOverrideInputInjectorFactory(
SystemInputInjectorFactory* factory);
// Sets a global SystemInputInjectorFactory which is used if there isn't an
// override injector factory. Currently, this is always the ozone
// implementation.
EVENTS_EXPORT void SetNativeInputInjectorFactory(
SystemInputInjectorFactory* factory);
// Returns the override input injector factory, the native one, or null if
// neither are set.
EVENTS_EXPORT SystemInputInjectorFactory* GetSystemInputInjectorFactory();
} // namespace ui
#endif // UI_OZONE_PUBLIC_SYSTEM_INPUT_INJECTOR_H_
#endif // UI_EVENTS_SYSTEM_INPUT_INJECTOR_H_

@ -73,7 +73,6 @@ component("ozone_base") {
"public/surface_factory_ozone.h",
"public/surface_ozone_canvas.h",
"public/swap_completion_callback.h",
"public/system_input_injector.h",
]
defines = [ "OZONE_BASE_IMPLEMENTATION" ]

@ -19,6 +19,7 @@
#include "ui/events/ozone/evdev/event_factory_evdev.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
#include "ui/events/system_input_injector.h"
#include "ui/ozone/platform/cast/overlay_manager_cast.h"
#include "ui/ozone/platform/cast/platform_window_cast.h"
#include "ui/ozone/platform/cast/surface_factory_cast.h"
@ -26,7 +27,6 @@
#include "ui/ozone/public/gpu_platform_support_host.h"
#include "ui/ozone/public/input_controller.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/system_input_injector.h"
using chromecast::CastEglPlatform;

@ -13,6 +13,7 @@
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/events/system_input_injector.h"
#include "ui/ozone/common/stub_overlay_manager.h"
#include "ui/ozone/platform/headless/headless_surface_factory.h"
#include "ui/ozone/platform/headless/headless_window.h"
@ -22,7 +23,6 @@
#include "ui/ozone/public/input_controller.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/ozone_switches.h"
#include "ui/ozone/public/system_input_injector.h"
namespace ui {

@ -8,6 +8,7 @@
#include "ui/base/ui_features.h"
#include "ui/display/manager/fake_display_delegate.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/events/system_input_injector.h"
#include "ui/ozone/common/stub_overlay_manager.h"
#include "ui/ozone/platform/wayland/wayland_connection.h"
#include "ui/ozone/platform/wayland/wayland_surface_factory.h"
@ -16,7 +17,6 @@
#include "ui/ozone/public/gpu_platform_support_host.h"
#include "ui/ozone/public/input_controller.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/system_input_injector.h"
#if BUILDFLAG(USE_XKBCOMMON)
#include "ui/events/ozone/layout/xkb/xkb_evdev_codes.h"

@ -16,13 +16,13 @@
#include "ui/display/manager/fake_display_delegate.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
#include "ui/events/platform/x11/x11_event_source_libevent.h"
#include "ui/events/system_input_injector.h"
#include "ui/ozone/common/stub_overlay_manager.h"
#include "ui/ozone/platform/x11/x11_cursor_factory_ozone.h"
#include "ui/ozone/platform/x11/x11_surface_factory.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
#include "ui/ozone/public/input_controller.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/system_input_injector.h"
#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/x11/x11_window_manager_ozone.h"
#include "ui/platform_window/x11/x11_window_ozone.h"

@ -24,11 +24,13 @@ OzonePlatform::OzonePlatform() {
instance_ = this;
g_platform_initialized_ui = false;
g_platform_initialized_gpu = false;
SetNativeInputInjectorFactory(this);
}
OzonePlatform::~OzonePlatform() {
DCHECK_EQ(instance_, this);
instance_ = NULL;
SetNativeInputInjectorFactory(nullptr);
}
// static

@ -11,6 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "services/service_manager/public/cpp/bind_source_info.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "ui/events/system_input_injector.h"
#include "ui/ozone/ozone_export.h"
namespace display {
@ -54,7 +55,7 @@ class SystemInputInjector;
// interface depending on the context. You can, for example, create
// different objects depending on the underlying hardware, command
// line flags, or whatever is appropriate for the platform.
class OZONE_EXPORT OzonePlatform {
class OZONE_EXPORT OzonePlatform : public SystemInputInjectorFactory {
public:
OzonePlatform();
virtual ~OzonePlatform();
@ -109,13 +110,15 @@ class OZONE_EXPORT OzonePlatform {
virtual ui::InputController* GetInputController() = 0;
virtual IPC::MessageFilter* GetGpuMessageFilter();
virtual ui::GpuPlatformSupportHost* GetGpuPlatformSupportHost() = 0;
virtual std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() = 0;
virtual std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
const gfx::Rect& bounds) = 0;
virtual std::unique_ptr<display::NativeDisplayDelegate>
CreateNativeDisplayDelegate() = 0;
// Factory getters which come through from SystemInputInjector:
std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override = 0;
// Returns the message loop type required for OzonePlatform instance that
// will be initialized for the GPU process.
virtual base::MessageLoop::Type GetMessageLoopTypeForGpu();

@ -124,9 +124,9 @@ void DragTest_Part2(int64_t display_id,
if (!result)
quit_closure.Run();
ui::mojom::WindowServerTest* server_test =
MusClient::Get()->GetTestingInterface();
server_test->DispatchEvent(
ui::mojom::RemoteEventDispatcher* dispatcher =
MusClient::Get()->GetTestingEventDispater();
dispatcher->DispatchEvent(
display_id, CreateMouseUpEvent(30, 30),
base::Bind(&DragTest_Part3, display_id, quit_closure));
}
@ -138,9 +138,9 @@ void DragTest_Part1(int64_t display_id,
if (!result)
quit_closure.Run();
ui::mojom::WindowServerTest* server_test =
MusClient::Get()->GetTestingInterface();
server_test->DispatchEvent(
ui::mojom::RemoteEventDispatcher* dispatcher =
MusClient::Get()->GetTestingEventDispater();
dispatcher->DispatchEvent(
display_id, CreateMouseMoveEvent(30, 30),
base::Bind(&DragTest_Part2, display_id, quit_closure));
}
@ -175,9 +175,9 @@ TEST_F(DragTestInteractive, DragTest) {
{
base::RunLoop run_loop;
ui::mojom::WindowServerTest* server_test =
MusClient::Get()->GetTestingInterface();
server_test->DispatchEvent(
ui::mojom::RemoteEventDispatcher* dispatcher =
MusClient::Get()->GetTestingEventDispater();
dispatcher->DispatchEvent(
display_id, CreateMouseDownEvent(10, 10),
base::Bind(&DragTest_Part1, display_id, run_loop.QuitClosure()));

@ -102,8 +102,11 @@ MusClient::MusClient(service_manager::Connector* connector,
if (create_wm_state)
wm_state_ = base::MakeUnique<wm::WMState>();
if (testing_state == MusClientTestingState::CREATE_TESTING_STATE)
if (testing_state == MusClientTestingState::CREATE_TESTING_STATE) {
connector->BindInterface(ui::mojom::kServiceName, &server_test_ptr_);
connector->BindInterface(ui::mojom::kServiceName,
&remote_event_dispatcher_ptr_);
}
window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>(
connector, this, nullptr /* window_manager_delegate */,
@ -274,6 +277,11 @@ ui::mojom::WindowServerTest* MusClient::GetTestingInterface() const {
return server_test_ptr_.get();
}
ui::mojom::RemoteEventDispatcher* MusClient::GetTestingEventDispater() const {
CHECK(remote_event_dispatcher_ptr_);
return remote_event_dispatcher_ptr_.get();
}
std::unique_ptr<DesktopWindowTreeHost> MusClient::CreateDesktopWindowTreeHost(
const Widget::InitParams& init_params,
internal::NativeWidgetDelegate* delegate,

@ -13,6 +13,7 @@
#include "base/macros.h"
#include "services/service_manager/public/cpp/identity.h"
#include "services/ui/public/interfaces/remote_event_dispatcher.mojom.h"
#include "services/ui/public/interfaces/window_server_test.mojom.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/mus/window_tree_client_delegate.h"
@ -119,10 +120,14 @@ class VIEWS_MUS_EXPORT MusClient : public aura::WindowTreeClientDelegate,
return mus_property_mirror_.get();
}
// Returns an interface to directly control mus. Only available when created
// Returns an interface to test drawing in mus. Only available when created
// with MusClientTestingState::CREATE_TESTING_STATE.
ui::mojom::WindowServerTest* GetTestingInterface() const;
// Returns an interface to dispatch events in the mus server. Only available
// when created with MusClientTestingState::CREATE_TESTING_STATE.
ui::mojom::RemoteEventDispatcher* GetTestingEventDispater() const;
private:
friend class AuraInit;
friend class test::MusClientTestApi;
@ -174,6 +179,7 @@ class VIEWS_MUS_EXPORT MusClient : public aura::WindowTreeClientDelegate,
std::unique_ptr<PointerWatcherEventRouter> pointer_watcher_event_router_;
ui::mojom::WindowServerTestPtr server_test_ptr_;
ui::mojom::RemoteEventDispatcherPtr remote_event_dispatcher_ptr_;
DISALLOW_COPY_AND_ASSIGN(MusClient);
};