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

Side by Side Diff: ui/aura/remote_root_window_host_win.cc

Issue 12558008: Ensure that menus put in Chrome ASH on Windows 8 are operatable using the keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/remote_root_window_host_win.h ('k') | win8/metro_driver/chrome_app_view_ash.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 22
23 namespace aura { 23 namespace aura {
24 24
25 namespace { 25 namespace {
26 26
27 const char* kRootWindowHostWinKey = "__AURA_REMOTE_ROOT_WINDOW_HOST_WIN__"; 27 const char* kRootWindowHostWinKey = "__AURA_REMOTE_ROOT_WINDOW_HOST_WIN__";
28 28
29 // The touch id to be used for touch events coming in from Windows Ash. 29 // The touch id to be used for touch events coming in from Windows Ash.
30 const int kRemoteWindowTouchId = 10; 30 const int kRemoteWindowTouchId = 10;
31 31
32 // Sets the keystate for the virtual key passed in to down or up.
33 void SetKeyState(uint8* key_states, bool key_down, uint32 virtual_key_code) {
34 DCHECK(key_states);
35
36 if (key_down)
37 key_states[virtual_key_code] |= 0x80;
38 else
39 key_states[virtual_key_code] &= 0x7F;
40 }
41
42 // Sets the keyboard states for the Shift/Control/Alt/Caps lock keys.
43 void SetVirtualKeyStates(uint32 flags) {
44 uint8 keyboard_state[256] = {0};
45 ::GetKeyboardState(keyboard_state);
46
47 SetKeyState(keyboard_state, !!(flags & ui::EF_SHIFT_DOWN), VK_SHIFT);
48 SetKeyState(keyboard_state, !!(flags & ui::EF_CONTROL_DOWN), VK_CONTROL);
49 SetKeyState(keyboard_state, !!(flags & ui::EF_ALT_DOWN), VK_MENU);
50 SetKeyState(keyboard_state, !!(flags & ui::EF_CAPS_LOCK_DOWN), VK_CAPITAL);
51
52 ::SetKeyboardState(keyboard_state);
53 }
54
32 } // namespace 55 } // namespace
33 56
34 void HandleOpenFile( 57 void HandleOpenFile(
35 const string16& title, 58 const string16& title,
36 const base::FilePath& default_path, 59 const base::FilePath& default_path,
37 const string16& filter, 60 const string16& filter,
38 const OpenFileCompletion& callback) { 61 const OpenFileCompletion& callback) {
39 DCHECK(aura::RemoteRootWindowHostWin::Instance()); 62 DCHECK(aura::RemoteRootWindowHostWin::Instance());
40 aura::RemoteRootWindowHostWin::Instance()->HandleOpenFile(title, 63 aura::RemoteRootWindowHostWin::Instance()->HandleOpenFile(title,
41 default_path, 64 default_path,
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } else { 333 } else {
311 mouse_event.SetClickCount(1); 334 mouse_event.SetClickCount(1);
312 delegate_->OnHostMouseEvent(&mouse_event); 335 delegate_->OnHostMouseEvent(&mouse_event);
313 } 336 }
314 } 337 }
315 338
316 void RemoteRootWindowHostWin::OnKeyDown(uint32 vkey, 339 void RemoteRootWindowHostWin::OnKeyDown(uint32 vkey,
317 uint32 repeat_count, 340 uint32 repeat_count,
318 uint32 scan_code, 341 uint32 scan_code,
319 uint32 flags) { 342 uint32 flags) {
320 ui::KeyEvent event(ui::ET_KEY_PRESSED, 343 DispatchKeyboardMessage(ui::ET_KEY_PRESSED, vkey, repeat_count, scan_code,
321 ui::KeyboardCodeForWindowsKeyCode(vkey), 344 flags, false);
322 flags,
323 false);
324 delegate_->OnHostKeyEvent(&event);
325 } 345 }
326 346
327 void RemoteRootWindowHostWin::OnKeyUp(uint32 vkey, 347 void RemoteRootWindowHostWin::OnKeyUp(uint32 vkey,
328 uint32 repeat_count, 348 uint32 repeat_count,
329 uint32 scan_code, 349 uint32 scan_code,
330 uint32 flags) { 350 uint32 flags) {
331 ui::KeyEvent event(ui::ET_KEY_RELEASED, 351 DispatchKeyboardMessage(ui::ET_KEY_RELEASED, vkey, repeat_count, scan_code,
332 ui::KeyboardCodeForWindowsKeyCode(vkey), 352 flags, false);
333 flags,
334 false);
335 delegate_->OnHostKeyEvent(&event);
336 } 353 }
337 354
338 void RemoteRootWindowHostWin::OnChar(uint32 key_code, 355 void RemoteRootWindowHostWin::OnChar(uint32 key_code,
339 uint32 repeat_count, 356 uint32 repeat_count,
340 uint32 scan_code, 357 uint32 scan_code,
341 uint32 flags) { 358 uint32 flags) {
342 ui::KeyEvent event(ui::ET_KEY_PRESSED, 359 DispatchKeyboardMessage(ui::ET_KEY_PRESSED, key_code, repeat_count,
343 ui::KeyboardCodeForWindowsKeyCode(key_code), 360 scan_code, flags, true);
344 flags,
345 true);
346 delegate_->OnHostKeyEvent(&event);
347 } 361 }
348 362
349 void RemoteRootWindowHostWin::OnVisibilityChanged(bool visible) { 363 void RemoteRootWindowHostWin::OnVisibilityChanged(bool visible) {
350 if (visible) 364 if (visible)
351 delegate_->OnHostActivated(); 365 delegate_->OnHostActivated();
352 } 366 }
353 367
354 void RemoteRootWindowHostWin::OnTouchDown(int32 x, int32 y, uint64 timestamp) { 368 void RemoteRootWindowHostWin::OnTouchDown(int32 x, int32 y, uint64 timestamp) {
355 ui::TouchEvent event(ui::ET_TOUCH_PRESSED, 369 ui::TouchEvent event(ui::ET_TOUCH_PRESSED,
356 gfx::Point(x, y), 370 gfx::Point(x, y),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 412
399 void RemoteRootWindowHostWin::OnMultiFileOpenDone( 413 void RemoteRootWindowHostWin::OnMultiFileOpenDone(
400 bool success, 414 bool success,
401 const std::vector<base::FilePath>& files) { 415 const std::vector<base::FilePath>& files) {
402 if (success) { 416 if (success) {
403 multi_file_open_completion_callback_.Run(files, NULL); 417 multi_file_open_completion_callback_.Run(files, NULL);
404 } 418 }
405 multi_file_open_completion_callback_.Reset(); 419 multi_file_open_completion_callback_.Reset();
406 } 420 }
407 421
422 void RemoteRootWindowHostWin::DispatchKeyboardMessage(ui::EventType type,
423 uint32 vkey,
424 uint32 repeat_count,
425 uint32 scan_code,
426 uint32 flags,
427 bool is_character) {
428 if (MessageLoop::current()->IsNested()) {
429 SetVirtualKeyStates(flags);
430
431 uint32 message = is_character ? WM_CHAR :
432 (type == ui::ET_KEY_PRESSED ? WM_KEYDOWN : WM_KEYUP);
433 ::PostThreadMessage(::GetCurrentThreadId(),
434 message,
435 vkey,
436 repeat_count | scan_code >> 15);
437 } else {
438 ui::KeyEvent event(type,
439 ui::KeyboardCodeForWindowsKeyCode(vkey),
440 flags,
441 is_character);
442 delegate_->OnHostKeyEvent(&event);
443 }
444 }
445
408 } // namespace aura 446 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/remote_root_window_host_win.h ('k') | win8/metro_driver/chrome_app_view_ash.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698