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

Add {get/set}_window_position for Windows platform. #434

Merged
merged 2 commits into from
May 17, 2024

Conversation

mandroll
Copy link
Contributor

@mandroll mandroll commented May 15, 2024

Add get_window_position and set_window_position to miniquad for Windows platform.

  • set_window_position uses the typical Request code path.
  • get_window_position adds a screen_position field to NativeDisplay struct and updates it every time the screen position changes or is resized in the main update loop.

Background

My motivation for this is to implement some form of pseudo hot-reloading (recompiling and reloading game state), which requires the window to always be in the same position and size. I've included an example in this gist, with a short video demonstration here.

There have also been numerous requests for this feature in the Discord channel and also #329.

Other platforms

This PR only adds Windows support. Other OSes will give an unimplemented error when trying to use these features. It is not applicable to ios/android/wasm platforms. For other platforms (linux_*, macos), adding support involves:

  1. Add a set_window_position implementation and calling it in process_request
  2. Update NativeDisplay.screen_position in the main update loop for that platform.

@mandroll mandroll changed the title Add {get/set}_window_position to enable hot-reloading. Add {get/set}_window_position. May 15, 2024
examples/save_window.rs Outdated Show resolved Hide resolved
@mandroll mandroll force-pushed the window_position branch 2 times, most recently from d3b6c26 to d210b20 Compare May 16, 2024 01:09
@mandroll mandroll changed the title Add {get/set}_window_position. Add {get/set}_window_position for Windows platform. May 16, 2024
@mandroll mandroll requested a review from not-fl3 May 16, 2024 01:16
@not-fl3 not-fl3 merged commit 838362b into not-fl3:master May 17, 2024
10 checks passed
@not-fl3
Copy link
Owner

not-fl3 commented May 17, 2024

Thanks for PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants