Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Only allow single instance of NoPorts Desktop on Windows #1713

Merged
merged 3 commits into from
Feb 3, 2025

Conversation

XavierChanth
Copy link
Member

@XavierChanth XavierChanth commented Jan 31, 2025

- What I did

  • Launching NoPorts Desktop will focus any existing instances instead of launching a new instance

The existing behavior:

  • Launch noports, onboard an atsign
  • close window (doesnt' kill current instance)
  • launch app again
  • new window

Desired behavior (that this PR provides):

  • Launch noports, onboard an atsign
  • close window (doesn't kill current instance)
  • launch app again
  • show existing window

Retained behavior:

  • When an atSign isn't onboarded and the window is closed, then it does kill the current instance.

- How I did it

- How to verify it

- Description for the changelog
fix: Only allow single instance of NoPorts Desktop on Windows

Comment on lines +18 to +24
HWND hwnd = ::FindWindow(kWindowClassName, kWindowName);
if (hwnd != NULL) {
::ShowWindow(hwnd, SW_NORMAL);
::SetForegroundWindow(hwnd);
return EXIT_FAILURE;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we find a window matching the default Flutter window class name && Titled "NoPorts Desktop" open that instead.

Comment on lines -19 to -20
constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved this to its .h file so we have access to it in main.cpp too.

@XavierChanth
Copy link
Member Author

I rebased 03d23e4 back onto trunk since it was based on a wildly divergent branch, then I retested.

@XavierChanth
Copy link
Member Author

XavierChanth commented Jan 31, 2025

I rebased 03d23e4 back onto trunk since it was based on a wildly divergent branch, then I retested.

Correction, I am retesting... VSCode cached commits... so they appeared in the build despite the rebase.

@XavierChanth
Copy link
Member Author

Okay, ready for review, tested with a git history that matches that of this PR.

Copy link
Member

@cconstab cconstab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built and tested on windows home and clean build odf windows.. Clicking the toolbar brings up the existing instance not a new one

@XavierChanth XavierChanth merged commit f50139e into trunk Feb 3, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unknown Error is shown when the user tries to onboard while having two instance of the app running.
4 participants