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") {
"ipc_video_frame_capturer.h",
"it2me_desktop_environment.cc",
"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_linux.cc",
"logging_mac.cc",
......@@ -308,6 +296,7 @@ static_library("host") {
"//media",
"//remoting/base",
"//remoting/base:authorization",
"//remoting/host/input_monitor",
"//remoting/host/security_key",
"//remoting/protocol",
"//remoting/resources",
......@@ -355,8 +344,6 @@ static_library("host") {
"clipboard_x11.cc",
"desktop_resizer_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") {
"desktop_resizer_x11.cc",
"input_injector_chromeos.cc",
"input_injector_chromeos.h",
"local_hotkey_input_monitor_x11.cc",
"local_mouse_input_monitor_x11.cc",
]
}
}
......@@ -480,11 +465,11 @@ source_set("unit_tests") {
"host_extension_session_manager_unittest.cc",
"host_power_save_blocker_unittest.cc",
"host_status_logger_unittest.cc",
"input_monitor/local_input_monitor_unittest.cc",
"ipc_desktop_environment_unittest.cc",
"it2me/it2me_confirmation_dialog_proxy_unittest.cc",
"it2me/it2me_host_unittest.cc",
"it2me/it2me_native_messaging_host_unittest.cc",
"local_input_monitor_unittest.cc",
"mouse_cursor_monitor_proxy_unittest.cc",
"mouse_shape_pump_unittest.cc",
"native_messaging/native_messaging_reader_unittest.cc",
......@@ -509,7 +494,7 @@ source_set("unit_tests") {
]
if (use_ozone || is_chromeos) {
sources -= [ "local_input_monitor_unittest.cc" ]
sources -= [ "input_monitor/local_input_monitor_unittest.cc" ]
}
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 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_LOCAL_HOTKEY_INPUT_MONITOR_H_
#define REMOTING_HOST_LOCAL_HOTKEY_INPUT_MONITOR_H_
#ifndef REMOTING_HOST_INPUT_MONITOR_LOCAL_HOTKEY_INPUT_MONITOR_H_
#define REMOTING_HOST_INPUT_MONITOR_LOCAL_HOTKEY_INPUT_MONITOR_H_
#include <memory>
......@@ -40,4 +40,4 @@ class LocalHotkeyInputMonitor {
} // namespace remoting
#endif // REMOTING_HOST_LOCAL_HOTKEY_INPUT_MONITOR_H_
#endif // REMOTING_HOST_INPUT_MONITOR_LOCAL_HOTKEY_INPUT_MONITOR_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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>
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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>
......@@ -88,11 +88,11 @@ class LocalHotkeyInputMonitorMac : public LocalHotkeyInputMonitor {
GTMCarbonEventDispatcherHandler* handler =
[GTMCarbonEventDispatcherHandler sharedEventDispatcherHandler];
hotKey_ = [handler registerHotKey:kEscKeyCode
modifiers:(NSAlternateKeyMask | NSControlKeyMask)
target:self
action:@selector(hotKeyHit:)
userInfo:nil
whenPressed:YES];
modifiers:(NSAlternateKeyMask | NSControlKeyMask)
target:self
action:@selector(hotKeyHit:)
userInfo:nil
whenPressed:YES];
if (!hotKey_) {
LOG(ERROR) << "registerHotKey failed.";
[self release];
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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 "remoting/host/client_session_control.h"
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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 <unistd.h>
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/local_input_monitor.h"
#include "remoting/host/input_monitor/local_input_monitor.h"
#include <utility>
......@@ -10,8 +10,8 @@
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
#include "remoting/host/client_session_control.h"
#include "remoting/host/local_hotkey_input_monitor.h"
#include "remoting/host/local_mouse_input_monitor.h"
#include "remoting/host/input_monitor/local_hotkey_input_monitor.h"
#include "remoting/host/input_monitor/local_mouse_input_monitor.h"
namespace remoting {
namespace {
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_LOCAL_INPUT_MONITOR_H_
#define REMOTING_HOST_LOCAL_INPUT_MONITOR_H_
#ifndef REMOTING_HOST_INPUT_MONITOR_LOCAL_INPUT_MONITOR_H_
#define REMOTING_HOST_INPUT_MONITOR_LOCAL_INPUT_MONITOR_H_
#include <memory>
......@@ -37,4 +37,4 @@ class LocalInputMonitor {
} // namespace remoting
#endif // REMOTING_HOST_LOCAL_INPUT_MONITOR_H_
#endif // REMOTING_HOST_INPUT_MONITOR_LOCAL_INPUT_MONITOR_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/local_input_monitor.h"
#include "remoting/host/input_monitor/local_input_monitor.h"
#include <memory>
......@@ -68,12 +68,9 @@ TEST_F(LocalInputMonitorTest, Basic) {
EXPECT_CALL(client_session_control_, client_jid())
.Times(AnyNumber())
.WillRepeatedly(ReturnRef(client_jid_));
EXPECT_CALL(client_session_control_, DisconnectSession(_))
.Times(AnyNumber());
EXPECT_CALL(client_session_control_, OnLocalMouseMoved(_))
.Times(AnyNumber());
EXPECT_CALL(client_session_control_, SetDisableInputs(_))
.Times(0);
EXPECT_CALL(client_session_control_, DisconnectSession(_)).Times(AnyNumber());
EXPECT_CALL(client_session_control_, OnLocalMouseMoved(_)).Times(AnyNumber());
EXPECT_CALL(client_session_control_, SetDisableInputs(_)).Times(0);
{
std::unique_ptr<LocalInputMonitor> local_input_monitor =
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_LOCAL_MOUSE_INPUT_MONITOR_H_
#define REMOTING_HOST_LOCAL_MOUSE_INPUT_MONITOR_H_
#ifndef REMOTING_HOST_INPUT_MONITOR_LOCAL_MOUSE_INPUT_MONITOR_H_
#define REMOTING_HOST_INPUT_MONITOR_LOCAL_MOUSE_INPUT_MONITOR_H_
#include <memory>
......@@ -38,4 +38,4 @@ class LocalMouseInputMonitor {
} // namespace remoting
#endif // REMOTING_HOST_LOCAL_MOUSE_INPUT_MONITOR_H_
#endif // REMOTING_HOST_INPUT_MONITOR_LOCAL_MOUSE_INPUT_MONITOR_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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>
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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>
......@@ -74,8 +74,10 @@ class LocalMouseInputMonitorMac : public LocalMouseInputMonitor {
@end
static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type,
CGEventRef event, void* context) {
static CGEventRef LocalMouseMoved(CGEventTapProxy proxy,
CGEventType type,
CGEventRef event,
void* context) {
int64_t pid = CGEventGetIntegerValueField(event, kCGEventSourceUnixProcessID);
if (pid == 0) {
CGPoint cgMousePos = CGEventGetLocation(event);
......@@ -96,10 +98,10 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type,
kCGSessionEventTap, kCGHeadInsertEventTap, kCGEventTapOptionListenOnly,
1 << kCGEventMouseMoved, LocalMouseMoved, self));
if (mouseMachPort_) {
mouseRunLoopSource_ = CFMachPortCreateRunLoopSource(
nullptr, mouseMachPort_, 0);
CFRunLoopAddSource(
CFRunLoopGetMain(), mouseRunLoopSource_, kCFRunLoopCommonModes);
mouseRunLoopSource_ =
CFMachPortCreateRunLoopSource(nullptr, mouseMachPort_, 0);
CFRunLoopAddSource(CFRunLoopGetMain(), mouseRunLoopSource_,
kCFRunLoopCommonModes);
} else {
LOG(ERROR) << "CGEventTapCreate failed.";
[self release];
......@@ -116,8 +118,8 @@ static CGEventRef LocalMouseMoved(CGEventTapProxy proxy, CGEventType type,
- (void)invalidate {
if (mouseRunLoopSource_) {
CFMachPortInvalidate(mouseMachPort_);
CFRunLoopRemoveSource(
CFRunLoopGetMain(), mouseRunLoopSource_, kCFRunLoopCommonModes);
CFRunLoopRemoveSource(CFRunLoopGetMain(), mouseRunLoopSource_,
kCFRunLoopCommonModes);
CFRelease(mouseRunLoopSource_);
mouseMachPort_.reset(0);
mouseRunLoopSource_ = nullptr;
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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>
......@@ -166,10 +166,7 @@ LRESULT LocalMouseInputMonitorWin::Core::OnInput(HRAWINPUT input_handle) {
// Get the size of the input record.
UINT size = 0;
UINT result = GetRawInputData(input_handle,
RID_INPUT,
nullptr,
&size,
UINT result = GetRawInputData(input_handle, RID_INPUT, nullptr, &size,
sizeof(RAWINPUTHEADER));
if (result == static_cast<UINT>(-1)) {
PLOG(ERROR) << "GetRawInputData() failed";
......@@ -179,10 +176,7 @@ LRESULT LocalMouseInputMonitorWin::Core::OnInput(HRAWINPUT input_handle) {
// Retrieve the input record itself.
std::unique_ptr<uint8_t[]> buffer(new uint8_t[size]);
RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get());
result = GetRawInputData(input_handle,
RID_INPUT,
buffer.get(),
&size,
result = GetRawInputData(input_handle, RID_INPUT, buffer.get(), &size,
sizeof(RAWINPUTHEADER));
if (result == static_cast<UINT>(-1)) {
PLOG(ERROR) << "GetRawInputData() failed";
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// 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 <unistd.h>
......
......@@ -13,7 +13,7 @@
#include "remoting/host/client_session_control.h"
#include "remoting/host/host_window.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)
#include <sys/types.h>
......
......@@ -15,10 +15,9 @@
#include "remoting/host/curtain_mode.h"
#include "remoting/host/desktop_resizer.h"
#include "remoting/host/host_window.h"
#include "remoting/host/host_window.h"
#include "remoting/host/host_window_proxy.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/screen_controls.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