-
Notifications
You must be signed in to change notification settings - Fork 306
Description
Since 2.1.4, QZ Tray offers the ability to "steal" another instance, which is helpful in multi-user environments, however for technical reasons, the qz:steal
URL behavior/feature will not work on MacOS.
More information here:
https://stackoverflow.com/questions/27435606
Quoting the accepted answer:
Note that your URI handler will be called in the currently running instance of you app or will first create a new instance of your app then get called. The OpenURIEvent will contain the entire URI message you send.
This means we can capture the call to qz:steal
via:
// app.setOpenURIHandler(this);
@Override
public void openURI(final com.apple.eawt.AppEvent.OpenURIEvent oue) {
// perform action
}
... however this event is proprietary to Apple, the code won't compile on Windows or Linux, requiring some elaborate proxying.
Fortunately, Java 9 offers an API to handle this gracefully, we do this for some of our other proprietary Apple APIs, but getting both of these tested requires Custom URL registration between trial and error attempts (i.e. a full ant pkgbuild
and watching the logs between each change)
Another caveat is that this technique causes QZ Tray to start asynchronously of it's startup handling, possibly causing a race between SingleInstanceChecker
and PrintSocketServer
, so safe, synchronized techniques must be used.