Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: move prepare_wait before querying the control_flow #3216

Merged
merged 1 commit into from
Nov 8, 2023
Merged

Windows: move prepare_wait before querying the control_flow #3216

merged 1 commit into from
Nov 8, 2023

Conversation

ogoffart
Copy link
Contributor

@ogoffart ogoffart commented Nov 7, 2023

In case the AboutToWait event sets the control flow to another value

Fixes #3215

  • Tested on all platforms changed
  • 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
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

@ogoffart ogoffart requested a review from msiglreith as a code owner November 7, 2023 18:38
Comment on lines 363 to 373
// We aim to be consistent with the MacOS backend which has a RunLoop
// observer that will dispatch AboutToWait when about to wait for
// events, and NewEvents after the RunLoop wakes up.
//
// We emulate similar behaviour by treating `GetMessage` as our wait
// point and wake up point (when it returns) and we drain all other
// pending messages via `PeekMessage` until we come back to "wait" via
// `GetMessage`
//
runner.prepare_wait();

Copy link
Member

Choose a reason for hiding this comment

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

I don't quite like the way it's structured in this function. Could you instead move the timeout calculation to the place it's actually being used? So basically revert your code and move the let control_flow_timeout part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. Also moved the computation of start nearer to where it is used. This is not strictly equivalent as time can pass while prepare_wait is being called. But i think this is fine.

In case the AboutToWait event sets the control flow to another value

Fixes #3215
@kchibisov
Copy link
Member

You've tested that it fixes your issue, right?

@ogoffart
Copy link
Contributor Author

ogoffart commented Nov 8, 2023

You've tested that it fixes your issue, right?

Yes

@kchibisov kchibisov merged commit 21701a3 into rust-windowing:master Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Windows: set_control_flow has no effect from AboutToWait event
3 participants