It's not true for AppKit, SwiftUI, GTK, Qt, WinUI, or Electron, and I'm not sure what's left.
It's not true for AppKit, SwiftUI, GTK, Qt, WinUI, or Electron, and I'm not sure what's left.
https://www.electronjs.org/docs/latest/api/app#apprequestsin...
and handle this event:
https://www.electronjs.org/docs/latest/api/app#event-second-...
I believe macos is the only OS that enforces single instance by default. If you start xterm five times on linux, you get five independent xterm processes.
It looks like macOS Finder tries to make it difficult to run two copies of a .app simultaneously, so I imagine many programs don't check for this case, but this is Hacker News, so we can use our hacker skills to try and do what they don't want us to: find the exe inside the bundle and run it directly from Finder, or run it from the terminal using its path. (This works for me with Ptacek's mdv app. Two copies of it end up in the dock.)
vscode, electron app, no problem opening multiple windows. Geany, gtk app, no problem opening multiple windows.
Can you give an example where this doesn't work?
But the point is that the developer has to build the app in a way that lets you do this.
Once again, there is no default with the tools I listed. You decide on how you want windowing to work and then build it.
At this point, show me examples of needing a mutex to "block" a multi-window default.
Just like you can start vim several times you can start gvim several times and have a few windows. This is the default behavior, and if the developer wants to change this for some reason, they need to put in some effort.
Maybe macOS is special? I'm not familiar with this platform.
You're wrong about GTK, Qt, WinUI and Electron though. They default to "do nothing" which eliminates the ability to even know that another instance exists. You have to manually program that.
Even in SwiftUI which has the simplest way to support multiple windows with zero work, the developer has to use WindowGroup, and if they didn't then you don't get to open more than one window.
TUI apps are multi-instance by default since the user can invoke the program in different pty sessions. The developer would have to actively fight that.
GUI SDKs generally require the developer to pick a solution. And it's easier to default to the simpler solution where you have one instance, one data model, one window.
Whether things might change in the future isn't relevant because we're talking about how things are today, not speculating about the future. And the time to change one's opinion is when reality changes, not ahead of time based on how you think things hopefully will be.
I don't know which GUIs you have programmed but for Windows and GNU/Linux this isn't the simplest option. It requires quite the effort to actually enforce single instance.
The merging behaviour is also in principle possible for TUIs, btw, it's just that nobody does it. But with something like tmux is would be easy to set up that all subsequent calls to your binary actually connect to the already open session launched by the first instance.