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

Side by Side Diff: remoting/host/event_executor_win.cc

Issue 5068001: Move move classes to the remoting::protocol namespace. Minor cleanups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes for windows Created 10 years 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/event_executor_win.h" 5 #include "remoting/host/event_executor_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "app/keyboard_codes.h" 9 #include "app/keyboard_codes.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
12 #include "remoting/host/capturer.h" 12 #include "remoting/host/capturer.h"
13 #include "remoting/proto/event.pb.h" 13 #include "remoting/proto/event.pb.h"
14 14
15 namespace remoting { 15 namespace remoting {
16 16
17 using protocol::MouseEvent;
18 using protocol::KeyEvent;
19
17 EventExecutorWin::EventExecutorWin( 20 EventExecutorWin::EventExecutorWin(
18 MessageLoop* message_loop, Capturer* capturer) 21 MessageLoop* message_loop, Capturer* capturer)
19 : message_loop_(message_loop), 22 : message_loop_(message_loop),
20 capturer_(capturer) { 23 capturer_(capturer) {
21 } 24 }
22 25
23 EventExecutorWin::~EventExecutorWin() { 26 EventExecutorWin::~EventExecutorWin() {
24 } 27 }
25 28
26 void EventExecutorWin::InjectKeyEvent(const KeyEvent* event, Task* done) { 29 void EventExecutorWin::InjectKeyEvent(const KeyEvent* event, Task* done) {
27 if (MessageLoop::current() != message_loop_) { 30 if (MessageLoop::current() != message_loop_) {
28 message_loop_->PostTask( 31 message_loop_->PostTask(
29 FROM_HERE, 32 FROM_HERE,
30 NewRunnableMethod(this, &EventExecutorWin::InjectKeyEvent, 33 NewRunnableMethod(this, &EventExecutorWin::InjectKeyEvent,
31 event, done)); 34 event, done));
32 return; 35 return;
33 } 36 }
34 HandleKey(event); 37 HandleKey(event);
35 done->Run(); 38 done->Run();
36 delete done; 39 delete done;
37 } 40 }
38 41
39 void EventExecutorWin::InjectMouseEvent(const MouseEvent* event, 42 void EventExecutorWin::InjectMouseEvent(const MouseEvent* event, Task* done) {
40 Task* done) {
41 if (MessageLoop::current() != message_loop_) { 43 if (MessageLoop::current() != message_loop_) {
42 message_loop_->PostTask( 44 message_loop_->PostTask(
43 FROM_HERE, 45 FROM_HERE,
44 NewRunnableMethod(this, &EventExecutorWin::InjectMouseEvent, 46 NewRunnableMethod(this, &EventExecutorWin::InjectMouseEvent,
45 event, done)); 47 event, done));
46 return; 48 return;
47 } 49 }
48 HandleMouse(event); 50 HandleMouse(event);
49 done->Run(); 51 done->Run();
50 delete done; 52 delete done;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 121 }
120 } 122 }
121 123
122 if (event->has_button() && event->has_button_down()) { 124 if (event->has_button() && event->has_button_down()) {
123 INPUT button_event; 125 INPUT button_event;
124 button_event.type = INPUT_MOUSE; 126 button_event.type = INPUT_MOUSE;
125 button_event.mi.time = 0; 127 button_event.mi.time = 0;
126 button_event.mi.dx = 0; 128 button_event.mi.dx = 0;
127 button_event.mi.dy = 0; 129 button_event.mi.dy = 0;
128 130
129 MouseButton button = event->button(); 131 MouseEvent::MouseButton button = event->button();
130 bool down = event->button_down(); 132 bool down = event->button_down();
131 if (button == MouseButtonLeft) { 133 if (button == MouseEvent::BUTTON_LEFT) {
132 button_event.mi.dwFlags = 134 button_event.mi.dwFlags =
133 down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP; 135 down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
134 } else if (button == MouseButtonMiddle) { 136 } else if (button == MouseEvent::BUTTON_MIDDLE) {
135 button_event.mi.dwFlags = 137 button_event.mi.dwFlags =
136 down ? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP; 138 down ? MOUSEEVENTF_MIDDLEDOWN : MOUSEEVENTF_MIDDLEUP;
137 } else if (button == MouseButtonRight) { 139 } else if (button == MouseEvent::BUTTON_RIGHT) {
138 button_event.mi.dwFlags = 140 button_event.mi.dwFlags =
139 down ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP; 141 down ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
140 } else { 142 } else {
141 button_event.mi.dwFlags = 143 button_event.mi.dwFlags =
142 down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP; 144 down ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
143 } 145 }
144 146
145 SendInput(1, &button_event, sizeof(INPUT)); 147 SendInput(1, &button_event, sizeof(INPUT));
146 } 148 }
147 } 149 }
148 150
149 } // namespace remoting 151 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698