mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-09-20 05:12:18 +02:00
examples/windowsize: Bug fix: Suppress calling SetWindowPosition if the position is not updated
This is a temoprary fix for the issue that the window size unexpectedly shrunk on Linux. Updates #1607 Closes #1605
This commit is contained in:
parent
ed8be49d23
commit
ab1eb1a0dd
@ -148,6 +148,7 @@ func (g *game) Update(screen *ebiten.Image) error {
|
||||
|
||||
const d = 16
|
||||
toUpdateWindowSize := false
|
||||
toUpdateWindowPosition := false
|
||||
if ebiten.IsKeyPressed(ebiten.KeyShift) {
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyUp) {
|
||||
screenHeight += d
|
||||
@ -172,15 +173,19 @@ func (g *game) Update(screen *ebiten.Image) error {
|
||||
} else {
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyUp) {
|
||||
positionY -= d
|
||||
toUpdateWindowPosition = true
|
||||
}
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyDown) {
|
||||
positionY += d
|
||||
toUpdateWindowPosition = true
|
||||
}
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyLeft) {
|
||||
positionX -= d
|
||||
toUpdateWindowPosition = true
|
||||
}
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyRight) {
|
||||
positionX += d
|
||||
toUpdateWindowPosition = true
|
||||
}
|
||||
}
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyS) && !*flagAutoAdjusting {
|
||||
@ -262,7 +267,9 @@ func (g *game) Update(screen *ebiten.Image) error {
|
||||
}
|
||||
ebiten.SetMaxTPS(tps)
|
||||
ebiten.SetWindowDecorated(decorated)
|
||||
if toUpdateWindowPosition {
|
||||
ebiten.SetWindowPosition(positionX, positionY)
|
||||
}
|
||||
ebiten.SetWindowFloating(floating)
|
||||
ebiten.SetScreenClearedEveryFrame(screenCleared)
|
||||
if maximize && ebiten.IsWindowResizable() {
|
||||
|
Loading…
Reference in New Issue
Block a user