New window messages and parameters

Given the addition of new New open and window messages and parameters we are well on the way to being able to being able to build a window manager that allows tiddlers to be opened in additional browser windows. I am working on one right now, I plan to share, with a link here in this topic.

Currently I will need to add a close button to the opened window so that when a window is closed, it is removed from the open window list.

  • However if the user uses the windows close icon (top right) the window will be closed by the browser and the wiki will be “none the wiser” that the window was closed.

My Question(s)

  • Is there a way, or could be a way to detect the browser “closed” a given WindowID?
  • Alternatively is there a way to detect within the wiki if the window is no longer open?

My expectation
I do expect the answer to be “no” on the above two questions so I would then ask the following;

  • Is this even technically possible for tabs/windows to test the status of child window(s} it has opened?
    • Clearly tm-close-all-windows and tm-close-window suggest this may be possible
  • If so I believe this would be a helpful if we add such support into the next release of tiddlywiki
    • If we could also list the windows opened by the parent, a window manager would be more reliable.

[Edited] A related observation is zoom in and out in a window affects the parent window as well. This should be restricted to just the window.

Yes and Yes. … Internally, there is already a window-manager. Since TW allows the windows to interact with the main tab (eg: keyboard shortcuts), we need to keep track of the windows, for housekeeping. …

If the browser close window button is clicked, the browser sends an event to the window js-code, that it is “about to be closed”. So the window has a chance to “clean the house” to avoid memory leaks. …

I didn’t look at the code in detail. I only had a look if a “close” event is handled.
It should be possible to create a filter operator, that returns all open windows by IDs, because we have them already.

It should be possible to handle some “on-window-close actions”, which would make interactions with the main window easy. — This would be new core code.


The main problem is, that very fast (non human) interaction with the browser window API could trigger some browser watch-dogs.

The open new-widows API was mis-used in early browser days to “spam” users … eg: if a site has been closed it opened a flood of new windows with adverts… If those adds-windows where closed they did the same thing. (good old days, where AltaVista was the dominant search-enginge) … So you see the problem.

This behaviour has since been blocked on the browser level. In FF it’s under Settings → Privacy and Security → Block PopUp Windows … Which I think is ON by default. …

… So we need to avoid to wake up Cerberus :wink:

1 Like

Mario that would be good

With the existing tools ands messages I can do most of it, the only gap I can see is detecting if a window was closed by the window close button.

  • Although if the code exists to retrieve the list of open windows, updated when one or more is opened or closed I would not have have to maintain the list.
  • Perhaps a trigger when the list changes would help.