Skip to content

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

Merged
leaanthony merged 61 commits into
wailsapp:masterfrom
APshenkin:feature/single-lock
Oct 23, 2023
Merged

leaanthony merged 61 commits into
wailsapp:masterfrom
APshenkin:feature/single-lock

Conversation

@APshenkin

Copy link
Copy Markdown
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

APshenkin commented Sep 28, 2023 •

Copy link
Copy Markdown
Contributor Author

Should be reviewed after #2918 merged

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

APshenkin commented Oct 21, 2023 •

Copy link
Copy Markdown
Contributor Author

@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

@leaanthony leaanthony left a comment

Copy link
Copy Markdown
Member

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.

Comment thread v2/pkg/options/options.go Resolved

@tmclane tmclane left a comment

Copy link
Copy Markdown
Contributor

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.

@stffabi stffabi left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

@tmclane Make sense. Updated to set it to one

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

@leaanthony leaanthony left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

Thanks for the awesome PR 🙏

@stffabi

stffabi commented Oct 23, 2023

Copy link
Copy Markdown
Contributor

Awesome, thanks for your time @APshenkin

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