Putting a window in the background

Talk about code development, features, specific bugzilla bugs, enhancements, patches, and other highly technical things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific referenced Bugzilla bugs, mercurial, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Most "bug reports" do not belong in this board and should initially be posted in Community Support or other relevant support boards.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
Post Reply
Posts: 290
Joined: 2014-05-10, 18:19
Location: UK

Putting a window in the background

Post by thosrtanner » 2020-04-19, 16:26

When trawling through the code of openlinkin, I found that it implements 'openin in new background window' by
  • Opening a window
  • adding an "load" eventlistener to the new window, along with a comment that says "focus hasn't worked since firefox 3.5"
  • in the load handler, calling 'originalwindow.focus' and setting up a timer that will call it fifty times, once every 20ms
this seems a remarkably odd way of doing things. I tried fiddling to use the focus event after the load event rather than repeated timers, and I get the following strange sequence
  • i get a focus event. at which point I put the window to the background
  • the window goes to the background briefly, then gets another focus event
  • the window goes to the background, then goes to the foreground again, but no more focus events are generated
which, obviously, isn't very satisfactory either.

I'm wondering what changed in 3.5 and how the whole thing might be dealt with in a way that doesn't involve hitting with a stick repeatedly and hoping. Search on the internet suggests using newwindow.blur() might be effective, but that doesn't seem to make any difference I can see.

Post Reply