Chromium Code Reviews| Index: remoting/host/event_executor_linux.cc |
| diff --git a/remoting/host/event_executor_linux.cc b/remoting/host/event_executor_linux.cc |
| index 2321c5c0ec3dd2d059f237e47c7f5d1456a773e7..9e2701ebf84c26156d665ecf98440358d36e1703 100644 |
| --- a/remoting/host/event_executor_linux.cc |
| +++ b/remoting/host/event_executor_linux.cc |
| @@ -68,6 +68,12 @@ int MouseButtonToX11ButtonNumber(MouseEvent::MouseButton button) { |
| } |
| } |
| +int VerticalScrollWheelToX11ButtonNumber(int dy) { |
|
Lambros
2011/10/13 00:56:06
Personally, I like "dy", but it might fall foul of
garykac
2011/10/13 21:18:53
^_^
|
| + // Positive y-values are wheel down events (button 4), negative y-values are |
| + // wheel up (button 5). |
|
Lambros
2011/10/13 00:41:13
Is this comment the wrong way round? If I touch m
garykac
2011/10/13 21:18:53
Fixed.
|
| + return (dy > 0 ? 4 : 5); |
| +} |
| + |
| // Hard-coded mapping from Virtual Key codes to X11 KeySyms. |
| // This mapping is only valid if both client and host are using a |
| // US English keyboard layout. |
| @@ -339,8 +345,7 @@ void EventExecutorLinux::InjectMouseEvent(const MouseEvent& event) { |
| int button_number = MouseButtonToX11ButtonNumber(event.button()); |
| if (button_number < 0) { |
| - LOG(WARNING) << "Ignoring unknown button type: " |
| - << event.button(); |
| + LOG(WARNING) << "Ignoring unknown button type: " << event.button(); |
| return; |
| } |
| @@ -353,8 +358,21 @@ void EventExecutorLinux::InjectMouseEvent(const MouseEvent& event) { |
| XFlush(display_); |
| } |
| - if (event.has_wheel_offset_x() && event.has_wheel_offset_y()) { |
| - NOTIMPLEMENTED() << "No scroll wheel support yet."; |
| + if (event.has_wheel_offset_x() && event.wheel_offset_x() != 0) { |
| + NOTIMPLEMENTED() << "No horizontal scroll wheel support yet."; |
| + } |
| + if (event.has_wheel_offset_y()) { |
| + int dy = event.wheel_offset_y(); |
| + int button_number = VerticalScrollWheelToX11ButtonNumber(dy); |
| + if (dy < 0) |
| + dy = -dy; |
| + |
| + for (int i = 0; i < dy; i++) { |
| + // Generate a button-down and a button-up to simulate a wheel click. |
| + XTestFakeButtonEvent(display_, button_number, true, CurrentTime); |
| + XTestFakeButtonEvent(display_, button_number, false, CurrentTime); |
| + } |
| + XFlush(display_); |
| } |
| } |