Commit 4dfb389c authored by Joe Downing's avatar Joe Downing Committed by Commit Bot

[Input monitor] Create a lib for input monitor related classes.

This is a clean-up CL which moves all of the LocalInputMonitor
related classes into their own folder and provides a public header
and lib for usage by the rest of the host classes.

Change-Id: I0a9ced94750d0724f99dace24c991fd3194eebb4
Reviewed-on: https://chromium-review.googlesource.com/1185298
Commit-Queue: Joe Downing <joedow@chromium.org>
Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585928}
parent 797dc685
...@@ -207,18 +207,6 @@ static_library("host") { ...@@ -207,18 +207,6 @@ static_library("host") {
"ipc_video_frame_capturer.h", "ipc_video_frame_capturer.h",
"it2me_desktop_environment.cc", "it2me_desktop_environment.cc",
"it2me_desktop_environment.h", "it2me_desktop_environment.h",
"local_hotkey_input_monitor.h",
"local_hotkey_input_monitor_chromeos.cc",
"local_hotkey_input_monitor_mac.mm",
"local_hotkey_input_monitor_win.cc",
"local_hotkey_input_monitor_x11.cc",
"local_input_monitor.cc",
"local_input_monitor.h",
"local_mouse_input_monitor.h",
"local_mouse_input_monitor_chromeos.cc",
"local_mouse_input_monitor_mac.mm",
"local_mouse_input_monitor_win.cc",
"local_mouse_input_monitor_x11.cc",
"logging.h", "logging.h",
"logging_linux.cc", "logging_linux.cc",
"logging_mac.cc", "logging_mac.cc",
...@@ -308,6 +296,7 @@ static_library("host") { ...@@ -308,6 +296,7 @@ static_library("host") {
"//media", "//media",
"//remoting/base", "//remoting/base",
"//remoting/base:authorization", "//remoting/base:authorization",
"//remoting/host/input_monitor",
"//remoting/host/security_key", "//remoting/host/security_key",
"//remoting/protocol", "//remoting/protocol",
"//remoting/resources", "//remoting/resources",
...@@ -355,8 +344,6 @@ static_library("host") { ...@@ -355,8 +344,6 @@ static_library("host") {
"clipboard_x11.cc", "clipboard_x11.cc",
"desktop_resizer_x11.cc", "desktop_resizer_x11.cc",
"input_injector_x11.cc", "input_injector_x11.cc",
"local_hotkey_input_monitor_x11.cc",
"local_mouse_input_monitor_x11.cc",
] ]
} }
...@@ -390,8 +377,6 @@ static_library("host") { ...@@ -390,8 +377,6 @@ static_library("host") {
"desktop_resizer_x11.cc", "desktop_resizer_x11.cc",
"input_injector_chromeos.cc", "input_injector_chromeos.cc",
"input_injector_chromeos.h", "input_injector_chromeos.h",
"local_hotkey_input_monitor_x11.cc",
"local_mouse_input_monitor_x11.cc",
] ]
} }
} }
...@@ -480,11 +465,11 @@ source_set("unit_tests") { ...@@ -480,11 +465,11 @@ source_set("unit_tests") {
"host_extension_session_manager_unittest.cc", "host_extension_session_manager_unittest.cc",
"host_power_save_blocker_unittest.cc", "host_power_save_blocker_unittest.cc",
"host_status_logger_unittest.cc", "host_status_logger_unittest.cc",
"input_monitor/local_input_monitor_unittest.cc",
"ipc_desktop_environment_unittest.cc", "ipc_desktop_environment_unittest.cc",
"it2me/it2me_confirmation_dialog_proxy_unittest.cc", "it2me/it2me_confirmation_dialog_proxy_unittest.cc",
"it2me/it2me_host_unittest.cc", "it2me/it2me_host_unittest.cc",
"it2me/it2me_native_messaging_host_unittest.cc", "it2me/it2me_native_messaging_host_unittest.cc",
"local_input_monitor_unittest.cc",
"mouse_cursor_monitor_proxy_unittest.cc", "mouse_cursor_monitor_proxy_unittest.cc",
"mouse_shape_pump_unittest.cc", "mouse_shape_pump_unittest.cc",
"native_messaging/native_messaging_reader_unittest.cc", "native_messaging/native_messaging_reader_unittest.cc",
...@@ -509,7 +494,7 @@ source_set("unit_tests") { ...@@ -509,7 +494,7 @@ source_set("unit_tests") {
] ]
if (use_ozone || is_chromeos) { if (use_ozone || is_chromeos) {
sources -= [ "local_input_monitor_unittest.cc" ] sources -= [ "input_monitor/local_input_monitor_unittest.cc" ]
} }
configs += [ "//remoting/build/config:version" ] configs += [ "//remoting/build/config:version" ]
......
# 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.
import("//remoting/build/config/remoting_build.gni")
source_set("input_monitor") {
public = [
"local_input_monitor.h",
]
sources = [
"local_hotkey_input_monitor.h",
"local_hotkey_input_monitor_chromeos.cc",
"local_hotkey_input_monitor_mac.mm",
"local_hotkey_input_monitor_win.cc",
"local_hotkey_input_monitor_x11.cc",
"local_input_monitor.cc",
"local_mouse_input_monitor.h",
"local_mouse_input_monitor_chromeos.cc",
"local_mouse_input_monitor_mac.mm",
"local_mouse_input_monitor_win.cc",
"local_mouse_input_monitor_x11.cc",
]
deps = [
"//remoting/proto",
"//third_party/webrtc/modules/desktop_capture",
]
if (use_ozone) {
deps += [ "//ui/ozone" ]
}
if (is_mac) {
deps += [ "//third_party/google_toolbox_for_mac" ]
}
if (!use_x11 || (is_chromeos && !use_ozone)) {
sources -= [
"local_hotkey_input_monitor_x11.cc",
"local_mouse_input_monitor_x11.cc",
]
}
}
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef REMOTING_HOST_LOCAL_HOTKEY_INPUT_MONITOR_H_ #ifndef REMOTING_HOST_INPUT_MONITOR_LOCAL_HOTKEY_INPUT_MONITOR_H_
#define REMOTING_HOST_LOCAL_HOTKEY_INPUT_MONITOR_H_ #define REMOTING_HOST_INPUT_MONITOR_LOCAL_HOTKEY_INPUT_MONITOR_H_
#include <memory> #include <memory>
...@@ -40,4 +40,4 @@ class LocalHotkeyInputMonitor { ...@@ -40,4 +40,4 @@ class LocalHotkeyInputMonitor {
} // namespace remoting } // namespace remoting
#endif // REMOTING_HOST_LOCAL_HOTKEY_INPUT_MONITOR_H_ #endif // REMOTING_HOST_INPUT_MONITOR_LOCAL_HOTKEY_INPUT_MONITOR_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/local_hotkey_input_monitor.h" #include "remoting/host/input_monitor/local_hotkey_input_monitor.h"
#include <utility> #include <utility>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/local_hotkey_input_monitor.h" #include "remoting/host/input_monitor/local_hotkey_input_monitor.h"
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
...@@ -88,11 +88,11 @@ class LocalHotkeyInputMonitorMac : public LocalHotkeyInputMonitor { ...@@ -88,11 +88,11 @@ class LocalHotkeyInputMonitorMac : public LocalHotkeyInputMonitor {
GTMCarbonEventDispatcherHandler* handler = GTMCarbonEventDispatcherHandler* handler =
[GTMCarbonEventDispatcherHandler sharedEventDispatcherHandler]; [GTMCarbonEventDispatcherHandler sharedEventDispatcherHandler];
hotKey_ = [handler registerHotKey:kEscKeyCode hotKey_ = [handler registerHotKey:kEscKeyCode
modifiers:(NSAlternateKeyMask | NSControlKeyMask) modifiers:(NSAlternateKeyMask | NSControlKeyMask)
target:self target:self
action:@selector(hotKeyHit:) action:@selector(hotKeyHit:)
userInfo:nil userInfo:nil
whenPressed:YES]; whenPressed:YES];
if (!hotKey_) { if (!hotKey_) {
LOG(ERROR) << "registerHotKey failed."; LOG(ERROR) << "registerHotKey failed.";
[self release]; [self release];
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/local_hotkey_input_monitor.h" #include "remoting/host/input_monitor/local_hotkey_input_monitor.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "remoting/host/client_session_control.h" #include "remoting/host/client_session_control.h"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/local_hotkey_input_monitor.h" #include "remoting/host/input_monitor/local_hotkey_input_monitor.h"
#include <sys/select.h> #include <sys/select.h>
#include <unistd.h> #include <unistd.h>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/local_input_monitor.h" #include "remoting/host/input_monitor/local_input_monitor.h"
#include <utility> #include <utility>
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "remoting/host/client_session_control.h" #include "remoting/host/client_session_control.h"
#include "remoting/host/local_hotkey_input_monitor.h" #include "remoting/host/input_monitor/local_hotkey_input_monitor.h"
#include "remoting/host/local_mouse_input_monitor.h" #include "remoting/host/input_monitor/local_mouse_input_monitor.h"
namespace remoting { namespace remoting {
namespace { namespace {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef REMOTING_HOST_LOCAL_INPUT_MONITOR_H_ #ifndef REMOTING_HOST_INPUT_MONITOR_LOCAL_INPUT_MONITOR_H_
#define REMOTING_HOST_LOCAL_INPUT_MONITOR_H_ #define REMOTING_HOST_INPUT_MONITOR_LOCAL_INPUT_MONITOR_H_
#include <memory> #include <memory>
...@@ -37,4 +37,4 @@ class LocalInputMonitor { ...@@ -37,4 +37,4 @@ class LocalInputMonitor {
} // namespace remoting } // namespace remoting
#endif // REMOTING_HOST_LOCAL_INPUT_MONITOR_H_ #endif // REMOTING_HOST_INPUT_MONITOR_LOCAL_INPUT_MONITOR_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/local_input_monitor.h" #include "remoting/host/input_monitor/local_input_monitor.h"
#include <memory> #include <memory>
...@@ -68,12 +68,9 @@ TEST_F(LocalInputMonitorTest, Basic) { ...@@ -68,12 +68,9 @@ TEST_F(LocalInputMonitorTest, Basic) {
EXPECT_CALL(client_session_control_, client_jid()) EXPECT_CALL(client_session_control_, client_jid())
.Times(AnyNumber()) .Times(AnyNumber())
.WillRepeatedly(ReturnRef(client_jid_)); .WillRepeatedly(ReturnRef(client_jid_));
EXPECT_CALL(client_session_control_, DisconnectSession(_)) EXPECT_CALL(client_session_control_, DisconnectSession(_)).Times(AnyNumber());
.Times(AnyNumber()); EXPECT_CALL(client_session_control_, OnLocalMouseMoved(_)).Times(AnyNumber());
EXPECT_CALL(client_session_control_, OnLocalMouseMoved(_)) EXPECT_CALL(client_session_control_, SetDisableInputs(_)).Times(0);
.Times(AnyNumber());
EXPECT_CALL(client_session_control_, SetDisableInputs(_))
.Times(0);
{ {
std::unique_ptr<LocalInputMonitor> local_input_monitor = std::unique_ptr<LocalInputMonitor> local_input_monitor =
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef REMOTING_HOST_LOCAL_MOUSE_INPUT_MONITOR_H_ #ifndef REMOTING_HOST_INPUT_MONITOR_LOCAL_MOUSE_INPUT_MONITOR_H_
#define REMOTING_HOST_LOCAL_MOUSE_INPUT_MONITOR_H_ #define REMOTING_HOST_INPUT_MONITOR_LOCAL_MOUSE_INPUT_MONITOR_H_
#include <memory> #include <memory>
...@@ -38,4 +38,4 @@ class LocalMouseInputMonitor { ...@@ -38,4 +38,4 @@ class LocalMouseInputMonitor {
} // namespace remoting } // namespace remoting
#endif // REMOTING_HOST_LOCAL_MOUSE_INPUT_MONITOR_H_ #endif // REMOTING_HOST_INPUT_MONITOR_LOCAL_MOUSE_INPUT_MONITOR_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/local_mouse_input_monitor.h" #include "remoting/host/input_monitor/local_mouse_input_monitor.h"
#include <utility> #include <utility>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/local_mouse_input_monitor.h" #include "remoting/host/input_monitor/local_mouse_input_monitor.h"
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
...@@ -74,8 +74,10 @@ class LocalMouseInputMonitorMac : public LocalMouseInputMonitor { ...@@ -74,8 +74,10 @@ class LocalMouseInputMonitorMac : public LocalMouseInputMonitor {
@end @end
static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type, static CGEventRef LocalMouseMoved(CGEventTapProxy proxy,
CGEventRef event, void* context) { CGEventType type,
CGEventRef event,
void* context) {
int64_t pid = CGEventGetIntegerValueField(event, kCGEventSourceUnixProcessID); int64_t pid = CGEventGetIntegerValueField(event, kCGEventSourceUnixProcessID);
if (pid == 0) { if (pid == 0) {
CGPoint cgMousePos = CGEventGetLocation(event); CGPoint cgMousePos = CGEventGetLocation(event);
...@@ -96,10 +98,10 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type, ...@@ -96,10 +98,10 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type,
kCGSessionEventTap, kCGHeadInsertEventTap, kCGEventTapOptionListenOnly, kCGSessionEventTap, kCGHeadInsertEventTap, kCGEventTapOptionListenOnly,
1 << kCGEventMouseMoved, LocalMouseMoved, self)); 1 << kCGEventMouseMoved, LocalMouseMoved, self));
if (mouseMachPort_) { if (mouseMachPort_) {
mouseRunLoopSource_ = CFMachPortCreateRunLoopSource( mouseRunLoopSource_ =
nullptr, mouseMachPort_, 0); CFMachPortCreateRunLoopSource(nullptr, mouseMachPort_, 0);
CFRunLoopAddSource( CFRunLoopAddSource(CFRunLoopGetMain(), mouseRunLoopSource_,
CFRunLoopGetMain(), mouseRunLoopSource_, kCFRunLoopCommonModes); kCFRunLoopCommonModes);
} else { } else {
LOG(ERROR) << "CGEventTapCreate failed."; LOG(ERROR) << "CGEventTapCreate failed.";
[self release]; [self release];
...@@ -116,8 +118,8 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type, ...@@ -116,8 +118,8 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type,
- (void)invalidate { - (void)invalidate {
if (mouseRunLoopSource_) { if (mouseRunLoopSource_) {
CFMachPortInvalidate(mouseMachPort_); CFMachPortInvalidate(mouseMachPort_);
CFRunLoopRemoveSource( CFRunLoopRemoveSource(CFRunLoopGetMain(), mouseRunLoopSource_,
CFRunLoopGetMain(), mouseRunLoopSource_, kCFRunLoopCommonModes); kCFRunLoopCommonModes);
CFRelease(mouseRunLoopSource_); CFRelease(mouseRunLoopSource_);
mouseMachPort_.reset(0); mouseMachPort_.reset(0);
mouseRunLoopSource_ = nullptr; mouseRunLoopSource_ = nullptr;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/local_mouse_input_monitor.h" #include "remoting/host/input_monitor/local_mouse_input_monitor.h"
#include <cstdint> #include <cstdint>
...@@ -166,10 +166,7 @@ LRESULT LocalMouseInputMonitorWin::Core::OnInput(HRAWINPUT input_handle) { ...@@ -166,10 +166,7 @@ LRESULT LocalMouseInputMonitorWin::Core::OnInput(HRAWINPUT input_handle) {
// Get the size of the input record. // Get the size of the input record.
UINT size = 0; UINT size = 0;
UINT result = GetRawInputData(input_handle, UINT result = GetRawInputData(input_handle, RID_INPUT, nullptr, &size,
RID_INPUT,
nullptr,
&size,
sizeof(RAWINPUTHEADER)); sizeof(RAWINPUTHEADER));
if (result == static_cast<UINT>(-1)) { if (result == static_cast<UINT>(-1)) {
PLOG(ERROR) << "GetRawInputData() failed"; PLOG(ERROR) << "GetRawInputData() failed";
...@@ -179,10 +176,7 @@ LRESULT LocalMouseInputMonitorWin::Core::OnInput(HRAWINPUT input_handle) { ...@@ -179,10 +176,7 @@ LRESULT LocalMouseInputMonitorWin::Core::OnInput(HRAWINPUT input_handle) {
// Retrieve the input record itself. // Retrieve the input record itself.
std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]); std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]);
RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get()); RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get());
result = GetRawInputData(input_handle, result = GetRawInputData(input_handle, RID_INPUT, buffer.get(), &size,
RID_INPUT,
buffer.get(),
&size,
sizeof(RAWINPUTHEADER)); sizeof(RAWINPUTHEADER));
if (result == static_cast<UINT>(-1)) { if (result == static_cast<UINT>(-1)) {
PLOG(ERROR) << "GetRawInputData() failed"; PLOG(ERROR) << "GetRawInputData() failed";
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/local_mouse_input_monitor.h" #include "remoting/host/input_monitor/local_mouse_input_monitor.h"
#include <sys/select.h> #include <sys/select.h>
#include <unistd.h> #include <unistd.h>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "remoting/host/client_session_control.h" #include "remoting/host/client_session_control.h"
#include "remoting/host/host_window.h" #include "remoting/host/host_window.h"
#include "remoting/host/host_window_proxy.h" #include "remoting/host/host_window_proxy.h"
#include "remoting/host/local_input_monitor.h" #include "remoting/host/input_monitor/local_input_monitor.h"
#if defined(OS_POSIX) #if defined(OS_POSIX)
#include <sys/types.h> #include <sys/types.h>
......
...@@ -15,10 +15,9 @@ ...@@ -15,10 +15,9 @@
#include "remoting/host/curtain_mode.h" #include "remoting/host/curtain_mode.h"
#include "remoting/host/desktop_resizer.h" #include "remoting/host/desktop_resizer.h"
#include "remoting/host/host_window.h" #include "remoting/host/host_window.h"
#include "remoting/host/host_window.h"
#include "remoting/host/host_window_proxy.h" #include "remoting/host/host_window_proxy.h"
#include "remoting/host/input_injector.h" #include "remoting/host/input_injector.h"
#include "remoting/host/local_input_monitor.h" #include "remoting/host/input_monitor/local_input_monitor.h"
#include "remoting/host/resizing_host_observer.h" #include "remoting/host/resizing_host_observer.h"
#include "remoting/host/screen_controls.h" #include "remoting/host/screen_controls.h"
#include "remoting/protocol/capability_names.h" #include "remoting/protocol/capability_names.h"
......
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