mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 18:02:02 +01:00
uidriver/glfw: Adjust monitor sizes with math.Ceil
deviceScaleFactor() sometimes returns an unnice value (e.g., 1.502361). Add math.Ceil whenever the calculation involves the device scale factor.
This commit is contained in:
parent
8cb037e902
commit
3fc328db8d
@ -22,7 +22,6 @@ package glfw
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"math"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync"
|
||||
@ -804,8 +803,8 @@ func (u *UserInterface) updateSize() {
|
||||
h = u.fromGLFWPixel(float64(wh))
|
||||
}
|
||||
// On Linux/UNIX, further adjusting is required (#1307).
|
||||
w = math.Ceil(u.toFramebufferPixel(w))
|
||||
h = math.Ceil(u.toFramebufferPixel(h))
|
||||
w = u.toFramebufferPixel(w)
|
||||
h = u.toFramebufferPixel(h)
|
||||
return nil
|
||||
})
|
||||
u.context.Layout(w, h)
|
||||
|
@ -19,12 +19,14 @@
|
||||
package glfw
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/glfw"
|
||||
)
|
||||
|
||||
// fromGLFWMonitorPixel must be called from the main thread.
|
||||
func (u *UserInterface) fromGLFWMonitorPixel(x float64) float64 {
|
||||
return x / u.deviceScaleFactor()
|
||||
return math.Ceil(x / u.deviceScaleFactor())
|
||||
}
|
||||
|
||||
// fromGLFWPixel must be called from the main thread.
|
||||
@ -44,7 +46,7 @@ func (u *UserInterface) toGLFWPixel(x float64) float64 {
|
||||
// toFramebufferPixel must be called from the main thread.
|
||||
func (u *UserInterface) toFramebufferPixel(x float64) float64 {
|
||||
s, _ := currentMonitor(u.window).GetContentScale()
|
||||
return x / u.deviceScaleFactor() * float64(s)
|
||||
return math.Ceil(x * float64(s) / u.deviceScaleFactor())
|
||||
}
|
||||
|
||||
func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) {
|
||||
|
Loading…
Reference in New Issue
Block a user