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

Call window close at com-exit #3004

Closed
nomennescio opened this issue May 27, 2024 · 24 comments
Closed

Call window close at com-exit #3004

nomennescio opened this issue May 27, 2024 · 24 comments

Comments

@nomennescio
Copy link
Contributor

When CTRL-Q or similar is pressed in the UI, com-exit is called, which currently has:

: com-exit ( -- ) 0 exit ;

However, this fails to close Window, which would prevent some code to dispose of resources to be triggered.

@mrjbq7 suggested:

: com-exit ( -- ) worlds get values [ [ close-window ] ignore-errors ] each 0 exit ; 
@nomennescio
Copy link
Contributor Author

It seems ungraft* is still not being called on ui.tools.listener even with 378fb18 and 7aa0e50

@mrjbq7
Copy link
Member

mrjbq7 commented May 27, 2024

Interesting, it appears M\ object close-window calls ungraft but the UI backends don't...

@mrjbq7
Copy link
Member

mrjbq7 commented May 27, 2024

So perhaps we should change it to have an inner backend close-window* and an outer close-window that calls ungraft before close-window*...

@nomennescio
Copy link
Contributor Author

It's nearly impossible for me to track this down, because using the Walker will cause a segmentation fault at certain points.
How do you debug this?

@mrjbq7
Copy link
Member

mrjbq7 commented May 27, 2024 via email

@nomennescio
Copy link
Contributor Author

Ye olde printf debugging

@nomennescio
Copy link
Contributor Author

Paper debugging is how I usually do it, however in this case the whole UI stack is relatively new to me, so will take significant time to work through. Have to pass on that for now.

@mrjbq7
Copy link
Member

mrjbq7 commented May 27, 2024 via email

@mrjbq7
Copy link
Member

mrjbq7 commented May 27, 2024

You know, I think it's sort of "working".

ungraft is being called, but it defers the ungraft* until later (ungraft-later), and we don't wait for that later before calling exit.

@nomennescio
Copy link
Contributor Author

nomennescio commented May 27, 2024

I couldn't check what the ungraft-later did, but then we would need to wait for it run.

@mrjbq7
Copy link
Member

mrjbq7 commented May 27, 2024

I mean we could also enqueue a close-later, but alternatively, we could add an ungraft-now...

@nomennescio
Copy link
Contributor Author

I think it all has to do with the whole native handling of windows, where you need to post messages and do stuff async, that we need to do things -later, isn't it? But then again, the whole Factor windowing stuff is new to me.

@mrjbq7
Copy link
Member

mrjbq7 commented May 27, 2024

the -later is largely to allow for "change a bunch of UI stuff" in one iteration of the UI thread message loop, then apply all the changes, then loop again. There are cases where do-it-now is useful.

@nomennescio
Copy link
Contributor Author

so why not just:

: ungraft-now ( gadget -- )
    dup [ ungraft-now ] each-child ungraft* ;

plus flushing the graft/ungraft queues?

@mrjbq7
Copy link
Member

mrjbq7 commented May 27, 2024 via email

@mrjbq7
Copy link
Member

mrjbq7 commented May 27, 2024

This calls ungraft* properly when com-end is called, but it doesn't seem to work with Cmd-Q on mac maybe?

4311024

@nomennescio
Copy link
Contributor Author

It does now work on Windows with CTRL-Q, thanks!

@nomennescio
Copy link
Contributor Author

Windows close button works now too!

@nomennescio
Copy link
Contributor Author

And ALT-F4 too!

It seems the whole feature is now working as expected!

@mrjbq7
Copy link
Member

mrjbq7 commented May 29, 2024

Ctrl-D works on windows

@nomennescio
Copy link
Contributor Author

Not really, it keeps the windows open.

I noticed your revert. Pity you don't want an alias for the user to type. Seemed like a good solution to me.

@nomennescio
Copy link
Contributor Author

a50f45c

and

831568a

@mrjbq7
Copy link
Member

mrjbq7 commented May 29, 2024

Ctrl-D works consistently on all platforms.

OS-specific commands (Cmd-Q / Alt-F4) work also.

Users can make their own words if they want that.

@nomennescio
Copy link
Contributor Author

nomennescio commented May 29, 2024

This was about having a command to type.

(for those people that expect such a command to exists. e.g. when starting factor from a shell)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants