mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
parent
40e35fa047
commit
51f06139a6
@ -62,6 +62,10 @@ type Monitor struct {
|
||||
m *glfw.Monitor
|
||||
}
|
||||
|
||||
func (m *Monitor) GetContentScale() (float32, float32) {
|
||||
return m.m.GetContentScale()
|
||||
}
|
||||
|
||||
func (m *Monitor) GetPos() (x, y int) {
|
||||
return m.m.GetPos()
|
||||
}
|
||||
|
@ -29,17 +29,22 @@ func (u *UserInterface) fromGLFWMonitorPixel(x float64) float64 {
|
||||
|
||||
// fromGLFWPixel must be called from the main thread.
|
||||
func (u *UserInterface) fromGLFWPixel(x float64) float64 {
|
||||
return x
|
||||
// deviceScaleFactor() is a scale by desktop environment (e.g., Cinnamon), while GetContentScale() is X's scale.
|
||||
// They are different things and then need to be treated different ways (#1350).
|
||||
s, _ := currentMonitor(u.window).GetContentScale()
|
||||
return x / float64(s)
|
||||
}
|
||||
|
||||
// toGLFWPixel must be called from the main thread.
|
||||
func (u *UserInterface) toGLFWPixel(x float64) float64 {
|
||||
return x
|
||||
s, _ := currentMonitor(u.window).GetContentScale()
|
||||
return x * float64(s)
|
||||
}
|
||||
|
||||
// toFramebufferPixel must be called from the main thread.
|
||||
func (u *UserInterface) toFramebufferPixel(x float64) float64 {
|
||||
return x / u.deviceScaleFactor()
|
||||
s, _ := currentMonitor(u.window).GetContentScale()
|
||||
return x / u.deviceScaleFactor() * float64(s)
|
||||
}
|
||||
|
||||
func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) {
|
||||
|
Loading…
Reference in New Issue
Block a user