@@ -54,6 +54,7 @@ InputManager::InputManager() {
54
54
this ->current_input_state_ .is_alt_pressed = false ;
55
55
this ->current_input_state_ .is_control_pressed = false ;
56
56
this ->current_input_state_ .is_shift_pressed = false ;
57
+ this ->current_input_state_ .is_meta_pressed = false ;
57
58
this ->current_input_state_ .is_left_button_pressed = false ;
58
59
this ->current_input_state_ .is_right_button_pressed = false ;
59
60
this ->current_input_state_ .mouse_x = 0 ;
@@ -239,6 +240,7 @@ InputState InputManager::CloneCurrentInputState(void) {
239
240
current_input_state.is_alt_pressed = this ->current_input_state_ .is_alt_pressed ;
240
241
current_input_state.is_control_pressed = this ->current_input_state_ .is_control_pressed ;
241
242
current_input_state.is_shift_pressed = this ->current_input_state_ .is_shift_pressed ;
243
+ current_input_state.is_meta_pressed = this ->current_input_state_ .is_meta_pressed ;
242
244
current_input_state.is_left_button_pressed = this ->current_input_state_ .is_left_button_pressed ;
243
245
current_input_state.is_right_button_pressed = this ->current_input_state_ .is_right_button_pressed ;
244
246
current_input_state.mouse_x = this ->current_input_state_ .mouse_x ;
@@ -395,10 +397,13 @@ int InputManager::PointerMoveTo(BrowserHandle browser_wrapper,
395
397
long end_y = start_y;
396
398
if (element_specified) {
397
399
LocationInfo element_location;
398
- LocationInfo move_location;
399
- status_code = target_element->GetClickLocation (this ->scroll_behavior_ ,
400
- &element_location,
401
- &move_location);
400
+ // Note: The caller of the action sequence is responsible for making
401
+ // sure the target element is in the view port. In particular, the
402
+ // high-level click and sendKeys implementations do this in their
403
+ // command handlers. Further note that offsets specified in this
404
+ // move action will be relative to the center of the element as
405
+ // calculated here.
406
+ status_code = target_element->GetStaticClickLocation (&element_location);
402
407
// We can't use the status code alone here. Even though the center of the
403
408
// element may not reachable via the mouse, we might still be able to move
404
409
// to whatever portion of the element *is* visible in the viewport, especially
@@ -420,11 +425,6 @@ int InputManager::PointerMoveTo(BrowserHandle browser_wrapper,
420
425
// move will be at some offset from the element origin.
421
426
end_x = element_location.x ;
422
427
end_y = element_location.y ;
423
- if (!offset_specified) {
424
- // No offset was specified, which means move to the center of the element.
425
- end_x = move_location.x ;
426
- end_y = move_location.y ;
427
- }
428
428
}
429
429
430
430
if (origin == " viewport" ) {
@@ -441,9 +441,20 @@ int InputManager::PointerMoveTo(BrowserHandle browser_wrapper,
441
441
}
442
442
}
443
443
444
+
444
445
LOG (DEBUG) << " Queueing SendInput structure for mouse move (origin: " << origin
445
446
<< " , x: " << end_x << " , y: " << end_y << " )" ;
446
447
HWND browser_window_handle = browser_wrapper->GetContentWindowHandle ();
448
+ RECT window_rect;
449
+ ::GetWindowRect (browser_window_handle, &window_rect);
450
+ POINT click_point = { end_x, end_y };
451
+ ::ClientToScreen (browser_window_handle, &click_point);
452
+ if (click_point.x < window_rect.left ||
453
+ click_point.x > window_rect.right ||
454
+ click_point.y < window_rect.top ||
455
+ click_point.y > window_rect.bottom ) {
456
+ return EMOVETARGETOUTOFBOUNDS;
457
+ }
447
458
if (end_x == input_state->mouse_x && end_y == input_state->mouse_y ) {
448
459
LOG (DEBUG) << " Omitting SendInput structure for mouse move; no movement required (x: "
449
460
<< end_x << " , y: " << end_y << " )" ;
@@ -685,6 +696,25 @@ void InputManager::AddKeyboardInput(HWND window_handle,
685
696
}
686
697
this ->UpdatePressedKeys (WD_KEY_ALT, input_state->is_alt_pressed );
687
698
}
699
+
700
+ // If the character represents the Meta (Windows) key, or represents
701
+ // the "release all modifiers" key and the Meta key is down, send
702
+ // the appropriate down or up keystroke for the Meta key.
703
+ if (character == WD_KEY_META ||
704
+ character == WD_KEY_R_META ||
705
+ (character == WD_KEY_NULL && input_state->is_meta_pressed )) {
706
+ // modifier_key_info.key_code = VK_LWIN;
707
+ // this->CreateKeyboardInputItem(modifier_key_info,
708
+ // 0,
709
+ // input_state->is_meta_pressed);
710
+ // if (input_state->is_meta_pressed) {
711
+ // input_state->is_meta_pressed = false;
712
+ // } else {
713
+ // input_state->is_meta_pressed = true;
714
+ // }
715
+ // this->UpdatePressedKeys(WD_KEY_META, input_state->is_meta_pressed);
716
+ }
717
+
688
718
return ;
689
719
}
690
720
@@ -803,9 +833,11 @@ bool InputManager::IsModifierKey(wchar_t character) {
803
833
return character == WD_KEY_SHIFT ||
804
834
character == WD_KEY_CONTROL ||
805
835
character == WD_KEY_ALT ||
836
+ character == WD_KEY_META ||
806
837
character == WD_KEY_R_SHIFT ||
807
838
character == WD_KEY_R_CONTROL ||
808
839
character == WD_KEY_R_ALT ||
840
+ character == WD_KEY_R_META ||
809
841
character == WD_KEY_NULL;
810
842
}
811
843
@@ -999,6 +1031,56 @@ KeyInfo InputManager::GetKeyInfo(HWND window_handle, wchar_t character) {
999
1031
key_info.scan_code = VK_DIVIDE;
1000
1032
key_info.is_extended_key = true ;
1001
1033
}
1034
+ else if (character == WD_KEY_R_PAGEUP) {
1035
+ key_info.key_code = VK_PRIOR;
1036
+ key_info.scan_code = VK_PRIOR;
1037
+ key_info.is_extended_key = true ;
1038
+ }
1039
+ else if (character == WD_KEY_R_PAGEDN) {
1040
+ key_info.key_code = VK_NEXT;
1041
+ key_info.scan_code = VK_NEXT;
1042
+ key_info.is_extended_key = true ;
1043
+ }
1044
+ else if (character == WD_KEY_R_END) { // end
1045
+ key_info.key_code = VK_END;
1046
+ key_info.scan_code = VK_END;
1047
+ key_info.is_extended_key = true ;
1048
+ }
1049
+ else if (character == WD_KEY_R_HOME) { // home
1050
+ key_info.key_code = VK_HOME;
1051
+ key_info.scan_code = VK_HOME;
1052
+ key_info.is_extended_key = true ;
1053
+ }
1054
+ else if (character == WD_KEY_R_LEFT) { // left arrow
1055
+ key_info.key_code = VK_LEFT;
1056
+ key_info.scan_code = VK_LEFT;
1057
+ key_info.is_extended_key = true ;
1058
+ }
1059
+ else if (character == WD_KEY_R_UP) { // up arrow
1060
+ key_info.key_code = VK_UP;
1061
+ key_info.scan_code = VK_UP;
1062
+ key_info.is_extended_key = true ;
1063
+ }
1064
+ else if (character == WD_KEY_R_RIGHT) { // right arrow
1065
+ key_info.key_code = VK_RIGHT;
1066
+ key_info.scan_code = VK_RIGHT;
1067
+ key_info.is_extended_key = true ;
1068
+ }
1069
+ else if (character == WD_KEY_R_DOWN) { // down arrow
1070
+ key_info.key_code = VK_DOWN;
1071
+ key_info.scan_code = VK_DOWN;
1072
+ key_info.is_extended_key = true ;
1073
+ }
1074
+ else if (character == WD_KEY_R_INSERT) { // insert
1075
+ key_info.key_code = VK_INSERT;
1076
+ key_info.scan_code = VK_INSERT;
1077
+ key_info.is_extended_key = true ;
1078
+ }
1079
+ else if (character == WD_KEY_R_DELETE) { // delete
1080
+ key_info.key_code = VK_DELETE;
1081
+ key_info.scan_code = VK_DELETE;
1082
+ key_info.is_extended_key = true ;
1083
+ }
1002
1084
else if (character == WD_KEY_F1) { // F1
1003
1085
key_info.key_code = VK_F1;
1004
1086
key_info.scan_code = VK_F1;
@@ -1047,14 +1129,6 @@ KeyInfo InputManager::GetKeyInfo(HWND window_handle, wchar_t character) {
1047
1129
key_info.key_code = VK_F12;
1048
1130
key_info.scan_code = VK_F12;
1049
1131
}
1050
- else if (character == WD_KEY_META) { // Meta
1051
- key_info.key_code = VK_LWIN;
1052
- key_info.scan_code = VK_LWIN;
1053
- }
1054
- else if (character == WD_KEY_R_META) { // Meta
1055
- key_info.key_code = VK_RWIN;
1056
- key_info.scan_code = VK_RWIN;
1057
- }
1058
1132
else if (character == L' \n ' ) { // line feed
1059
1133
key_info.key_code = VK_RETURN;
1060
1134
key_info.scan_code = VK_RETURN;
0 commit comments