mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
graphicsdriver/glfw: Bug fix: Convert window size unit correctly on Linux/UNIX
Updates #1307
This commit is contained in:
parent
5278a7c6d6
commit
97607f5779
@ -789,19 +789,20 @@ func (u *UserInterface) updateSize() {
|
||||
if sizeChanged {
|
||||
var w, h float64
|
||||
_ = u.t.Call(func() error {
|
||||
var ww, wh int
|
||||
if u.isFullscreen() {
|
||||
v := currentMonitor(u.window).GetVideoMode()
|
||||
ww = v.Width
|
||||
wh = v.Height
|
||||
ww, wh := v.Width, v.Height
|
||||
w = u.toDeviceIndependentPixel(float64(ww))
|
||||
h = u.toDeviceIndependentPixel(float64(wh))
|
||||
} else {
|
||||
// Instead of u.windowWidth and u.windowHeight, use the actual window size here.
|
||||
// On Windows, the specified size at SetSize and the actual window size might not
|
||||
// match (#1163).
|
||||
ww, wh = u.window.GetSize()
|
||||
}
|
||||
ww, wh := u.window.GetSize()
|
||||
// TODO: Is this correct?
|
||||
w = u.toDeviceIndependentPixel(float64(ww))
|
||||
h = u.toDeviceIndependentPixel(float64(wh))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
u.context.Layout(w, h)
|
||||
|
@ -49,6 +49,10 @@ func (u *UserInterface) toDeviceIndependentPixel(x float64) float64 {
|
||||
return x
|
||||
}
|
||||
|
||||
func (u *UserInterface) fromGLFWPixel(x float64) float64 {
|
||||
return x
|
||||
}
|
||||
|
||||
func (u *UserInterface) toGLFWPixel(x float64) float64 {
|
||||
return x
|
||||
}
|
||||
|
@ -27,6 +27,11 @@ func (u *UserInterface) toDeviceIndependentPixel(x float64) float64 {
|
||||
return x / u.deviceScaleFactor()
|
||||
}
|
||||
|
||||
// fromGLFWPixel must be called from the main thread.
|
||||
func (u *UserInterface) fromGLFWPixel(x float64) float64 {
|
||||
return x
|
||||
}
|
||||
|
||||
// toGLFWPixel must be called from the main thread.
|
||||
func (u *UserInterface) toGLFWPixel(x float64) float64 {
|
||||
return x
|
||||
|
@ -104,6 +104,11 @@ func (u *UserInterface) toDeviceIndependentPixel(x float64) float64 {
|
||||
return x / u.deviceScaleFactor()
|
||||
}
|
||||
|
||||
// fromGLFWPixel must be called from the main thread.
|
||||
func (u *UserInterface) fromGLFWPixel(x float64) float64 {
|
||||
return x / u.deviceScaleFactor()
|
||||
}
|
||||
|
||||
// toGLFWPixel must be called from the main thread.
|
||||
func (u *UserInterface) toGLFWPixel(x float64) float64 {
|
||||
return x * u.deviceScaleFactor()
|
||||
|
@ -192,8 +192,8 @@ func (w *window) Position() (int, int) {
|
||||
mx, my := currentMonitor(w.ui.window).GetPos()
|
||||
wx -= mx
|
||||
wy -= my
|
||||
xf := w.ui.toDeviceIndependentPixel(float64(wx))
|
||||
yf := w.ui.toDeviceIndependentPixel(float64(wy))
|
||||
xf := w.ui.fromGLFWPixel(float64(wx))
|
||||
yf := w.ui.fromGLFWPixel(float64(wy))
|
||||
x, y = int(xf), int(yf)
|
||||
return nil
|
||||
})
|
||||
@ -226,8 +226,8 @@ func (w *window) Size() (int, int) {
|
||||
if !w.ui.isRunning() {
|
||||
return w.ui.getInitWindowSize()
|
||||
}
|
||||
ww := int(w.ui.toDeviceIndependentPixel(float64(w.ui.windowWidth)))
|
||||
wh := int(w.ui.toDeviceIndependentPixel(float64(w.ui.windowHeight)))
|
||||
ww := int(w.ui.fromGLFWPixel(float64(w.ui.windowWidth)))
|
||||
wh := int(w.ui.fromGLFWPixel(float64(w.ui.windowHeight)))
|
||||
return ww, wh
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user