Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Unified Diff: remoting/host/event_executor_linux.cc

Issue 6697024: client-side wheel mouse support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unused usings Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_);
}
}

Powered by Google App Engine
This is Rietveld 408576698