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

[Feature Request] Activate Instance #10

Open
SonnyX opened this issue Feb 15, 2021 · 9 comments
Open

[Feature Request] Activate Instance #10

SonnyX opened this issue Feb 15, 2021 · 9 comments

Comments

@SonnyX
Copy link

SonnyX commented Feb 15, 2021

Since both Linux and Windows now use something akin of domains, it makes me believe it should be somewhat possible to implement a function that brings the window to the foreground.

@WLBF
Copy link
Owner

WLBF commented Feb 15, 2021

I dont fully understand what you said brings the window to the foreground, Can you explain more detail about what you are proposing?

@SonnyX
Copy link
Author

SonnyX commented Feb 15, 2021

A function that if another instance exists, and if that Instance has a GUI, to bring the GUI to the foreground (in case it is minimized or hidden)

@WLBF
Copy link
Owner

WLBF commented Feb 15, 2021

Very interesting idea. I will do some research on this, although I probably would not add this kind of complex feature to this simple crate.

@WLBF
Copy link
Owner

WLBF commented Feb 15, 2021

One solution I can imagine is use unix domain socket inform another instance.

@SonnyX
Copy link
Author

SonnyX commented Feb 15, 2021

The same potentially with Windows named pipes, unless there is another way to get the window handle.

@WLBF WLBF closed this as completed Jun 24, 2021
@ottosson
Copy link

I would very much love to see this feature as well. Why was it closed?

Thanks!

@betamos
Copy link

betamos commented May 3, 2022

+1! I'm looking for single-instance in my Tauri app. When a user tries to open a new instance, it should bring focus to the existing application.

However, seeing this is a low-level utility (you wouldn't even need a GUI app at all) it wouldn't make sense to try to foreground an application from this crate. However, what would work is if the existing instance got a notification that another instance has been requested, perhaps as a receiving channel + canceler API. This would be sufficient to pipe through the request and do the appropriate thing.

Note that this would have tremendous value even if it wasn't supported on all platforms. For instance, MacOS already has deduplication so it's never a problem in practice (afaik). Windows is certainly the most useful one, probably followed by Linux.

Please consider reopening this.

@WLBF WLBF reopened this May 3, 2022
@nu11ptr
Copy link

nu11ptr commented Sep 2, 2022

A potential workaround until this feature is added: what is really needed is a "platform independent IPC". It looks like there is a crate that does this: interprocess. My plan is to use this crate plus that one (haven't tried yet, but seems like it should work). At that point, the first process could take any action needed in a GUI independent manner once notified including restoring a GUI window, etc.

@Hellager
Copy link

+1! I'm looking for single-instance in my Tauri app. When a user tries to open a new instance, it should bring focus to the existing application.

However, seeing this is a low-level utility (you wouldn't even need a GUI app at all) it wouldn't make sense to try to foreground an application from this crate. However, what would work is if the existing instance got a notification that another instance has been requested, perhaps as a receiving channel + canceler API. This would be sufficient to pipe through the request and do the appropriate thing.

Note that this would have tremendous value even if it wasn't supported on all platforms. For instance, MacOS already has deduplication so it's never a problem in practice (afaik). Windows is certainly the most useful one, probably followed by Linux.

Please consider reopening this.

Hi there, i wonder have you already tried using this crate in your app? I'm trying add this to my tauri app, it works well in pure rust, but seems to be not working in tauri. I tried like this

#[tauri::command]
fn check_instance() -> bool {
    let instance = SingleInstance::new("tauri-app").unwrap();
    println!("check instance whether single {}", instance.is_single());
   
    instance.is_single()
}

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

No branches or pull requests

6 participants