summaryrefslogtreecommitdiffstats
path: root/remoting/client/x11_input_handler.cc
diff options
context:
space:
mode:
authorgarykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 00:34:57 +0000
committergarykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-20 00:34:57 +0000
commit4d37c874d917cc370e188cfdef05bb629388421a (patch)
tree08f68e3ef47406ae69209f489832fa8f1c76448e /remoting/client/x11_input_handler.cc
parent0af395eb3fa7d33473b4239a7b637fc6a7ce0e98 (diff)
downloadchromium_src-4d37c874d917cc370e188cfdef05bb629388421a.zip
chromium_src-4d37c874d917cc370e188cfdef05bb629388421a.tar.gz
chromium_src-4d37c874d917cc370e188cfdef05bb629388421a.tar.bz2
Refactor the client code for the X11 version.
Make ChromotingViews responsible for initializing themselves. Move all x11-related code into X11View. Create InputCapturer class manage client input capture. BUG=none TEST=ran Win host + X11 client Review URL: http://codereview.chromium.org/2861047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52973 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client/x11_input_handler.cc')
-rw-r--r--remoting/client/x11_input_handler.cc62
1 files changed, 62 insertions, 0 deletions
diff --git a/remoting/client/x11_input_handler.cc b/remoting/client/x11_input_handler.cc
new file mode 100644
index 0000000..455ff61
--- /dev/null
+++ b/remoting/client/x11_input_handler.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/client/x11_input_handler.h"
+
+#include "base/message_loop.h"
+#include "remoting/client/client_context.h"
+#include "remoting/client/x11_view.h"
+#include "remoting/jingle_glue/jingle_thread.h"
+
+// Include Xlib at the end because it clashes with ClientMessage defined in
+// the protocol buffer.
+#include <X11/Xlib.h>
+
+namespace remoting {
+
+X11InputHandler::X11InputHandler(ClientContext* context,
+ ChromotingView* view)
+ : context_(context),
+ view_(view) {
+}
+
+X11InputHandler::~X11InputHandler() {
+}
+
+void X11InputHandler::Initialize() {
+ ScheduleX11EventHandler();
+}
+
+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();
+ }
+ }
+
+ // Schedule the next event handler.
+ ScheduleX11EventHandler();
+}
+
+void X11InputHandler::ScheduleX11EventHandler() {
+ // Schedule a delayed task to process X11 events in 10ms.
+ static const int kProcessEventsInterval = 10;
+ context_->jingle_thread()->message_loop()->PostDelayedTask(
+ FROM_HERE,
+ NewRunnableMethod(this, &X11InputHandler::DoProcessX11Events),
+ kProcessEventsInterval);
+}
+
+} // namespace remoting