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

Emit an event for SDL_WINDOWEVENT_EXPOSED #2004

Closed
doesntgolf opened this issue Jan 9, 2024 · 1 comment
Closed

Emit an event for SDL_WINDOWEVENT_EXPOSED #2004

doesntgolf opened this issue Jan 9, 2024 · 1 comment
Labels
feature New feature or request SDL3 Features and changes that depend on upgrading from SDL2 to SDL3
Milestone

Comments

@doesntgolf
Copy link

doesntgolf commented Jan 9, 2024

In the i3 window manager, when switching from one workspace to the workspace with an SDL application running, SDL emits the SDL_WINDOWEVENT_EXPOSED event. (I'm guessing this happens in other X desktops as well, and probably elsewhere, but I haven't tested anything else.)

I proposed emitting love.visible(true) when this happens (#2003), and @slime73 thought this didn't quite align with love.visible well enough. She suggested waiting to add something for this until SDL3, which is also adding an occluded event, which will be the opposite half of exposed.

(Edit: also, for what it's worth, I'm working on a non-game desktop app in Love. My graphics are static most of the time, so I have my own main loop where I only redraw when necessary, etc. I imagine in a game this isn't much of a concern, so I understand if this isn't added or isn't a priority.)

This issue is to track getting those events in a future Love version.

@slime73 slime73 added the feature New feature or request label Jan 9, 2024
@slime73 slime73 added the SDL3 Features and changes that depend on upgrading from SDL2 to SDL3 label Feb 9, 2024
@HDPLocust
Copy link

HDPLocust commented Jun 22, 2024

Personally, I see the point in using love.visible and other similar events only if you, for example, are playing a video, and want to stop it from redrawing if the user minimizes the window. But even so, it is advisable to maintain some frame rate (3-5 frames per second) to update the preview window while it's changes (OS-dependent preview like this one).
image

Most of non-immediate UI engines redraw the window only when strictly necessary - some internal event occurs (for example, the player moves the mouse), and the game screen is redrawn. Or while something is animatted, a redraw event was created and redraw entire UI window. Or something keeps getting redrawn every frame (like playing a video), and so you have to redraw the window.

Btw, good UI engines redraw only those areas that require redrawing, like this: ui node changes background color on redraw, being true static canvas otherwise (animated buttons emits redraw event up to UI node tree while animation goes on) and it's quite heavy optimization: UI complexity no longer affects performance, since only those UI elements that have been changed are redrawed.
https://github.com/love2d/love/assets/13125395/6feb1039-a820-478e-9b42-ae369d1df70f

@slime73 slime73 added this to the 12.0 milestone Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request SDL3 Features and changes that depend on upgrading from SDL2 to SDL3
Projects
None yet
Development

No branches or pull requests

3 participants