ui: Keep the device scale to avoid re-calculation

This commit is contained in:
Hajime Hoshi 2017-05-14 04:21:20 +09:00
parent d6219e38d8
commit 93cdfe107e
2 changed files with 5 additions and 2 deletions

View File

@ -34,6 +34,7 @@ type userInterface struct {
width int width int
height int height int
scale float64 scale float64
deviceScale float64
funcs chan func() funcs chan func()
running bool running bool
sizeChanged bool sizeChanged bool
@ -208,7 +209,10 @@ func (u *userInterface) glfwSize() (int, int) {
} }
func (u *userInterface) actualScreenScale() float64 { func (u *userInterface) actualScreenScale() float64 {
return u.scale * deviceScale() if u.deviceScale == 0 {
u.deviceScale = deviceScale()
}
return u.scale * u.deviceScale
} }
func (u *userInterface) pollEvents() { func (u *userInterface) pollEvents() {

View File

@ -34,7 +34,6 @@ package ui
// static int getCaptionHeight() { // static int getCaptionHeight() {
// return GetSystemMetrics(SM_CYCAPTION); // return GetSystemMetrics(SM_CYCAPTION);
// } // }
//
import "C" import "C"
func deviceScale() float64 { func deviceScale() float64 {