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

Unified Diff: remoting/client/x11_input_handler.cc

Issue 2861047: Refactor the client code. Move all x11-related code into X11View and create... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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/client/x11_input_handler.cc
===================================================================
--- remoting/client/x11_input_handler.cc (revision 0)
+++ remoting/client/x11_input_handler.cc (revision 0)
@@ -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
Property changes on: remoting/client/x11_input_handler.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698