OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/aura/remote_root_window_host_win.h" | 5 #include "ui/aura/remote_root_window_host_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ui/events/event_utils.h" | 23 #include "ui/events/event_utils.h" |
24 #include "ui/events/keycodes/keyboard_code_conversion_win.h" | 24 #include "ui/events/keycodes/keyboard_code_conversion_win.h" |
25 #include "ui/base/view_prop.h" | 25 #include "ui/base/view_prop.h" |
26 #include "ui/gfx/insets.h" | 26 #include "ui/gfx/insets.h" |
27 #include "ui/metro_viewer/metro_viewer_messages.h" | 27 #include "ui/metro_viewer/metro_viewer_messages.h" |
28 | 28 |
29 namespace aura { | 29 namespace aura { |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 const char* kRootWindowHostWinKey = "__AURA_REMOTE_ROOT_WINDOW_HOST_WIN__"; | 33 const char* kWindowTreeHostWinKey = "__AURA_REMOTE_ROOT_WINDOW_HOST_WIN__"; |
34 | 34 |
35 // Sets the keystate for the virtual key passed in to down or up. | 35 // Sets the keystate for the virtual key passed in to down or up. |
36 void SetKeyState(uint8* key_states, bool key_down, uint32 virtual_key_code) { | 36 void SetKeyState(uint8* key_states, bool key_down, uint32 virtual_key_code) { |
37 DCHECK(key_states); | 37 DCHECK(key_states); |
38 | 38 |
39 if (key_down) | 39 if (key_down) |
40 key_states[virtual_key_code] |= 0x80; | 40 key_states[virtual_key_code] |= 0x80; |
41 else | 41 else |
42 key_states[virtual_key_code] &= 0x7F; | 42 key_states[virtual_key_code] &= 0x7F; |
43 } | 43 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 } // namespace | 82 } // namespace |
83 | 83 |
84 void HandleOpenFile(const base::string16& title, | 84 void HandleOpenFile(const base::string16& title, |
85 const base::FilePath& default_path, | 85 const base::FilePath& default_path, |
86 const base::string16& filter, | 86 const base::string16& filter, |
87 const OpenFileCompletion& on_success, | 87 const OpenFileCompletion& on_success, |
88 const FileSelectionCanceled& on_failure) { | 88 const FileSelectionCanceled& on_failure) { |
89 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 89 DCHECK(aura::RemoteWindowTreeHostWin::Instance()); |
90 aura::RemoteRootWindowHostWin::Instance()->HandleOpenFile(title, | 90 aura::RemoteWindowTreeHostWin::Instance()->HandleOpenFile(title, |
91 default_path, | 91 default_path, |
92 filter, | 92 filter, |
93 on_success, | 93 on_success, |
94 on_failure); | 94 on_failure); |
95 } | 95 } |
96 | 96 |
97 void HandleOpenMultipleFiles(const base::string16& title, | 97 void HandleOpenMultipleFiles(const base::string16& title, |
98 const base::FilePath& default_path, | 98 const base::FilePath& default_path, |
99 const base::string16& filter, | 99 const base::string16& filter, |
100 const OpenMultipleFilesCompletion& on_success, | 100 const OpenMultipleFilesCompletion& on_success, |
101 const FileSelectionCanceled& on_failure) { | 101 const FileSelectionCanceled& on_failure) { |
102 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 102 DCHECK(aura::RemoteWindowTreeHostWin::Instance()); |
103 aura::RemoteRootWindowHostWin::Instance()->HandleOpenMultipleFiles( | 103 aura::RemoteWindowTreeHostWin::Instance()->HandleOpenMultipleFiles( |
104 title, | 104 title, |
105 default_path, | 105 default_path, |
106 filter, | 106 filter, |
107 on_success, | 107 on_success, |
108 on_failure); | 108 on_failure); |
109 } | 109 } |
110 | 110 |
111 void HandleSaveFile(const base::string16& title, | 111 void HandleSaveFile(const base::string16& title, |
112 const base::FilePath& default_path, | 112 const base::FilePath& default_path, |
113 const base::string16& filter, | 113 const base::string16& filter, |
114 int filter_index, | 114 int filter_index, |
115 const base::string16& default_extension, | 115 const base::string16& default_extension, |
116 const SaveFileCompletion& on_success, | 116 const SaveFileCompletion& on_success, |
117 const FileSelectionCanceled& on_failure) { | 117 const FileSelectionCanceled& on_failure) { |
118 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 118 DCHECK(aura::RemoteWindowTreeHostWin::Instance()); |
119 aura::RemoteRootWindowHostWin::Instance()->HandleSaveFile(title, | 119 aura::RemoteWindowTreeHostWin::Instance()->HandleSaveFile(title, |
120 default_path, | 120 default_path, |
121 filter, | 121 filter, |
122 filter_index, | 122 filter_index, |
123 default_extension, | 123 default_extension, |
124 on_success, | 124 on_success, |
125 on_failure); | 125 on_failure); |
126 } | 126 } |
127 | 127 |
128 void HandleSelectFolder(const base::string16& title, | 128 void HandleSelectFolder(const base::string16& title, |
129 const SelectFolderCompletion& on_success, | 129 const SelectFolderCompletion& on_success, |
130 const FileSelectionCanceled& on_failure) { | 130 const FileSelectionCanceled& on_failure) { |
131 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 131 DCHECK(aura::RemoteWindowTreeHostWin::Instance()); |
132 aura::RemoteRootWindowHostWin::Instance()->HandleSelectFolder(title, | 132 aura::RemoteWindowTreeHostWin::Instance()->HandleSelectFolder(title, |
133 on_success, | 133 on_success, |
134 on_failure); | 134 on_failure); |
135 } | 135 } |
136 | 136 |
137 void HandleActivateDesktop(const base::FilePath& shortcut, | 137 void HandleActivateDesktop(const base::FilePath& shortcut, |
138 bool ash_exit) { | 138 bool ash_exit) { |
139 DCHECK(aura::RemoteRootWindowHostWin::Instance()); | 139 DCHECK(aura::RemoteWindowTreeHostWin::Instance()); |
140 aura::RemoteRootWindowHostWin::Instance()->HandleActivateDesktop(shortcut, | 140 aura::RemoteWindowTreeHostWin::Instance()->HandleActivateDesktop(shortcut, |
141 ash_exit); | 141 ash_exit); |
142 } | 142 } |
143 | 143 |
144 RemoteRootWindowHostWin* g_instance = NULL; | 144 RemoteWindowTreeHostWin* g_instance = NULL; |
145 | 145 |
146 RemoteRootWindowHostWin* RemoteRootWindowHostWin::Instance() { | 146 RemoteWindowTreeHostWin* RemoteWindowTreeHostWin::Instance() { |
147 if (g_instance) | 147 if (g_instance) |
148 return g_instance; | 148 return g_instance; |
149 return Create(gfx::Rect()); | 149 return Create(gfx::Rect()); |
150 } | 150 } |
151 | 151 |
152 RemoteRootWindowHostWin* RemoteRootWindowHostWin::Create( | 152 RemoteWindowTreeHostWin* RemoteWindowTreeHostWin::Create( |
153 const gfx::Rect& bounds) { | 153 const gfx::Rect& bounds) { |
154 g_instance = g_instance ? g_instance : new RemoteRootWindowHostWin(bounds); | 154 g_instance = g_instance ? g_instance : new RemoteWindowTreeHostWin(bounds); |
155 return g_instance; | 155 return g_instance; |
156 } | 156 } |
157 | 157 |
158 RemoteRootWindowHostWin::RemoteRootWindowHostWin(const gfx::Rect& bounds) | 158 RemoteWindowTreeHostWin::RemoteWindowTreeHostWin(const gfx::Rect& bounds) |
159 : remote_window_(NULL), | 159 : remote_window_(NULL), |
160 host_(NULL), | 160 host_(NULL), |
161 ignore_mouse_moves_until_set_cursor_ack_(false), | 161 ignore_mouse_moves_until_set_cursor_ack_(false), |
162 event_flags_(0), | 162 event_flags_(0), |
163 window_size_(aura::RootWindowHost::GetNativeScreenSize()) { | 163 window_size_(aura::WindowTreeHost::GetNativeScreenSize()) { |
164 prop_.reset(new ui::ViewProp(NULL, kRootWindowHostWinKey, this)); | 164 prop_.reset(new ui::ViewProp(NULL, kWindowTreeHostWinKey, this)); |
165 CreateCompositor(GetAcceleratedWidget()); | 165 CreateCompositor(GetAcceleratedWidget()); |
166 } | 166 } |
167 | 167 |
168 RemoteRootWindowHostWin::~RemoteRootWindowHostWin() { | 168 RemoteWindowTreeHostWin::~RemoteWindowTreeHostWin() { |
169 g_instance = NULL; | 169 g_instance = NULL; |
170 } | 170 } |
171 | 171 |
172 void RemoteRootWindowHostWin::Connected(IPC::Sender* host, HWND remote_window) { | 172 void RemoteWindowTreeHostWin::Connected(IPC::Sender* host, HWND remote_window) { |
173 CHECK(host_ == NULL); | 173 CHECK(host_ == NULL); |
174 host_ = host; | 174 host_ = host; |
175 remote_window_ = remote_window; | 175 remote_window_ = remote_window; |
176 } | 176 } |
177 | 177 |
178 void RemoteRootWindowHostWin::Disconnected() { | 178 void RemoteWindowTreeHostWin::Disconnected() { |
179 // Don't CHECK here, Disconnected is called on a channel error which can | 179 // Don't CHECK here, Disconnected is called on a channel error which can |
180 // happen before we're successfully Connected. | 180 // happen before we're successfully Connected. |
181 if (!host_) | 181 if (!host_) |
182 return; | 182 return; |
183 ui::RemoteInputMethodPrivateWin* remote_input_method_private = | 183 ui::RemoteInputMethodPrivateWin* remote_input_method_private = |
184 GetRemoteInputMethodPrivate(); | 184 GetRemoteInputMethodPrivate(); |
185 if (remote_input_method_private) | 185 if (remote_input_method_private) |
186 remote_input_method_private->SetRemoteDelegate(NULL); | 186 remote_input_method_private->SetRemoteDelegate(NULL); |
187 host_ = NULL; | 187 host_ = NULL; |
188 remote_window_ = NULL; | 188 remote_window_ = NULL; |
189 } | 189 } |
190 | 190 |
191 bool RemoteRootWindowHostWin::OnMessageReceived(const IPC::Message& message) { | 191 bool RemoteWindowTreeHostWin::OnMessageReceived(const IPC::Message& message) { |
192 bool handled = true; | 192 bool handled = true; |
193 IPC_BEGIN_MESSAGE_MAP(RemoteRootWindowHostWin, message) | 193 IPC_BEGIN_MESSAGE_MAP(RemoteWindowTreeHostWin, message) |
194 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseMoved, OnMouseMoved) | 194 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseMoved, OnMouseMoved) |
195 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseButton, OnMouseButton) | 195 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_MouseButton, OnMouseButton) |
196 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyDown, OnKeyDown) | 196 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyDown, OnKeyDown) |
197 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyUp, OnKeyUp) | 197 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_KeyUp, OnKeyUp) |
198 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_Character, OnChar) | 198 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_Character, OnChar) |
199 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_WindowActivated, | 199 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_WindowActivated, |
200 OnWindowActivated) | 200 OnWindowActivated) |
201 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_TouchDown, | 201 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_TouchDown, |
202 OnTouchDown) | 202 OnTouchDown) |
203 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_TouchUp, | 203 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_TouchUp, |
(...skipping 16 matching lines...) Expand all Loading... |
220 OnImeCompositionChanged) | 220 OnImeCompositionChanged) |
221 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ImeTextCommitted, | 221 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ImeTextCommitted, |
222 OnImeTextCommitted) | 222 OnImeTextCommitted) |
223 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ImeInputSourceChanged, | 223 IPC_MESSAGE_HANDLER(MetroViewerHostMsg_ImeInputSourceChanged, |
224 OnImeInputSourceChanged) | 224 OnImeInputSourceChanged) |
225 IPC_MESSAGE_UNHANDLED(handled = false) | 225 IPC_MESSAGE_UNHANDLED(handled = false) |
226 IPC_END_MESSAGE_MAP() | 226 IPC_END_MESSAGE_MAP() |
227 return handled; | 227 return handled; |
228 } | 228 } |
229 | 229 |
230 void RemoteRootWindowHostWin::HandleOpenURLOnDesktop( | 230 void RemoteWindowTreeHostWin::HandleOpenURLOnDesktop( |
231 const base::FilePath& shortcut, | 231 const base::FilePath& shortcut, |
232 const base::string16& url) { | 232 const base::string16& url) { |
233 if (!host_) | 233 if (!host_) |
234 return; | 234 return; |
235 host_->Send(new MetroViewerHostMsg_OpenURLOnDesktop(shortcut, url)); | 235 host_->Send(new MetroViewerHostMsg_OpenURLOnDesktop(shortcut, url)); |
236 } | 236 } |
237 | 237 |
238 void RemoteRootWindowHostWin::HandleActivateDesktop( | 238 void RemoteWindowTreeHostWin::HandleActivateDesktop( |
239 const base::FilePath& shortcut, | 239 const base::FilePath& shortcut, |
240 bool ash_exit) { | 240 bool ash_exit) { |
241 if (!host_) | 241 if (!host_) |
242 return; | 242 return; |
243 host_->Send(new MetroViewerHostMsg_ActivateDesktop(shortcut, ash_exit)); | 243 host_->Send(new MetroViewerHostMsg_ActivateDesktop(shortcut, ash_exit)); |
244 } | 244 } |
245 | 245 |
246 void RemoteRootWindowHostWin::HandleOpenFile( | 246 void RemoteWindowTreeHostWin::HandleOpenFile( |
247 const base::string16& title, | 247 const base::string16& title, |
248 const base::FilePath& default_path, | 248 const base::FilePath& default_path, |
249 const base::string16& filter, | 249 const base::string16& filter, |
250 const OpenFileCompletion& on_success, | 250 const OpenFileCompletion& on_success, |
251 const FileSelectionCanceled& on_failure) { | 251 const FileSelectionCanceled& on_failure) { |
252 if (!host_) | 252 if (!host_) |
253 return; | 253 return; |
254 | 254 |
255 // Can only have one of these operations in flight. | 255 // Can only have one of these operations in flight. |
256 DCHECK(file_open_completion_callback_.is_null()); | 256 DCHECK(file_open_completion_callback_.is_null()); |
257 DCHECK(failure_callback_.is_null()); | 257 DCHECK(failure_callback_.is_null()); |
258 | 258 |
259 file_open_completion_callback_ = on_success; | 259 file_open_completion_callback_ = on_success; |
260 failure_callback_ = on_failure; | 260 failure_callback_ = on_failure; |
261 | 261 |
262 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, | 262 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, |
263 filter, | 263 filter, |
264 default_path, | 264 default_path, |
265 false)); | 265 false)); |
266 } | 266 } |
267 | 267 |
268 void RemoteRootWindowHostWin::HandleOpenMultipleFiles( | 268 void RemoteWindowTreeHostWin::HandleOpenMultipleFiles( |
269 const base::string16& title, | 269 const base::string16& title, |
270 const base::FilePath& default_path, | 270 const base::FilePath& default_path, |
271 const base::string16& filter, | 271 const base::string16& filter, |
272 const OpenMultipleFilesCompletion& on_success, | 272 const OpenMultipleFilesCompletion& on_success, |
273 const FileSelectionCanceled& on_failure) { | 273 const FileSelectionCanceled& on_failure) { |
274 if (!host_) | 274 if (!host_) |
275 return; | 275 return; |
276 | 276 |
277 // Can only have one of these operations in flight. | 277 // Can only have one of these operations in flight. |
278 DCHECK(multi_file_open_completion_callback_.is_null()); | 278 DCHECK(multi_file_open_completion_callback_.is_null()); |
279 DCHECK(failure_callback_.is_null()); | 279 DCHECK(failure_callback_.is_null()); |
280 multi_file_open_completion_callback_ = on_success; | 280 multi_file_open_completion_callback_ = on_success; |
281 failure_callback_ = on_failure; | 281 failure_callback_ = on_failure; |
282 | 282 |
283 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, | 283 host_->Send(new MetroViewerHostMsg_DisplayFileOpen(title, |
284 filter, | 284 filter, |
285 default_path, | 285 default_path, |
286 true)); | 286 true)); |
287 } | 287 } |
288 | 288 |
289 void RemoteRootWindowHostWin::HandleSaveFile( | 289 void RemoteWindowTreeHostWin::HandleSaveFile( |
290 const base::string16& title, | 290 const base::string16& title, |
291 const base::FilePath& default_path, | 291 const base::FilePath& default_path, |
292 const base::string16& filter, | 292 const base::string16& filter, |
293 int filter_index, | 293 int filter_index, |
294 const base::string16& default_extension, | 294 const base::string16& default_extension, |
295 const SaveFileCompletion& on_success, | 295 const SaveFileCompletion& on_success, |
296 const FileSelectionCanceled& on_failure) { | 296 const FileSelectionCanceled& on_failure) { |
297 if (!host_) | 297 if (!host_) |
298 return; | 298 return; |
299 | 299 |
300 MetroViewerHostMsg_SaveAsDialogParams params; | 300 MetroViewerHostMsg_SaveAsDialogParams params; |
301 params.title = title; | 301 params.title = title; |
302 params.default_extension = default_extension; | 302 params.default_extension = default_extension; |
303 params.filter = filter; | 303 params.filter = filter; |
304 params.filter_index = filter_index; | 304 params.filter_index = filter_index; |
305 params.suggested_name = default_path; | 305 params.suggested_name = default_path; |
306 | 306 |
307 // Can only have one of these operations in flight. | 307 // Can only have one of these operations in flight. |
308 DCHECK(file_saveas_completion_callback_.is_null()); | 308 DCHECK(file_saveas_completion_callback_.is_null()); |
309 DCHECK(failure_callback_.is_null()); | 309 DCHECK(failure_callback_.is_null()); |
310 file_saveas_completion_callback_ = on_success; | 310 file_saveas_completion_callback_ = on_success; |
311 failure_callback_ = on_failure; | 311 failure_callback_ = on_failure; |
312 | 312 |
313 host_->Send(new MetroViewerHostMsg_DisplayFileSaveAs(params)); | 313 host_->Send(new MetroViewerHostMsg_DisplayFileSaveAs(params)); |
314 } | 314 } |
315 | 315 |
316 void RemoteRootWindowHostWin::HandleSelectFolder( | 316 void RemoteWindowTreeHostWin::HandleSelectFolder( |
317 const base::string16& title, | 317 const base::string16& title, |
318 const SelectFolderCompletion& on_success, | 318 const SelectFolderCompletion& on_success, |
319 const FileSelectionCanceled& on_failure) { | 319 const FileSelectionCanceled& on_failure) { |
320 if (!host_) | 320 if (!host_) |
321 return; | 321 return; |
322 | 322 |
323 // Can only have one of these operations in flight. | 323 // Can only have one of these operations in flight. |
324 DCHECK(select_folder_completion_callback_.is_null()); | 324 DCHECK(select_folder_completion_callback_.is_null()); |
325 DCHECK(failure_callback_.is_null()); | 325 DCHECK(failure_callback_.is_null()); |
326 select_folder_completion_callback_ = on_success; | 326 select_folder_completion_callback_ = on_success; |
327 failure_callback_ = on_failure; | 327 failure_callback_ = on_failure; |
328 | 328 |
329 host_->Send(new MetroViewerHostMsg_DisplaySelectFolder(title)); | 329 host_->Send(new MetroViewerHostMsg_DisplaySelectFolder(title)); |
330 } | 330 } |
331 | 331 |
332 void RemoteRootWindowHostWin::HandleWindowSizeChanged(uint32 width, | 332 void RemoteWindowTreeHostWin::HandleWindowSizeChanged(uint32 width, |
333 uint32 height) { | 333 uint32 height) { |
334 SetBounds(gfx::Rect(0, 0, width, height)); | 334 SetBounds(gfx::Rect(0, 0, width, height)); |
335 } | 335 } |
336 | 336 |
337 bool RemoteRootWindowHostWin::IsForegroundWindow() { | 337 bool RemoteWindowTreeHostWin::IsForegroundWindow() { |
338 return ::GetForegroundWindow() == remote_window_; | 338 return ::GetForegroundWindow() == remote_window_; |
339 } | 339 } |
340 | 340 |
341 Window* RemoteRootWindowHostWin::GetAshWindow() { | 341 Window* RemoteWindowTreeHostWin::GetAshWindow() { |
342 return GetRootWindow()->window(); | 342 return GetRootWindow()->window(); |
343 } | 343 } |
344 | 344 |
345 RootWindow* RemoteRootWindowHostWin::GetRootWindow() { | 345 RootWindow* RemoteWindowTreeHostWin::GetRootWindow() { |
346 return delegate_->AsRootWindow(); | 346 return delegate_->AsRootWindow(); |
347 } | 347 } |
348 | 348 |
349 gfx::AcceleratedWidget RemoteRootWindowHostWin::GetAcceleratedWidget() { | 349 gfx::AcceleratedWidget RemoteWindowTreeHostWin::GetAcceleratedWidget() { |
350 if (remote_window_) | 350 if (remote_window_) |
351 return remote_window_; | 351 return remote_window_; |
352 // Getting here should only happen for ash_unittests.exe and related code. | 352 // Getting here should only happen for ash_unittests.exe and related code. |
353 return ::GetDesktopWindow(); | 353 return ::GetDesktopWindow(); |
354 } | 354 } |
355 | 355 |
356 void RemoteRootWindowHostWin::Show() { | 356 void RemoteWindowTreeHostWin::Show() { |
357 ui::RemoteInputMethodPrivateWin* remote_input_method_private = | 357 ui::RemoteInputMethodPrivateWin* remote_input_method_private = |
358 GetRemoteInputMethodPrivate(); | 358 GetRemoteInputMethodPrivate(); |
359 if (remote_input_method_private) | 359 if (remote_input_method_private) |
360 remote_input_method_private->SetRemoteDelegate(this); | 360 remote_input_method_private->SetRemoteDelegate(this); |
361 } | 361 } |
362 | 362 |
363 void RemoteRootWindowHostWin::Hide() { | 363 void RemoteWindowTreeHostWin::Hide() { |
364 NOTIMPLEMENTED(); | 364 NOTIMPLEMENTED(); |
365 } | 365 } |
366 | 366 |
367 void RemoteRootWindowHostWin::ToggleFullScreen() { | 367 void RemoteWindowTreeHostWin::ToggleFullScreen() { |
368 } | 368 } |
369 | 369 |
370 gfx::Rect RemoteRootWindowHostWin::GetBounds() const { | 370 gfx::Rect RemoteWindowTreeHostWin::GetBounds() const { |
371 return gfx::Rect(window_size_); | 371 return gfx::Rect(window_size_); |
372 } | 372 } |
373 | 373 |
374 void RemoteRootWindowHostWin::SetBounds(const gfx::Rect& bounds) { | 374 void RemoteWindowTreeHostWin::SetBounds(const gfx::Rect& bounds) { |
375 window_size_ = bounds.size(); | 375 window_size_ = bounds.size(); |
376 NotifyHostResized(bounds.size()); | 376 NotifyHostResized(bounds.size()); |
377 } | 377 } |
378 | 378 |
379 gfx::Insets RemoteRootWindowHostWin::GetInsets() const { | 379 gfx::Insets RemoteWindowTreeHostWin::GetInsets() const { |
380 return gfx::Insets(); | 380 return gfx::Insets(); |
381 } | 381 } |
382 | 382 |
383 void RemoteRootWindowHostWin::SetInsets(const gfx::Insets& insets) { | 383 void RemoteWindowTreeHostWin::SetInsets(const gfx::Insets& insets) { |
384 } | 384 } |
385 | 385 |
386 gfx::Point RemoteRootWindowHostWin::GetLocationOnNativeScreen() const { | 386 gfx::Point RemoteWindowTreeHostWin::GetLocationOnNativeScreen() const { |
387 return gfx::Point(0, 0); | 387 return gfx::Point(0, 0); |
388 } | 388 } |
389 | 389 |
390 void RemoteRootWindowHostWin::SetCursor(gfx::NativeCursor native_cursor) { | 390 void RemoteWindowTreeHostWin::SetCursor(gfx::NativeCursor native_cursor) { |
391 if (!host_) | 391 if (!host_) |
392 return; | 392 return; |
393 host_->Send( | 393 host_->Send( |
394 new MetroViewerHostMsg_SetCursor(uint64(native_cursor.platform()))); | 394 new MetroViewerHostMsg_SetCursor(uint64(native_cursor.platform()))); |
395 } | 395 } |
396 | 396 |
397 void RemoteRootWindowHostWin::SetCapture() { | 397 void RemoteWindowTreeHostWin::SetCapture() { |
398 } | 398 } |
399 | 399 |
400 void RemoteRootWindowHostWin::ReleaseCapture() { | 400 void RemoteWindowTreeHostWin::ReleaseCapture() { |
401 } | 401 } |
402 | 402 |
403 bool RemoteRootWindowHostWin::QueryMouseLocation(gfx::Point* location_return) { | 403 bool RemoteWindowTreeHostWin::QueryMouseLocation(gfx::Point* location_return) { |
404 aura::client::CursorClient* cursor_client = | 404 aura::client::CursorClient* cursor_client = |
405 aura::client::GetCursorClient(GetRootWindow()->window()); | 405 aura::client::GetCursorClient(GetRootWindow()->window()); |
406 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) { | 406 if (cursor_client && !cursor_client->IsMouseEventsEnabled()) { |
407 *location_return = gfx::Point(0, 0); | 407 *location_return = gfx::Point(0, 0); |
408 return false; | 408 return false; |
409 } | 409 } |
410 POINT pt; | 410 POINT pt; |
411 GetCursorPos(&pt); | 411 GetCursorPos(&pt); |
412 *location_return = | 412 *location_return = |
413 gfx::Point(static_cast<int>(pt.x), static_cast<int>(pt.y)); | 413 gfx::Point(static_cast<int>(pt.x), static_cast<int>(pt.y)); |
414 return true; | 414 return true; |
415 } | 415 } |
416 | 416 |
417 bool RemoteRootWindowHostWin::ConfineCursorToRootWindow() { | 417 bool RemoteWindowTreeHostWin::ConfineCursorToRootWindow() { |
418 return true; | 418 return true; |
419 } | 419 } |
420 | 420 |
421 void RemoteRootWindowHostWin::UnConfineCursor() { | 421 void RemoteWindowTreeHostWin::UnConfineCursor() { |
422 } | 422 } |
423 | 423 |
424 void RemoteRootWindowHostWin::OnCursorVisibilityChanged(bool show) { | 424 void RemoteWindowTreeHostWin::OnCursorVisibilityChanged(bool show) { |
425 NOTIMPLEMENTED(); | 425 NOTIMPLEMENTED(); |
426 } | 426 } |
427 | 427 |
428 void RemoteRootWindowHostWin::MoveCursorTo(const gfx::Point& location) { | 428 void RemoteWindowTreeHostWin::MoveCursorTo(const gfx::Point& location) { |
429 VLOG(1) << "In MoveCursorTo: " << location.x() << ", " << location.y(); | 429 VLOG(1) << "In MoveCursorTo: " << location.x() << ", " << location.y(); |
430 if (!host_) | 430 if (!host_) |
431 return; | 431 return; |
432 | 432 |
433 // This function can be called in cases like when the mouse cursor is | 433 // This function can be called in cases like when the mouse cursor is |
434 // restricted within a viewport (For e.g. LockCursor) which assumes that | 434 // restricted within a viewport (For e.g. LockCursor) which assumes that |
435 // subsequent mouse moves would be received starting with the new cursor | 435 // subsequent mouse moves would be received starting with the new cursor |
436 // coordinates. This is a challenge for Windows ASH for the reasons | 436 // coordinates. This is a challenge for Windows ASH for the reasons |
437 // outlined below. | 437 // outlined below. |
438 // Other cases which don't expect this behavior should continue to work | 438 // Other cases which don't expect this behavior should continue to work |
439 // without issues. | 439 // without issues. |
440 | 440 |
441 // The mouse events are received by the viewer process and sent to the | 441 // The mouse events are received by the viewer process and sent to the |
442 // browser. If we invoke the SetCursor API here we continue to receive | 442 // browser. If we invoke the SetCursor API here we continue to receive |
443 // mouse messages from the viewer which were posted before the SetCursor | 443 // mouse messages from the viewer which were posted before the SetCursor |
444 // API executes which messes up the state in the browser. To workaround | 444 // API executes which messes up the state in the browser. To workaround |
445 // this we invoke the SetCursor API in the viewer process and ignore | 445 // this we invoke the SetCursor API in the viewer process and ignore |
446 // mouse messages until we received an ACK from the viewer indicating that | 446 // mouse messages until we received an ACK from the viewer indicating that |
447 // the SetCursor operation completed. | 447 // the SetCursor operation completed. |
448 ignore_mouse_moves_until_set_cursor_ack_ = true; | 448 ignore_mouse_moves_until_set_cursor_ack_ = true; |
449 VLOG(1) << "In MoveCursorTo. Sending IPC"; | 449 VLOG(1) << "In MoveCursorTo. Sending IPC"; |
450 host_->Send(new MetroViewerHostMsg_SetCursorPos(location.x(), location.y())); | 450 host_->Send(new MetroViewerHostMsg_SetCursorPos(location.x(), location.y())); |
451 } | 451 } |
452 | 452 |
453 void RemoteRootWindowHostWin::PostNativeEvent( | 453 void RemoteWindowTreeHostWin::PostNativeEvent( |
454 const base::NativeEvent& native_event) { | 454 const base::NativeEvent& native_event) { |
455 } | 455 } |
456 | 456 |
457 void RemoteRootWindowHostWin::OnDeviceScaleFactorChanged( | 457 void RemoteWindowTreeHostWin::OnDeviceScaleFactorChanged( |
458 float device_scale_factor) { | 458 float device_scale_factor) { |
459 NOTIMPLEMENTED(); | 459 NOTIMPLEMENTED(); |
460 } | 460 } |
461 | 461 |
462 void RemoteRootWindowHostWin::PrepareForShutdown() { | 462 void RemoteWindowTreeHostWin::PrepareForShutdown() { |
463 } | 463 } |
464 | 464 |
465 void RemoteRootWindowHostWin::CancelComposition() { | 465 void RemoteWindowTreeHostWin::CancelComposition() { |
466 host_->Send(new MetroViewerHostMsg_ImeCancelComposition); | 466 host_->Send(new MetroViewerHostMsg_ImeCancelComposition); |
467 } | 467 } |
468 | 468 |
469 void RemoteRootWindowHostWin::OnTextInputClientUpdated( | 469 void RemoteWindowTreeHostWin::OnTextInputClientUpdated( |
470 const std::vector<int32>& input_scopes, | 470 const std::vector<int32>& input_scopes, |
471 const std::vector<gfx::Rect>& composition_character_bounds) { | 471 const std::vector<gfx::Rect>& composition_character_bounds) { |
472 std::vector<metro_viewer::CharacterBounds> character_bounds; | 472 std::vector<metro_viewer::CharacterBounds> character_bounds; |
473 for (size_t i = 0; i < composition_character_bounds.size(); ++i) { | 473 for (size_t i = 0; i < composition_character_bounds.size(); ++i) { |
474 const gfx::Rect& rect = composition_character_bounds[i]; | 474 const gfx::Rect& rect = composition_character_bounds[i]; |
475 metro_viewer::CharacterBounds bounds; | 475 metro_viewer::CharacterBounds bounds; |
476 bounds.left = rect.x(); | 476 bounds.left = rect.x(); |
477 bounds.top = rect.y(); | 477 bounds.top = rect.y(); |
478 bounds.right = rect.right(); | 478 bounds.right = rect.right(); |
479 bounds.bottom = rect.bottom(); | 479 bounds.bottom = rect.bottom(); |
480 character_bounds.push_back(bounds); | 480 character_bounds.push_back(bounds); |
481 } | 481 } |
482 host_->Send(new MetroViewerHostMsg_ImeTextInputClientUpdated( | 482 host_->Send(new MetroViewerHostMsg_ImeTextInputClientUpdated( |
483 input_scopes, character_bounds)); | 483 input_scopes, character_bounds)); |
484 } | 484 } |
485 | 485 |
486 void RemoteRootWindowHostWin::OnMouseMoved(int32 x, int32 y, int32 flags) { | 486 void RemoteWindowTreeHostWin::OnMouseMoved(int32 x, int32 y, int32 flags) { |
487 if (ignore_mouse_moves_until_set_cursor_ack_) | 487 if (ignore_mouse_moves_until_set_cursor_ack_) |
488 return; | 488 return; |
489 | 489 |
490 gfx::Point location(x, y); | 490 gfx::Point location(x, y); |
491 ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, flags, 0); | 491 ui::MouseEvent event(ui::ET_MOUSE_MOVED, location, location, flags, 0); |
492 delegate_->OnHostMouseEvent(&event); | 492 delegate_->OnHostMouseEvent(&event); |
493 } | 493 } |
494 | 494 |
495 void RemoteRootWindowHostWin::OnMouseButton( | 495 void RemoteWindowTreeHostWin::OnMouseButton( |
496 const MetroViewerHostMsg_MouseButtonParams& params) { | 496 const MetroViewerHostMsg_MouseButtonParams& params) { |
497 gfx::Point location(params.x, params.y); | 497 gfx::Point location(params.x, params.y); |
498 ui::MouseEvent mouse_event(params.event_type, location, location, | 498 ui::MouseEvent mouse_event(params.event_type, location, location, |
499 static_cast<int>(params.flags), | 499 static_cast<int>(params.flags), |
500 static_cast<int>(params.changed_button)); | 500 static_cast<int>(params.changed_button)); |
501 | 501 |
502 SetEventFlags(params.flags | key_event_flags()); | 502 SetEventFlags(params.flags | key_event_flags()); |
503 if (params.event_type == ui::ET_MOUSEWHEEL) { | 503 if (params.event_type == ui::ET_MOUSEWHEEL) { |
504 ui::MouseWheelEvent wheel_event(mouse_event, 0, params.extra); | 504 ui::MouseWheelEvent wheel_event(mouse_event, 0, params.extra); |
505 delegate_->OnHostMouseEvent(&wheel_event); | 505 delegate_->OnHostMouseEvent(&wheel_event); |
(...skipping 11 matching lines...) Expand all Loading... |
517 } else { | 517 } else { |
518 mouse_event.SetClickCount(1); | 518 mouse_event.SetClickCount(1); |
519 } | 519 } |
520 last_mouse_click_event_ .reset(new ui::MouseEvent(mouse_event)); | 520 last_mouse_click_event_ .reset(new ui::MouseEvent(mouse_event)); |
521 delegate_->OnHostMouseEvent(&mouse_event); | 521 delegate_->OnHostMouseEvent(&mouse_event); |
522 } else { | 522 } else { |
523 delegate_->OnHostMouseEvent(&mouse_event); | 523 delegate_->OnHostMouseEvent(&mouse_event); |
524 } | 524 } |
525 } | 525 } |
526 | 526 |
527 void RemoteRootWindowHostWin::OnKeyDown(uint32 vkey, | 527 void RemoteWindowTreeHostWin::OnKeyDown(uint32 vkey, |
528 uint32 repeat_count, | 528 uint32 repeat_count, |
529 uint32 scan_code, | 529 uint32 scan_code, |
530 uint32 flags) { | 530 uint32 flags) { |
531 DispatchKeyboardMessage(ui::ET_KEY_PRESSED, vkey, repeat_count, scan_code, | 531 DispatchKeyboardMessage(ui::ET_KEY_PRESSED, vkey, repeat_count, scan_code, |
532 flags, false); | 532 flags, false); |
533 } | 533 } |
534 | 534 |
535 void RemoteRootWindowHostWin::OnKeyUp(uint32 vkey, | 535 void RemoteWindowTreeHostWin::OnKeyUp(uint32 vkey, |
536 uint32 repeat_count, | 536 uint32 repeat_count, |
537 uint32 scan_code, | 537 uint32 scan_code, |
538 uint32 flags) { | 538 uint32 flags) { |
539 DispatchKeyboardMessage(ui::ET_KEY_RELEASED, vkey, repeat_count, scan_code, | 539 DispatchKeyboardMessage(ui::ET_KEY_RELEASED, vkey, repeat_count, scan_code, |
540 flags, false); | 540 flags, false); |
541 } | 541 } |
542 | 542 |
543 void RemoteRootWindowHostWin::OnChar(uint32 key_code, | 543 void RemoteWindowTreeHostWin::OnChar(uint32 key_code, |
544 uint32 repeat_count, | 544 uint32 repeat_count, |
545 uint32 scan_code, | 545 uint32 scan_code, |
546 uint32 flags) { | 546 uint32 flags) { |
547 DispatchKeyboardMessage(ui::ET_KEY_PRESSED, key_code, repeat_count, | 547 DispatchKeyboardMessage(ui::ET_KEY_PRESSED, key_code, repeat_count, |
548 scan_code, flags, true); | 548 scan_code, flags, true); |
549 } | 549 } |
550 | 550 |
551 void RemoteRootWindowHostWin::OnWindowActivated() { | 551 void RemoteWindowTreeHostWin::OnWindowActivated() { |
552 delegate_->OnHostActivated(); | 552 delegate_->OnHostActivated(); |
553 } | 553 } |
554 | 554 |
555 void RemoteRootWindowHostWin::OnTouchDown(int32 x, | 555 void RemoteWindowTreeHostWin::OnTouchDown(int32 x, |
556 int32 y, | 556 int32 y, |
557 uint64 timestamp, | 557 uint64 timestamp, |
558 uint32 pointer_id) { | 558 uint32 pointer_id) { |
559 ui::TouchEvent event(ui::ET_TOUCH_PRESSED, | 559 ui::TouchEvent event(ui::ET_TOUCH_PRESSED, |
560 gfx::Point(x, y), | 560 gfx::Point(x, y), |
561 pointer_id, | 561 pointer_id, |
562 base::TimeDelta::FromMicroseconds(timestamp)); | 562 base::TimeDelta::FromMicroseconds(timestamp)); |
563 delegate_->OnHostTouchEvent(&event); | 563 delegate_->OnHostTouchEvent(&event); |
564 } | 564 } |
565 | 565 |
566 void RemoteRootWindowHostWin::OnTouchUp(int32 x, | 566 void RemoteWindowTreeHostWin::OnTouchUp(int32 x, |
567 int32 y, | 567 int32 y, |
568 uint64 timestamp, | 568 uint64 timestamp, |
569 uint32 pointer_id) { | 569 uint32 pointer_id) { |
570 ui::TouchEvent event(ui::ET_TOUCH_RELEASED, | 570 ui::TouchEvent event(ui::ET_TOUCH_RELEASED, |
571 gfx::Point(x, y), | 571 gfx::Point(x, y), |
572 pointer_id, | 572 pointer_id, |
573 base::TimeDelta::FromMicroseconds(timestamp)); | 573 base::TimeDelta::FromMicroseconds(timestamp)); |
574 delegate_->OnHostTouchEvent(&event); | 574 delegate_->OnHostTouchEvent(&event); |
575 } | 575 } |
576 | 576 |
577 void RemoteRootWindowHostWin::OnTouchMoved(int32 x, | 577 void RemoteWindowTreeHostWin::OnTouchMoved(int32 x, |
578 int32 y, | 578 int32 y, |
579 uint64 timestamp, | 579 uint64 timestamp, |
580 uint32 pointer_id) { | 580 uint32 pointer_id) { |
581 ui::TouchEvent event(ui::ET_TOUCH_MOVED, | 581 ui::TouchEvent event(ui::ET_TOUCH_MOVED, |
582 gfx::Point(x, y), | 582 gfx::Point(x, y), |
583 pointer_id, | 583 pointer_id, |
584 base::TimeDelta::FromMicroseconds(timestamp)); | 584 base::TimeDelta::FromMicroseconds(timestamp)); |
585 delegate_->OnHostTouchEvent(&event); | 585 delegate_->OnHostTouchEvent(&event); |
586 } | 586 } |
587 | 587 |
588 void RemoteRootWindowHostWin::OnFileSaveAsDone(bool success, | 588 void RemoteWindowTreeHostWin::OnFileSaveAsDone(bool success, |
589 const base::FilePath& filename, | 589 const base::FilePath& filename, |
590 int filter_index) { | 590 int filter_index) { |
591 if (success) | 591 if (success) |
592 file_saveas_completion_callback_.Run(filename, filter_index, NULL); | 592 file_saveas_completion_callback_.Run(filename, filter_index, NULL); |
593 else | 593 else |
594 failure_callback_.Run(NULL); | 594 failure_callback_.Run(NULL); |
595 file_saveas_completion_callback_.Reset(); | 595 file_saveas_completion_callback_.Reset(); |
596 failure_callback_.Reset(); | 596 failure_callback_.Reset(); |
597 } | 597 } |
598 | 598 |
599 | 599 |
600 void RemoteRootWindowHostWin::OnFileOpenDone(bool success, | 600 void RemoteWindowTreeHostWin::OnFileOpenDone(bool success, |
601 const base::FilePath& filename) { | 601 const base::FilePath& filename) { |
602 if (success) | 602 if (success) |
603 file_open_completion_callback_.Run(base::FilePath(filename), 0, NULL); | 603 file_open_completion_callback_.Run(base::FilePath(filename), 0, NULL); |
604 else | 604 else |
605 failure_callback_.Run(NULL); | 605 failure_callback_.Run(NULL); |
606 file_open_completion_callback_.Reset(); | 606 file_open_completion_callback_.Reset(); |
607 failure_callback_.Reset(); | 607 failure_callback_.Reset(); |
608 } | 608 } |
609 | 609 |
610 void RemoteRootWindowHostWin::OnMultiFileOpenDone( | 610 void RemoteWindowTreeHostWin::OnMultiFileOpenDone( |
611 bool success, | 611 bool success, |
612 const std::vector<base::FilePath>& files) { | 612 const std::vector<base::FilePath>& files) { |
613 if (success) | 613 if (success) |
614 multi_file_open_completion_callback_.Run(files, NULL); | 614 multi_file_open_completion_callback_.Run(files, NULL); |
615 else | 615 else |
616 failure_callback_.Run(NULL); | 616 failure_callback_.Run(NULL); |
617 multi_file_open_completion_callback_.Reset(); | 617 multi_file_open_completion_callback_.Reset(); |
618 failure_callback_.Reset(); | 618 failure_callback_.Reset(); |
619 } | 619 } |
620 | 620 |
621 void RemoteRootWindowHostWin::OnSelectFolderDone( | 621 void RemoteWindowTreeHostWin::OnSelectFolderDone( |
622 bool success, | 622 bool success, |
623 const base::FilePath& folder) { | 623 const base::FilePath& folder) { |
624 if (success) | 624 if (success) |
625 select_folder_completion_callback_.Run(base::FilePath(folder), 0, NULL); | 625 select_folder_completion_callback_.Run(base::FilePath(folder), 0, NULL); |
626 else | 626 else |
627 failure_callback_.Run(NULL); | 627 failure_callback_.Run(NULL); |
628 select_folder_completion_callback_.Reset(); | 628 select_folder_completion_callback_.Reset(); |
629 failure_callback_.Reset(); | 629 failure_callback_.Reset(); |
630 } | 630 } |
631 | 631 |
632 void RemoteRootWindowHostWin::OnSetCursorPosAck() { | 632 void RemoteWindowTreeHostWin::OnSetCursorPosAck() { |
633 DCHECK(ignore_mouse_moves_until_set_cursor_ack_); | 633 DCHECK(ignore_mouse_moves_until_set_cursor_ack_); |
634 ignore_mouse_moves_until_set_cursor_ack_ = false; | 634 ignore_mouse_moves_until_set_cursor_ack_ = false; |
635 } | 635 } |
636 | 636 |
637 ui::RemoteInputMethodPrivateWin* | 637 ui::RemoteInputMethodPrivateWin* |
638 RemoteRootWindowHostWin::GetRemoteInputMethodPrivate() { | 638 RemoteWindowTreeHostWin::GetRemoteInputMethodPrivate() { |
639 ui::InputMethod* input_method = GetAshWindow()->GetProperty( | 639 ui::InputMethod* input_method = GetAshWindow()->GetProperty( |
640 aura::client::kRootWindowInputMethodKey); | 640 aura::client::kRootWindowInputMethodKey); |
641 return ui::RemoteInputMethodPrivateWin::Get(input_method); | 641 return ui::RemoteInputMethodPrivateWin::Get(input_method); |
642 } | 642 } |
643 | 643 |
644 void RemoteRootWindowHostWin::OnImeCandidatePopupChanged(bool visible) { | 644 void RemoteWindowTreeHostWin::OnImeCandidatePopupChanged(bool visible) { |
645 ui::RemoteInputMethodPrivateWin* remote_input_method_private = | 645 ui::RemoteInputMethodPrivateWin* remote_input_method_private = |
646 GetRemoteInputMethodPrivate(); | 646 GetRemoteInputMethodPrivate(); |
647 if (!remote_input_method_private) | 647 if (!remote_input_method_private) |
648 return; | 648 return; |
649 remote_input_method_private->OnCandidatePopupChanged(visible); | 649 remote_input_method_private->OnCandidatePopupChanged(visible); |
650 } | 650 } |
651 | 651 |
652 void RemoteRootWindowHostWin::OnImeCompositionChanged( | 652 void RemoteWindowTreeHostWin::OnImeCompositionChanged( |
653 const base::string16& text, | 653 const base::string16& text, |
654 int32 selection_start, | 654 int32 selection_start, |
655 int32 selection_end, | 655 int32 selection_end, |
656 const std::vector<metro_viewer::UnderlineInfo>& underlines) { | 656 const std::vector<metro_viewer::UnderlineInfo>& underlines) { |
657 ui::RemoteInputMethodPrivateWin* remote_input_method_private = | 657 ui::RemoteInputMethodPrivateWin* remote_input_method_private = |
658 GetRemoteInputMethodPrivate(); | 658 GetRemoteInputMethodPrivate(); |
659 if (!remote_input_method_private) | 659 if (!remote_input_method_private) |
660 return; | 660 return; |
661 ui::CompositionText composition_text; | 661 ui::CompositionText composition_text; |
662 FillCompositionText( | 662 FillCompositionText( |
663 text, selection_start, selection_end, underlines, &composition_text); | 663 text, selection_start, selection_end, underlines, &composition_text); |
664 remote_input_method_private->OnCompositionChanged(composition_text); | 664 remote_input_method_private->OnCompositionChanged(composition_text); |
665 } | 665 } |
666 | 666 |
667 void RemoteRootWindowHostWin::OnImeTextCommitted(const base::string16& text) { | 667 void RemoteWindowTreeHostWin::OnImeTextCommitted(const base::string16& text) { |
668 ui::RemoteInputMethodPrivateWin* remote_input_method_private = | 668 ui::RemoteInputMethodPrivateWin* remote_input_method_private = |
669 GetRemoteInputMethodPrivate(); | 669 GetRemoteInputMethodPrivate(); |
670 if (!remote_input_method_private) | 670 if (!remote_input_method_private) |
671 return; | 671 return; |
672 remote_input_method_private->OnTextCommitted(text); | 672 remote_input_method_private->OnTextCommitted(text); |
673 } | 673 } |
674 | 674 |
675 void RemoteRootWindowHostWin::OnImeInputSourceChanged(uint16 language_id, | 675 void RemoteWindowTreeHostWin::OnImeInputSourceChanged(uint16 language_id, |
676 bool is_ime) { | 676 bool is_ime) { |
677 ui::RemoteInputMethodPrivateWin* remote_input_method_private = | 677 ui::RemoteInputMethodPrivateWin* remote_input_method_private = |
678 GetRemoteInputMethodPrivate(); | 678 GetRemoteInputMethodPrivate(); |
679 if (!remote_input_method_private) | 679 if (!remote_input_method_private) |
680 return; | 680 return; |
681 remote_input_method_private->OnInputSourceChanged(language_id, is_ime); | 681 remote_input_method_private->OnInputSourceChanged(language_id, is_ime); |
682 } | 682 } |
683 | 683 |
684 void RemoteRootWindowHostWin::DispatchKeyboardMessage(ui::EventType type, | 684 void RemoteWindowTreeHostWin::DispatchKeyboardMessage(ui::EventType type, |
685 uint32 vkey, | 685 uint32 vkey, |
686 uint32 repeat_count, | 686 uint32 repeat_count, |
687 uint32 scan_code, | 687 uint32 scan_code, |
688 uint32 flags, | 688 uint32 flags, |
689 bool is_character) { | 689 bool is_character) { |
690 SetEventFlags(flags | mouse_event_flags()); | 690 SetEventFlags(flags | mouse_event_flags()); |
691 if (base::MessageLoop::current()->IsNested()) { | 691 if (base::MessageLoop::current()->IsNested()) { |
692 int index = (flags & ui::EF_ALT_DOWN) ? 1 : 0; | 692 int index = (flags & ui::EF_ALT_DOWN) ? 1 : 0; |
693 const int char_message[] = {WM_CHAR, WM_SYSCHAR}; | 693 const int char_message[] = {WM_CHAR, WM_SYSCHAR}; |
694 const int keydown_message[] = {WM_KEYDOWN, WM_SYSKEYDOWN}; | 694 const int keydown_message[] = {WM_KEYDOWN, WM_SYSKEYDOWN}; |
695 const int keyup_message[] = {WM_KEYUP, WM_SYSKEYUP}; | 695 const int keyup_message[] = {WM_KEYUP, WM_SYSKEYUP}; |
696 uint32 message = is_character | 696 uint32 message = is_character |
697 ? char_message[index] | 697 ? char_message[index] |
698 : (type == ui::ET_KEY_PRESSED ? keydown_message[index] | 698 : (type == ui::ET_KEY_PRESSED ? keydown_message[index] |
699 : keyup_message[index]); | 699 : keyup_message[index]); |
700 ::PostThreadMessage(::GetCurrentThreadId(), | 700 ::PostThreadMessage(::GetCurrentThreadId(), |
701 message, | 701 message, |
702 vkey, | 702 vkey, |
703 repeat_count | scan_code >> 15); | 703 repeat_count | scan_code >> 15); |
704 } else { | 704 } else { |
705 ui::KeyEvent event(type, | 705 ui::KeyEvent event(type, |
706 ui::KeyboardCodeForWindowsKeyCode(vkey), | 706 ui::KeyboardCodeForWindowsKeyCode(vkey), |
707 flags, | 707 flags, |
708 is_character); | 708 is_character); |
709 delegate_->OnHostKeyEvent(&event); | 709 delegate_->OnHostKeyEvent(&event); |
710 } | 710 } |
711 } | 711 } |
712 | 712 |
713 void RemoteRootWindowHostWin::SetEventFlags(uint32 flags) { | 713 void RemoteWindowTreeHostWin::SetEventFlags(uint32 flags) { |
714 if (flags == event_flags_) | 714 if (flags == event_flags_) |
715 return; | 715 return; |
716 event_flags_ = flags; | 716 event_flags_ = flags; |
717 SetVirtualKeyStates(event_flags_); | 717 SetVirtualKeyStates(event_flags_); |
718 } | 718 } |
719 | 719 |
720 } // namespace aura | 720 } // namespace aura |
OLD | NEW |