@@ -116,6 +116,12 @@ Win32Window::HandleMessage(UINT const message,
116116 int xPos = 0 , yPos = 0 ;
117117 UINT width = 0 , height = 0 ;
118118 UINT button_pressed = 0 ;
119+ LPARAM extraInfo = GetMessageExtraInfo ();
120+ if (extraInfo == 0xbaddecaf ) {
121+ // Don't pass messages that we synthesized to the framework again.
122+ std::cerr << " Found Extra Info synthesized key for scancode " << scancode << " ("
123+ << character << " )" << std::endl;
124+ }
119125
120126 switch (message) {
121127 case kWmDpiChangedBeforeParent :
@@ -237,39 +243,45 @@ Win32Window::HandleMessage(UINT const message,
237243 OnText (text);
238244 }
239245
240- // All key presses that generate a character should be sent from
241- // WM_CHAR. In order to send the full key press information, the keycode
242- // is persisted in keycode_for_char_message_ obtained from WM_KEYDOWN.
243- if (keycode_for_char_message_ != 0 ) {
244- const unsigned int scancode = (lparam >> 16 ) & 0xff ;
245- OnKey (keycode_for_char_message_, scancode, WM_KEYDOWN, code_point);
246- keycode_for_char_message_ = 0 ;
247- }
248- break ;
249- }
250- case WM_KEYDOWN:
251- case WM_SYSKEYDOWN:
252- case WM_KEYUP:
253- case WM_SYSKEYUP:
254- const bool is_keydown_message =
255- (message == WM_KEYDOWN || message == WM_SYSKEYDOWN);
256- // Check if this key produces a character. If so, the key press should
257- // be sent with the character produced at WM_CHAR. Store the produced
258- // keycode (it's not accessible from WM_CHAR) to be used in WM_CHAR.
259- const unsigned int character = MapVirtualKey (wparam, MAPVK_VK_TO_CHAR);
260- if (character > 0 && is_keydown_message) {
261- keycode_for_char_message_ = wparam;
246+ // All key presses that generate a character should be sent from
247+ // WM_CHAR. In order to send the full key press information, the keycode
248+ // is persisted in keycode_for_char_message_ obtained from WM_KEYDOWN.
249+ if (keycode_for_char_message_ != 0 ) {
250+ const unsigned int scancode = (lparam >> 16 ) & 0xff ;
251+ const bool extended = ((lparam >> 24 ) & 0x01 ) == 0x01 ;
252+ window->OnKey (keycode_for_char_message_, scancode, WM_KEYDOWN,
253+ code_point, extended);
254+ keycode_for_char_message_ = 0 ;
255+ }
262256 break ;
263257 }
264- unsigned int keyCode (wparam);
265- const unsigned int scancode = (lparam >> 16 ) & 0xff ;
266- // If the key is a modifier, get its side.
267- if (keyCode == VK_SHIFT || keyCode == VK_MENU || keyCode == VK_CONTROL) {
268- keyCode = MapVirtualKey (scancode, MAPVK_VSC_TO_VK_EX);
269- }
270- const int action = is_keydown_message ? WM_KEYDOWN : WM_KEYUP;
271- OnKey (keyCode, scancode, action, 0 );
272- break ;
258+ case WM_KEYDOWN:
259+ case WM_SYSKEYDOWN:
260+ case WM_KEYUP:
261+ case WM_SYSKEYUP:
262+ const bool is_keydown_message =
263+ (message == WM_KEYDOWN || message == WM_SYSKEYDOWN);
264+ // Check if this key produces a character. If so, the key press should
265+ // be sent with the character produced at WM_CHAR. Store the produced
266+ // keycode (it's not accessible from WM_CHAR) to be used in WM_CHAR.
267+ const unsigned int character = MapVirtualKey (wparam, MAPVK_VK_TO_CHAR);
268+ if (character > 0 && is_keydown_message) {
269+ keycode_for_char_message_ = wparam;
270+ break ;
271+ }
272+ unsigned int keyCode (wparam);
273+ const unsigned int scancode = (lparam >> 16 ) & 0xff ;
274+ const bool extended = ((lparam >> 24 ) & 0x01 ) == 0x01 ;
275+ // If the key is a modifier, get its side.
276+ if (keyCode == VK_SHIFT || keyCode == VK_MENU ||
277+ keyCode == VK_CONTROL) {
278+ keyCode = MapVirtualKey (scancode, MAPVK_VSC_TO_VK_EX);
279+ }
280+ const int action = is_keydown_message ? WM_KEYDOWN : WM_KEYUP;
281+ window->OnKey (keyCode, scancode, action, 0 , extended);
282+ break ;
283+ }
284+ return DefWindowProc (hwnd, message, wparam, lparam);
273285 }
274286
275287 return DefWindowProc(window_handle_, message, wparam, lparam);
0 commit comments