Skip to content

Conversation

@ajtribick
Copy link
Contributor

  • Tested on all platforms changed
    • Windows 10
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior (N/A)
  • Created or updated an example program if it would help users understand this functionality (N/A)
  • Updated feature matrix, if new features were added or implemented (N/A)

This follows Microsoft's documentation on handling the WM_SYSCHAR and WM_SYSKEYDOWN events. Allows the ALT+Space menu to work.

This also allows opening the window menu in fullscreen, as tested in the "fullscreen" example. I'm not sure whether or not that is desired behavior.

Resolves #2406

@ajtribick ajtribick requested a review from msiglreith as a code owner August 27, 2022 15:10
@maroider maroider added the DS - win32 Affects the Win32/Windows backend label Aug 27, 2022
Copy link
Member

@msiglreith msiglreith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! a few changes would be needed

}
0

if msg == WM_SYSCHAR {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to completely remove the WM_SYSCHAR as a case we explicitly handle in WM_CHAR | WM_SYSCHAR - otherwise we would generate ReceivedCharacter events which isn't desired imo.
WM_SYSCHAR would be then handled by the default fallback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I've also added a handler for WM_MENUCHAR to disable the annoying beep sound when an ALT+keypress is entered. This could in principle be used to communicate an event to be used in a menu system, but not sure how generalisable that would be to other platforms.

- Pass WM_SYSKEYDOWN to DefWindowProc
- Avoid intercepting WM_SYSCHAR to allow ALT+Space to work: removes ReceivedCharacter events for alt+keypress
- Intercept WM_MENUCHAR to disable bell sound
@ajtribick
Copy link
Contributor Author

Force pushed to pick up the CI fix

@ajtribick ajtribick changed the title Windows: Pass WM_SYSCHAR and WM_SYSKEYDOWN to DefWindowProc Windows: Update handling of system keypresses Aug 31, 2022
@msiglreith msiglreith merged commit dfecdc5 into rust-windowing:master Aug 31, 2022
@ajtribick ajtribick deleted the alt-space-fix branch September 1, 2022 05:49
kchibisov pushed a commit to kchibisov/winit that referenced this pull request Sep 9, 2022
- Pass WM_SYSKEYDOWN to DefWindowProc
- Avoid intercepting WM_SYSCHAR to allow ALT+Space to work: removes ReceivedCharacter events for alt+keypress
- Intercept WM_MENUCHAR to disable bell sound
kchibisov pushed a commit that referenced this pull request Sep 11, 2022
- Pass WM_SYSKEYDOWN to DefWindowProc
- Avoid intercepting WM_SYSCHAR to allow ALT+Space to work: removes ReceivedCharacter events for alt+keypress
- Intercept WM_MENUCHAR to disable bell sound
@ilya-bobyr
Copy link

This change broke compatibility between Windows and other platforms.
On Unix pressing Alt+B emits ReceivedCharacter, while on Windows, after this change, ReceivedCharacter is no longer emitted.

Here is a relevant bug for Alacritty, for example: alacritty/alacritty#6356

Should I open a separate issue for this discussion, or should we use this one?

@madsmtm
Copy link
Member

madsmtm commented Sep 27, 2022

Please open a new issue, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - win32 Affects the Win32/Windows backend

Development

Successfully merging this pull request may close these issues.

Alt-space does not open the system menu on Windows

5 participants