Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

feat: refresh_strategy and post_refresh() #14

Open
1 task done
limikael opened this issue May 5, 2023 · 0 comments
Open
1 task done

feat: refresh_strategy and post_refresh() #14

limikael opened this issue May 5, 2023 · 0 comments

Comments

@limikael
Copy link

limikael commented May 5, 2023

Area

lokinit

Problem

Currently, lokinit is continuously emitting update and render events. For a game that is usually the sole focus of a user, and where things are constantly moving on screen, this makes sense. For other types of apps (like a chat app), it takes up unnecessary CPU.

Suggested solution

It would be nice if there was a setting to just have it emit such events when a redraw is needed. This is similar to e.g. ControlFlow in winit and the EventPump in SDL. From the programmer's perspective we could do this by having a setting refresh_strategy: RefreshStrategy in Conf, where RefreshStrategy is an enum with the values Continuous or Requested. The default would be Continuous, in which case things would work the same as they do now. If the refresh strategy is requested, the update and draw events would only be sent if needed (e.g. when the app is started, or if it has been minimized and then restored). There would also be a post_refresh function on the window module that manually triggers the update and draw events to be sent.

As an implementation note, it is important that the post_refresh function makes sure that the update happens after any pending events.

Also, in order to be able to roll the feature out quicker we can see it as a kind of "hint". I.e., we don't need to have it on all platforms before we merge the code into mainline.

Alternatives

No response

Additional information

No response

Checks

  • I have checked for existing issues about this, and did not
    find any.
@limikael limikael changed the title feat: refresh_strategy and post_redisplay() feat: refresh_strategy and post_refresh() May 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant