giorefreshrate

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2023 License: MIT, Unlicense Imports: 2 Imported by: 0

README

GioRefreshRate

Allows to set the display refresh rate on Android. Some manufacturers limit apps using SurfaceView (such as gio) to 60hz, this library can bring it back and have that scroll be smooth.

Getting Started

Run go get github.com/ilidemi/giorefreshrate

Call giorefreshrate.PreferHighRefreshRate() or giorefreshrate.PreferLowRefreshRate() before the event loop and provide giorefreshrate access to the Window events:

+   giorefreshrate.PreferHighRefreshRate()

    for e := range w.Events() { // Gio main event loop
+       giorefreshrate.ListenEvents(e, w)

        switch e := e.(type) {
            // ...
        }
    }

That's it! The refresh rate will be the highest or lowest supported for the current display resolution.

Notes

Uses the same approach as flutter_displaymode.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenEvents

func ListenEvents(event event.Event, w *app.Window) error

ListenEvents must get all the events from Gio, in order to get the GioView once it's ready and apply the refresh rate to the window. It needs to be called from the main UI loop.

Example:

select {
case e := <-w.Events():
	giorefreshrate.ListenEvents(e, w)

	switch e := e.(type) {
     (( ... your code ...  ))

func PreferHighRefreshRate

func PreferHighRefreshRate()

Prefer the highest refresh rate supported by the display at the current resolution. Needs to be called before any window events are consumed. The refresh rate will be applied by ListenEvents() when it sees that the window is ready.

func PreferLowRefreshRate

func PreferLowRefreshRate()

Prefer the lowest refresh rate supported by the display at the current resolution. Needs to be called before any window events are consumed. The refresh rate will be applied by ListenEvents() when it sees that the window is ready.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL