From 70c036a23625851e3cf325c75805620184d33900 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Wed, 26 Aug 2026 10:36:37 +0100 Subject: [PATCH] wezterm-open-url: Replace winapi with windows-sys (#8101) --- Cargo.lock | 2 +- wezterm-open-url/Cargo.toml | 7 +++++-- wezterm-open-url/src/lib.rs | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 81c2b0b8f..cfa9fa6c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7260,7 +7260,7 @@ dependencies = [ name = "wezterm-open-url" version = "0.1.0" dependencies = [ - "winapi", + "windows-sys 0.61.2", ] [[package]] diff --git a/wezterm-open-url/Cargo.toml b/wezterm-open-url/Cargo.toml index a5759e2ba..08b28f5fa 100644 --- a/wezterm-open-url/Cargo.toml +++ b/wezterm-open-url/Cargo.toml @@ -6,5 +6,8 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[dependencies] -winapi = {workspace=true, features=["shellapi"]} +[target."cfg(windows)".dependencies] +windows-sys = { workspace = true, features = [ + "Win32_UI_Shell", + "Win32_UI_WindowsAndMessaging", +] } \ No newline at end of file diff --git a/wezterm-open-url/src/lib.rs b/wezterm-open-url/src/lib.rs index 9a61fd947..70354a16e 100644 --- a/wezterm-open-url/src/lib.rs +++ b/wezterm-open-url/src/lib.rs @@ -57,7 +57,9 @@ pub fn open_with(url: &str, app: &str) { #[cfg(windows)] fn shell_execute(url: String, with: Option) { use std::os::windows::ffi::OsStrExt; - use winapi::um::shellapi::ShellExecuteW; + use windows_sys::Win32::UI::Shell::ShellExecuteW; + use windows_sys::Win32::UI::WindowsAndMessaging::SW_SHOW; + /// Convert a rust string to a windows wide string fn wide_string(s: &str) -> Vec { std::ffi::OsStr::new(s) @@ -83,7 +85,7 @@ fn shell_execute(url: String, with: Option) { app, path, std::ptr::null(), - winapi::um::winuser::SW_SHOW, + SW_SHOW, ); } });