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 events related to the display state of the window #248

Conversation

sumibi-yakitori
Copy link
Contributor

@sumibi-yakitori sumibi-yakitori commented Mar 15, 2021

I am currently working on a tool that displays images from a large number of external files.

I need these events to unload textures from VRAM when the window is minimized.
(This requires that tetra::graphics::present is called at least once in the tetra lifecycle after the user has released textures)

Copy link
Owner

@17cupsofcoffee 17cupsofcoffee left a comment

Choose a reason for hiding this comment

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

I see no downside to exposing these, given how simple they are to implement!

@17cupsofcoffee 17cupsofcoffee merged commit eee3987 into 17cupsofcoffee:main Mar 15, 2021
@17cupsofcoffee
Copy link
Owner

Thank you for the PR!

@sumibi-yakitori sumibi-yakitori deleted the add_window_display_state_events branch March 15, 2021 13:46
@17cupsofcoffee
Copy link
Owner

17cupsofcoffee commented Mar 15, 2021

I noticed after merging that Shown and Hidden can't currently be triggered via Tetra's public API (other than Shown getting fired once automatically at startup) - however, I needed to expose window visibility for #119, so I've done so in a seperate commit.

@sumibi-yakitori
Copy link
Contributor Author

I'm not sure if I'm understanding what you're saying correctly, but on MacOS, minimizing and unminimizing a window seems to cause SDL_WINDOWEVENT_SHOWN and SDL_WINDOWEVENT_HIDDEN.

@17cupsofcoffee
Copy link
Owner

17cupsofcoffee commented Mar 15, 2021

Ugh, that must be platform-specific, then, because it doesn't happen on Windows. I'll document that.

@sumibi-yakitori
Copy link
Contributor Author

sumibi-yakitori commented Mar 15, 2021

Ok.
I haven't checked how it works on Linux, but I think I can remove Shown and Hidden since my desire seems to be achieved if I can detect the minimization of a window and its unminimization.

Restored, Maximized, Minimized These three events also occur on MacOS.

@17cupsofcoffee
Copy link
Owner

17cupsofcoffee commented Mar 15, 2021

Yeah, I think I might remove them for now - the only consistent way to trigger them on all platforms seems to be to call SDL_ShowWindow/SDL_HideWindow (now exposed via tetra::window::set_visible), but you don't need events to run code in response to that. The minimize/maximize/etc events are still super useful though 😄

And yep, those other three events work fine on Windows.

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