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