Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window doesn't render when called for the first time from system tray and the last window was closed #4163

Closed
2 tasks done
mbaklor opened this issue Aug 16, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@mbaklor
Copy link
Contributor

mbaklor commented Aug 16, 2023

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

I have an app set up with a system tray and splash screen, where the main window is hidden on startup until you open it from the systray. What I found is that if I don't render the window before the splash screen closes the window won't render. On windows by resizing it renders, on ubuntu it doesn't even do that.

I did find that using Hide on the splash screen instead of Close avoids the issue, so it's something about the last visibly window calling Close I guess? Couldn't find anything I could understand in the sources.

How to reproduce

build an app with a splash screen, no other window showing on startup, and a systray to open a window.

Screenshots

I'm not on my windows machine now so I'll grab that later but here's the linux:
image

Example code

func main() {
	a := app.New()
	label := widget.NewLabel("Window with content!")
	win := a.NewWindow("Render Test")
	win.SetContent(label)
	showWin := fyne.NewMenuItem("Show win", func() {
		win.Show()
	})
	menu := fyne.NewMenu("tray", showWin)

	if desk, ok := a.(desktop.App); ok {
		desk.SetSystemTrayMenu(menu)
	}
	if drv, ok := a.Driver().(desktop.Driver); ok {
		splash := drv.CreateSplashWindow()
		splash.SetContent(widget.NewLabel("Splash with content!"))
		splash.Show()
		go func() {
			time.Sleep(time.Second * 3)
			splash.Close()
		}()
	}
	win.SetCloseIntercept(func() {
		win.Hide()
	})
	a.Run()
}

Fyne version

both latest (2.3.5) and develop (v2.3.6-0.20230815202934-6f2c727d711a)

Go compiler version

1.20.5

Operating system and version

windows 11, 10, kubuntu 5.27.4

Additional Information

No response

@mbaklor mbaklor added the unverified A bug that has been reported but not verified label Aug 16, 2023
@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Aug 17, 2023
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Aug 18, 2023
@andydotxyz
Copy link
Member

Fixed on develop

@mbaklor
Copy link
Contributor Author

mbaklor commented Aug 24, 2023

@andydotxyz looks like this is still happening on develop (v2.3.6-0.20230824093032-28ab69056a4c), I think the problem isn't a window being reused but a window being rendered for the first time after the last existing window (besides the systray monitor) is closed

This is what it looks like on my windows machine
image

@andydotxyz
Copy link
Member

I have re-tweaked the order of the code since other changes landed. Fix should be back again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants