windows: Dock menu impl 2 (#26010)

Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
张小白 2025-03-06 20:40:34 +08:00 committed by GitHub
parent 84f4d2630f
commit 05df3d1bd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 163 additions and 62 deletions

View file

@ -217,29 +217,27 @@ fn main() {
let (open_listener, mut open_rx) = OpenListener::new();
let failed_single_instance_check =
if *db::ZED_STATELESS || *release_channel::RELEASE_CHANNEL == ReleaseChannel::Dev {
false
} else {
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
{
crate::zed::listen_for_cli_connections(open_listener.clone()).is_err()
}
let failed_single_instance_check = if *db::ZED_STATELESS
|| *release_channel::RELEASE_CHANNEL == ReleaseChannel::Dev
{
false
} else {
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
{
crate::zed::listen_for_cli_connections(open_listener.clone()).is_err()
}
#[cfg(target_os = "windows")]
{
!crate::zed::windows_only_instance::check_single_instance(
open_listener.clone(),
args.foreground,
)
}
#[cfg(target_os = "windows")]
{
!crate::zed::windows_only_instance::check_single_instance(open_listener.clone(), &args)
}
#[cfg(target_os = "macos")]
{
use zed::mac_only_instance::*;
ensure_only_instance() != IsOnlyInstance::Yes
}
};
#[cfg(target_os = "macos")]
{
use zed::mac_only_instance::*;
ensure_only_instance() != IsOnlyInstance::Yes
}
};
if failed_single_instance_check {
println!("zed is already running");
return;
@ -643,6 +641,11 @@ fn handle_open_request(request: OpenRequest, app_state: Arc<AppState>, cx: &mut
return;
}
if let Some(action_index) = request.dock_menu_action {
cx.perform_dock_menu_action(action_index);
return;
}
if let Some(connection_options) = request.ssh_connection {
cx.spawn(|mut cx| async move {
let paths_with_position =
@ -953,7 +956,14 @@ struct Args {
/// Run zed in the foreground, only used on Windows, to match the behavior of the behavior on macOS.
#[arg(long)]
#[cfg(target_os = "windows")]
#[arg(hide = true)]
foreground: bool,
/// The dock action to perform. This is used on Windows only.
#[arg(long)]
#[cfg(target_os = "windows")]
#[arg(hide = true)]
dock_action: Option<usize>,
}
#[derive(Clone, Debug)]