Skip to content

Implement Single instance lock feature with passing arguments to initial instance #2951

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

Merged
merged 61 commits into from
Oct 23, 2023

Conversation

APshenkin
Copy link
Contributor

Description

Implements Single instance lock feature with additional passing arguments to initial instance #1351

There is implementation for single instance lock in V3 as plugin, but it doesn't allow to pass arguments of second instance to first one.

Now in V2 it's possible.
Also in plugin version there was option ActivateAppOnSubsequentLaunch. I decided to not put it here. As now we have callbacks when second instance is called, I think it should be on "developer" side how to treat this. For example somebody will want to handle it differently depends on what type of arguments were passed.

Also in addition Windows runtime.Show() and runtime.WindowUnminimise() were modified for better handling different scenarios related to change focus of apps.

You can see how it works here.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Test repo is available here https://github.com/APshenkin/wails-open-file/tree/feature/single-lock
PR should be fetched and replace in go.mod should be adjusted

  • Windows
  • macOS
  • Linux

Test Configuration

# Wails
Version  | v2.6.0
Revision | a419721dcdf16da7a4afd92b9ba63b2050229a26
Modified | true

# System
┌─────────────────────────┐
| OS           | MacOS    |
| Version      | 13.5.2   |
| ID           | 22G91    |
| Go Version   | go1.20.2 |
| Platform     | darwin   |
| Architecture | arm64    |
└─────────────────────────┘


# System
┌────────────────────────────────────┐
| OS           | Windows 10 Pro      |
| Version      | 2009 (Build: 22621) |
| ID           | 22H2                |
| Go Version   | go1.21.1            |
| Platform     | windows             |
| Architecture | arm64               |
└────────────────────────────────────┘                         

# System
┌────────────────────────────────────┐
| OS           | Ubuntu              |
| Version      | 22.04               |
| ID           | ubuntu              |
| Go Version   | go1.21.1            |
| Platform     | linux               |
| Architecture | arm64               |
└────────────────────────────────────┘

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@APshenkin
Copy link
Contributor Author

APshenkin commented Sep 28, 2023

Should be reviewed after #2918 merged

@APshenkin APshenkin marked this pull request as ready for review October 21, 2023 20:20
@APshenkin
Copy link
Contributor Author

APshenkin commented Oct 21, 2023

@leaanthony Maybe we can take a look on this too?

Also I have one more PR to enable custom url protocols support in wails as well 🚀
Will raise it once this one merged

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

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

Looks good on the whole. I have a few questions. Keen to hear what @stffabi and @tmclane think.

Copy link
Member

@tmclane tmclane left a comment

Choose a reason for hiding this comment

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

I would recommend setting this to one because all that means is that if two messages are sent at the same time the second routine sending will block until the first message is processed. Setting it higher only ensures that the caller doesn't block on sending up to the limit.

Copy link
Collaborator

@stffabi stffabi left a comment

Choose a reason for hiding this comment

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

LGTM, that's an awesome PR thanks @APshenkin 🙏

I only added two minor comments regarding the Windows code.

@APshenkin
Copy link
Contributor Author

@tmclane Make sense. Updated to set it to one

@leaanthony @stffabi @tmclane
All your comments are addressed, please check PR again 🙂

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

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

👍 from me

@leaanthony leaanthony merged commit c24bd5e into wailsapp:master Oct 23, 2023
@leaanthony
Copy link
Member

Thanks for the awesome PR 🙏

@stffabi
Copy link
Collaborator

stffabi commented Oct 23, 2023

Awesome, thanks for your time @APshenkin

@APshenkin APshenkin deleted the feature/single-lock branch October 23, 2023 11:47
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.

4 participants