PistonDevelopers / PistonDevelopers/piston
Add method to Window trait to disable automatic closing
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 4.7k
- Forks
- 235
- Avg merge
- 1m
- Merged PRs (30d)
- 4
Description
One simple thing I would like from Piston is the ability to disable automatic window closing when the window's "X" button in the top corner is pressed. For example, if I am developing some kind of editor-like interface, and the user tries to close the window, I would like to be able to intercept that close request and ask them if they would like to save their data first.
My idea would be to add automatic_close(self, bool) -> Self and set_automatic_close(&mut self, bool) methods to the Window trait.
As an example, currently, in GlutinWindow's implementation of Window, when a close is requested, should_close is set to true and a Event::Input(Input::Close(CloseArgs {})) is returned from Window::poll_event(). If automatic_close were set to false, then the close event could still be returned, but should_close would not be set to true. This would allow the user to have control over when the window actually closes.
Something to consider would be whether or not these methods should have a default implementation that does nothing, so as not to break current Window implementors that blindly upgrade their piston version.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Window trait and the GlutinWindow implementation mentioned in the issue, then trace Window::poll_event and the should_close state. Confirm how a close request currently produces Event::Input(Input::Close(CloseArgs {})); done means the event remains available while automatic closing can be disabled, with existing implementors considered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100