ATT-21 single instance: a later launch brings the running at-terminal forward #5
Loading…
Reference in a new issue
No description provided.
Delete branch "ATT-21-single-instance"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Work package: https://openproject.home.romaine.life/wp/ATT-21 (part of https://openproject.home.romaine.life/wp/ATT-19)
One at-terminal per user: launching it again, by any command line, runs nothing and brings the running window forward (AT-TERMINAL.md's "Launching it again"). Rio had no single-instance handling; every launch was a new process.
What changes
rioterminstance.rs: a launch claims a per-user name before anything else. Windows: a named pipe\.\pipe\at-terminal-<USERNAME>, created withFILE_FLAG_FIRST_PIPE_INSTANCE, local clients only. macOS and Linux: a Unix socketat-terminal-<uid>.sockinXDG_RUNTIME_DIR(or the temp dir); a socket nobody answers (left by an instance that ended) is taken over. The first launch serves the name on a thread; a later one sendsforwardand exits. On Windows the later launch first callsAllowSetForegroundWindow(ASFW_ANY), so the running one may take the foreground Windows would otherwise keep for the launcher.main.rs: the claim, and aforwardsends the event loopCreateWindow, which the router (one window since #3) turns into bringing the window forward.windows-sysgainsWin32_System_PipesandWin32_Storage_FileSystem.Tests:
a_second_launch_brings_the_first_forward(two later launches, each delivered), and on Unixa_socket_left_by_an_ended_instance_is_taken_over. Run five times in a row on upstairspc, all passing.Checked on upstairspc (Windows): fmt, clippy
-D warnings, the tests. nelsonpc builds nothing. CI covers the Unix socket on Linux.Only a real desktop shows: the window actually coming to the front over another app (ATT-23 adds the Windows foreground handling, including minimizing what's behind it).