Commit 680cbed1 authored by wez@chromium.org's avatar wez@chromium.org

Update EventExecutorLinux to use mouse wheel deltas if present.

BUG=145875


Review URL: https://chromiumcodereview.appspot.com/11147009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162409 0039d316-1c4b-4281-b951-d872f2087c98
parent fe306d38
...@@ -33,6 +33,10 @@ using protocol::MouseEvent; ...@@ -33,6 +33,10 @@ using protocol::MouseEvent;
#include "ui/base/keycodes/usb_keycode_map.h" #include "ui/base/keycodes/usb_keycode_map.h"
#undef USB_KEYMAP #undef USB_KEYMAP
// Pixel-to-wheel-ticks conversion ratio used by GTK.
// From Source/WebKit/chromium/src/gtk/WebInputFactory.cc.
const float kWheelTicksPerPixel = 3.0f / 160.0f;
// A class to generate events on Linux. // A class to generate events on Linux.
class EventExecutorLinux : public EventExecutor { class EventExecutorLinux : public EventExecutor {
public: public:
...@@ -77,6 +81,8 @@ class EventExecutorLinux : public EventExecutor { ...@@ -77,6 +81,8 @@ class EventExecutorLinux : public EventExecutor {
std::set<int> pressed_keys_; std::set<int> pressed_keys_;
SkIPoint latest_mouse_position_; SkIPoint latest_mouse_position_;
float wheel_ticks_x_;
float wheel_ticks_y_;
// X11 graphics context. // X11 graphics context.
Display* display_; Display* display_;
...@@ -96,6 +102,8 @@ EventExecutorLinux::EventExecutorLinux( ...@@ -96,6 +102,8 @@ EventExecutorLinux::EventExecutorLinux(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: task_runner_(task_runner), : task_runner_(task_runner),
latest_mouse_position_(SkIPoint::Make(-1, -1)), latest_mouse_position_(SkIPoint::Make(-1, -1)),
wheel_ticks_x_(0.0f),
wheel_ticks_y_(0.0f),
display_(XOpenDisplay(NULL)), display_(XOpenDisplay(NULL)),
root_window_(BadValue) { root_window_(BadValue) {
#if defined(REMOTING_HOST_LINUX_CLIPBOARD) #if defined(REMOTING_HOST_LINUX_CLIPBOARD)
...@@ -264,14 +272,30 @@ void EventExecutorLinux::InjectMouseEvent(const MouseEvent& event) { ...@@ -264,14 +272,30 @@ void EventExecutorLinux::InjectMouseEvent(const MouseEvent& event) {
CurrentTime); CurrentTime);
} }
if (event.has_wheel_offset_y() && event.wheel_offset_y() != 0) { int ticks_y = 0;
int dy = event.wheel_offset_y(); if (event.has_wheel_delta_y()) {
InjectScrollWheelClicks(VerticalScrollWheelToX11ButtonNumber(dy), abs(dy)); wheel_ticks_y_ += event.wheel_delta_y() * kWheelTicksPerPixel;
ticks_y = static_cast<int>(wheel_ticks_y_);
wheel_ticks_y_ -= ticks_y;
} else if (event.has_wheel_offset_y()) {
ticks_y = event.wheel_offset_y();
}
if (ticks_y != 0) {
InjectScrollWheelClicks(VerticalScrollWheelToX11ButtonNumber(ticks_y),
abs(ticks_y));
}
int ticks_x = 0;
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;
} else if (event.has_wheel_offset_x()) {
ticks_x = event.wheel_offset_x();
} }
if (event.has_wheel_offset_x() && event.wheel_offset_x() != 0) { if (ticks_x != 0) {
int dx = event.wheel_offset_x(); InjectScrollWheelClicks(HorizontalScrollWheelToX11ButtonNumber(ticks_x),
InjectScrollWheelClicks(HorizontalScrollWheelToX11ButtonNumber(dx), abs(ticks_x));
abs(dx));
} }
XFlush(display_); XFlush(display_);
......
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