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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/client/x11_input_handler.h"
6
7 #include "base/message_loop.h"
8 #include "remoting/client/client_context.h"
9 #include "remoting/client/x11_view.h"
10 #include "remoting/jingle_glue/jingle_thread.h"
11
12 // Include Xlib at the end because it clashes with ClientMessage defined in
13 // the protocol buffer.
14 #include <X11/Xlib.h>
15
16 namespace remoting {
17
18 X11InputHandler::X11InputHandler(ClientContext* context,
19 ChromotingView* view)
20 : context_(context),
21 view_(view) {
22 }
23
24 X11InputHandler::~X11InputHandler() {
25 }
26
27 void X11InputHandler::Initialize() {
28 ScheduleX11EventHandler();
29 }
30
31 void X11InputHandler::DoProcessX11Events() {
32 DCHECK_EQ(context_->jingle_thread()->message_loop(), MessageLoop::current());
33 Display* display = static_cast<X11View*>(view_)->display();
34 if (XPending(display)) {
35 XEvent e;
36 XNextEvent(display, &e);
37 if (e.type == Expose) {
38 // Tell the view to paint again.
39 view_->Paint();
40 } else if (e.type == ButtonPress) {
41 // TODO(hclam): Implement.
42 NOTIMPLEMENTED();
43 } else {
44 // TODO(hclam): Implement.
45 NOTIMPLEMENTED();
46 }
47 }
48
49 // Schedule the next event handler.
50 ScheduleX11EventHandler();
51 }
52
53 void X11InputHandler::ScheduleX11EventHandler() {
54 // Schedule a delayed task to process X11 events in 10ms.
55 static const int kProcessEventsInterval = 10;
56 context_->jingle_thread()->message_loop()->PostDelayedTask(
57 FROM_HERE,
58 NewRunnableMethod(this, &X11InputHandler::DoProcessX11Events),
59 kProcessEventsInterval);
60 }
61
62 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698