mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
internal/ui: bug fix: SetWindowIcon(nil) didn't reset the window icon
Closes #2796
This commit is contained in:
parent
13dfb28a98
commit
dce18d7c23
@ -307,6 +307,9 @@ func (g *game) Update() error {
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyI) {
|
||||
ebiten.SetWindowIcon([]image.Image{createRandomIconImage()})
|
||||
}
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyJ) {
|
||||
ebiten.SetWindowIcon(nil)
|
||||
}
|
||||
|
||||
ebiten.SetWindowMousePassthrough(mousePassthrough)
|
||||
|
||||
@ -358,6 +361,7 @@ func (g *game) Draw(screen *ebiten.Image) {
|
||||
[U] Switch the runnable-on-unfocused state
|
||||
[C] Switch the cursor mode (visible, hidden, or captured)
|
||||
[I] Change the window icon (only for desktops)
|
||||
[J] Reset the window icon (only for desktops)
|
||||
[V] Switch the vsync
|
||||
[T] Switch TPS (ticks per second)
|
||||
[D] Switch the window decoration (only for desktops)
|
||||
|
@ -1559,6 +1559,9 @@ func (w *Window) platformSetWindowIcon(images []*Image) error {
|
||||
if len(images) > 0 {
|
||||
w.platform.bigIcon = bigIcon
|
||||
w.platform.smallIcon = smallIcon
|
||||
} else {
|
||||
w.platform.bigIcon = 0
|
||||
w.platform.smallIcon = 0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -1204,11 +1204,17 @@ func (u *userInterfaceImpl) updateIconIfNeeded() error {
|
||||
}
|
||||
|
||||
imgs := u.getAndResetIconImages()
|
||||
if len(imgs) == 0 {
|
||||
// A 0-size slice and nil are distinguished here.
|
||||
// A 0-size slice means a user indicates to reset the icon.
|
||||
// On the other hand, nil means a user didn't update the icon state.
|
||||
if imgs == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
newImgs := make([]image.Image, len(imgs))
|
||||
var newImgs []image.Image
|
||||
if len(imgs) > 0 {
|
||||
newImgs = make([]image.Image, len(imgs))
|
||||
}
|
||||
for i, img := range imgs {
|
||||
// TODO: If img is not *ebiten.Image, this converting is not necessary.
|
||||
// However, this package cannot refer *ebiten.Image due to the package
|
||||
|
Loading…
Reference in New Issue
Block a user