mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 19:58:54 +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) {
|
if inpututil.IsKeyJustPressed(ebiten.KeyI) {
|
||||||
ebiten.SetWindowIcon([]image.Image{createRandomIconImage()})
|
ebiten.SetWindowIcon([]image.Image{createRandomIconImage()})
|
||||||
}
|
}
|
||||||
|
if inpututil.IsKeyJustPressed(ebiten.KeyJ) {
|
||||||
|
ebiten.SetWindowIcon(nil)
|
||||||
|
}
|
||||||
|
|
||||||
ebiten.SetWindowMousePassthrough(mousePassthrough)
|
ebiten.SetWindowMousePassthrough(mousePassthrough)
|
||||||
|
|
||||||
@ -358,6 +361,7 @@ func (g *game) Draw(screen *ebiten.Image) {
|
|||||||
[U] Switch the runnable-on-unfocused state
|
[U] Switch the runnable-on-unfocused state
|
||||||
[C] Switch the cursor mode (visible, hidden, or captured)
|
[C] Switch the cursor mode (visible, hidden, or captured)
|
||||||
[I] Change the window icon (only for desktops)
|
[I] Change the window icon (only for desktops)
|
||||||
|
[J] Reset the window icon (only for desktops)
|
||||||
[V] Switch the vsync
|
[V] Switch the vsync
|
||||||
[T] Switch TPS (ticks per second)
|
[T] Switch TPS (ticks per second)
|
||||||
[D] Switch the window decoration (only for desktops)
|
[D] Switch the window decoration (only for desktops)
|
||||||
|
@ -1559,6 +1559,9 @@ func (w *Window) platformSetWindowIcon(images []*Image) error {
|
|||||||
if len(images) > 0 {
|
if len(images) > 0 {
|
||||||
w.platform.bigIcon = bigIcon
|
w.platform.bigIcon = bigIcon
|
||||||
w.platform.smallIcon = smallIcon
|
w.platform.smallIcon = smallIcon
|
||||||
|
} else {
|
||||||
|
w.platform.bigIcon = 0
|
||||||
|
w.platform.smallIcon = 0
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1204,11 +1204,17 @@ func (u *userInterfaceImpl) updateIconIfNeeded() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
imgs := u.getAndResetIconImages()
|
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
|
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 {
|
for i, img := range imgs {
|
||||||
// TODO: If img is not *ebiten.Image, this converting is not necessary.
|
// TODO: If img is not *ebiten.Image, this converting is not necessary.
|
||||||
// However, this package cannot refer *ebiten.Image due to the package
|
// However, this package cannot refer *ebiten.Image due to the package
|
||||||
|
Loading…
Reference in New Issue
Block a user