oakmound / oak

A pure Go game engine
Apache License 2.0
1.53k stars 83 forks source link

Q: respond to close window click on linux? #153

Closed glycerine closed 3 years ago

glycerine commented 3 years ago

Just wondering how my app can respond to the user clicking the close window X button (kubuntu 18.04) in the outermost window corner. On OSX the window shuts down automatically, but not in x11. I couldn't locate a message or callback to handle this. Can someone point it out?

200sc commented 3 years ago

The event to respond to for manual resource cleanup should be event.OnStop (https://github.com/oakmound/oak/blob/master/event/strings.go#L33).

But the window should close regardless. Let me know if this isn't getting triggered, I can look into it in the internals to see if there's a bug there.

glycerine commented 3 years ago

Thanks Patrick! I'll try that. For me, on x11, clicking the close window button currently has no effect at all.

200sc commented 3 years ago

I somehow missed the last comment on this issue, and will be looking into this shortly.

200sc commented 3 years ago

On my usual box (cinnamon) the x button does close the window, I'll get a kubuntu image and test that out.

200sc commented 3 years ago

Failed to replicate on kubuntu as well. What I did:

  1. Downloaded kubuntu image
  2. Installed on virtual box instance
  3. Downloaded Go 1.16.5
  4. Checked out Oak v3 via go get github.com/oakmound/oak/v3@latest
  5. Ran pong example
  6. X closed window successfully

Again, sorry for taking so long for getting to this. Screenshot of the kubuntu version I used:

Screenshot from 2021-06-13 08-43-49

glycerine commented 3 years ago

so might be a kubuntu version thing. thanks for letting me know.

200sc commented 3 years ago

Scratch that, I actually replicated this on mint, looking into supporting multi-window on linux. We never called Release on windows when they were manually closed.

I never saw it in my previous testing because the program would always exit after oak.Init exited.