Index: remoting/client/x11_input_handler.cc |
diff --git a/remoting/client/x11_input_handler.cc b/remoting/client/x11_input_handler.cc |
index 900b49230471b0d9d51bd50d9916e9cd53ef8fd3..f7900ca2d19d9e1d8b208e0b66f40f85f60a24f3 100644 |
--- a/remoting/client/x11_input_handler.cc |
+++ b/remoting/client/x11_input_handler.cc |
@@ -6,7 +6,6 @@ |
#include "base/message_loop.h" |
#include "remoting/client/client_context.h" |
-#include "remoting/client/host_connection.h" |
#include "remoting/client/x11_view.h" |
#include "remoting/jingle_glue/jingle_thread.h" |
@@ -31,19 +30,33 @@ void X11InputHandler::Initialize() { |
void X11InputHandler::DoProcessX11Events() { |
DCHECK_EQ(context_->jingle_thread()->message_loop(), MessageLoop::current()); |
+ |
Display* display = static_cast<X11View*>(view_)->display(); |
if (XPending(display)) { |
XEvent e; |
XNextEvent(display, &e); |
- if (e.type == Expose) { |
- // Tell the view to paint again. |
- view_->Paint(); |
- } else if (e.type == ButtonPress) { |
- // TODO(hclam): Implement. |
- NOTIMPLEMENTED(); |
- } else { |
- // TODO(hclam): Implement. |
- NOTIMPLEMENTED(); |
+ switch (e.type) { |
+ case Expose: |
+ // Tell the view to paint again. |
+ view_->Paint(); |
+ break; |
+ case KeyPress: |
+ case KeyRelease: |
+ // TODO(garykac) Implement. |
+ break; |
+ case ButtonPress: |
+ HandleMouseButtonEvent(true, e.xbutton.button); |
+ HandleMouseMoveEvent(e.xbutton.x, e.xbutton.y); |
+ break; |
+ case ButtonRelease: |
+ HandleMouseButtonEvent(false, e.xbutton.button); |
+ HandleMouseMoveEvent(e.xbutton.x, e.xbutton.y); |
+ break; |
+ case MotionNotify: |
+ SendMouseMoveEvent(e.xmotion.x, e.xmotion.y); |
+ break; |
+ default: |
+ LOG(WARNING) << "Unknown event type: " << e.type; |
} |
} |
@@ -60,4 +73,23 @@ void X11InputHandler::ScheduleX11EventHandler() { |
kProcessEventsInterval); |
} |
+void X11InputHandler::HandleMouseMoveEvent(int x, int y) { |
+ SendMouseMoveEvent(x, y); |
+} |
+ |
+void X11InputHandler::HandleMouseButtonEvent(bool button_down, int xbutton_id) { |
+ MouseButton button = MouseButtonUndefined; |
+ if (xbutton_id == 1) { |
+ button = MouseButtonLeft; |
+ } else if (xbutton_id == 2) { |
+ button = MouseButtonMiddle; |
+ } else if (xbutton_id == 3) { |
+ button = MouseButtonRight; |
+ } |
+ |
+ if (button != MouseButtonUndefined) { |
+ SendMouseButtonEvent(button_down, button); |
+ } |
+} |
+ |
} // namespace remoting |