summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/client/plugin/pepper_input_handler.cc25
-rw-r--r--remoting/client/plugin/pepper_input_handler.h4
-rw-r--r--remoting/host/input_injector_linux.cc13
-rw-r--r--remoting/proto/event.proto6
4 files changed, 40 insertions, 8 deletions
diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc
index dba438a..1b67ba25 100644
--- a/remoting/client/plugin/pepper_input_handler.cc
+++ b/remoting/client/plugin/pepper_input_handler.cc
@@ -16,7 +16,9 @@ namespace remoting {
PepperInputHandler::PepperInputHandler(protocol::InputStub* input_stub)
: input_stub_(input_stub),
wheel_delta_x_(0),
- wheel_delta_y_(0) {
+ wheel_delta_y_(0),
+ wheel_ticks_x_(0),
+ wheel_ticks_y_(0) {
}
PepperInputHandler::~PepperInputHandler() {
@@ -107,12 +109,17 @@ bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) {
if (pp_wheel_event.GetScrollByPage())
return false;
- // Add this event to our accumulated sub-pixel deltas.
+ // Add this event to our accumulated sub-pixel deltas and clicks.
pp::FloatPoint delta = pp_wheel_event.GetDelta();
wheel_delta_x_ += delta.x();
wheel_delta_y_ += delta.y();
+ pp::FloatPoint ticks = pp_wheel_event.GetTicks();
+ wheel_ticks_x_ += ticks.x();
+ wheel_ticks_y_ += ticks.y();
- // If there is at least a pixel's movement, emit an event.
+ // If there is at least a pixel's movement, emit an event. We don't
+ // ever expect to accumulate one tick's worth of scrolling without
+ // accumulating a pixel's worth at the same time, so this is safe.
int delta_x = static_cast<int>(wheel_delta_x_);
int delta_y = static_cast<int>(wheel_delta_y_);
if (delta_x != 0 || delta_y != 0) {
@@ -122,6 +129,18 @@ bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) {
mouse_event.set_wheel_delta_x(delta_x);
mouse_event.set_wheel_delta_y(delta_y);
+ // Always include the ticks in the event, even if insufficient pixel
+ // scrolling has accumulated for a single tick. This informs hosts
+ // that can't inject pixel-based scroll events that the client will
+ // accumulate them into tick-based scrolling, which gives a better
+ // overall experience than trying to do this host-side.
+ int ticks_x = static_cast<int>(wheel_ticks_x_);
+ int ticks_y = static_cast<int>(wheel_ticks_y_);
+ wheel_ticks_x_ -= ticks_x;
+ wheel_ticks_y_ -= ticks_y;
+ mouse_event.set_wheel_ticks_x(ticks_x);
+ mouse_event.set_wheel_ticks_y(ticks_y);
+
input_stub_->InjectMouseEvent(mouse_event);
}
return true;
diff --git a/remoting/client/plugin/pepper_input_handler.h b/remoting/client/plugin/pepper_input_handler.h
index 2983b07a..0e63e0f 100644
--- a/remoting/client/plugin/pepper_input_handler.h
+++ b/remoting/client/plugin/pepper_input_handler.h
@@ -28,9 +28,11 @@ class PepperInputHandler {
private:
protocol::InputStub* input_stub_;
- // Accumulated sub-pixel deltas from wheel events.
+ // Accumulated sub-pixel and sub-tick deltas from wheel events.
float wheel_delta_x_;
float wheel_delta_y_;
+ float wheel_ticks_x_;
+ float wheel_ticks_y_;
DISALLOW_COPY_AND_ASSIGN(PepperInputHandler);
};
diff --git a/remoting/host/input_injector_linux.cc b/remoting/host/input_injector_linux.cc
index 45221d1..6054cc5 100644
--- a/remoting/host/input_injector_linux.cc
+++ b/remoting/host/input_injector_linux.cc
@@ -340,8 +340,15 @@ void InputInjectorLinux::Core::InjectMouseEvent(const MouseEvent& event) {
CurrentTime);
}
+ // Older client plugins always send scroll events in pixels, which
+ // must be accumulated host-side. Recent client plugins send both
+ // pixels and ticks with every scroll event, allowing the host to
+ // choose the best model on a per-platform basis. Since we can only
+ // inject ticks on Linux, use them if available.
int ticks_y = 0;
- if (event.has_wheel_delta_y()) {
+ if (event.has_wheel_ticks_y()) {
+ ticks_y = event.wheel_ticks_y();
+ } else if (event.has_wheel_delta_y()) {
wheel_ticks_y_ += event.wheel_delta_y() * kWheelTicksPerPixel;
ticks_y = static_cast<int>(wheel_ticks_y_);
wheel_ticks_y_ -= ticks_y;
@@ -352,7 +359,9 @@ void InputInjectorLinux::Core::InjectMouseEvent(const MouseEvent& event) {
}
int ticks_x = 0;
- if (event.has_wheel_delta_x()) {
+ if (event.has_wheel_ticks_x()) {
+ ticks_x = event.wheel_ticks_x();
+ } else if (event.has_wheel_delta_x()) {
wheel_ticks_x_ += event.wheel_delta_x() * kWheelTicksPerPixel;
ticks_x = static_cast<int>(wheel_ticks_x_);
wheel_ticks_x_ -= ticks_x;
diff --git a/remoting/proto/event.proto b/remoting/proto/event.proto
index e5ec135..8f28f07 100644
--- a/remoting/proto/event.proto
+++ b/remoting/proto/event.proto
@@ -52,10 +52,12 @@ message MouseEvent {
optional bool button_down = 6;
// Mouse wheel information.
- // These values encode the number of pixels of movement that would result
- // from the wheel event on the client system.
+ // These values encode the number of pixels and 'ticks' of movement that
+ // would result from the wheel event on the client system.
optional float wheel_delta_x = 7;
optional float wheel_delta_y = 8;
+ optional float wheel_ticks_x = 9;
+ optional float wheel_ticks_y = 10;
}
// Defines an event that sends clipboard data between peers.