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

Unified Diff: remoting/client/x11_input_handler.cc

Issue 3175028: Add mouse event support to Chromoting client (Pepper and X11). (Closed)
Patch Set: Remove win float/int conversion Created 10 years, 4 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
« no previous file with comments | « remoting/client/x11_input_handler.h ('k') | remoting/client/x11_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « remoting/client/x11_input_handler.h ('k') | remoting/client/x11_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698