ig we can try again
This commit is contained in:
parent
22ec1278d3
commit
199c679238
3 changed files with 39 additions and 4 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -4124,6 +4124,7 @@ dependencies = [
|
|||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"uuid",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ freya = { git = "https://github.com/marc2332/freya.git", features = ["engine", "
|
|||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
mimalloc = "=0.1.52"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
windows-sys = { version = "0.60", features = ["Win32_UI_Shell", "Win32_Foundation"] }
|
||||
|
||||
[patch.crates-io]
|
||||
freya = { git = "https://github.com/marc2332/freya.git", branch = "fix/blur" }
|
||||
# Build then package (per OS):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub fn open_url(url: &str) {
|
||||
let result = {
|
||||
#[cfg(target_os = "linux")]
|
||||
|
|
@ -9,10 +10,6 @@ pub fn open_url(url: &str) {
|
|||
{
|
||||
std::process::Command::new("open").arg(url).spawn()
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
std::process::Command::new("explorer").arg(url).spawn()
|
||||
}
|
||||
};
|
||||
|
||||
if let Err(err) = result {
|
||||
|
|
@ -20,6 +17,40 @@ pub fn open_url(url: &str) {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn open_url(url: &str) {
|
||||
use std::os::windows::ffi::OsStrExt;
|
||||
use windows_sys::Win32::UI::Shell::ShellExecuteW;
|
||||
|
||||
// SW_SHOWNORMAL
|
||||
const SW_SHOWNORMAL: i32 = 1;
|
||||
|
||||
fn wide(s: &str) -> Vec<u16> {
|
||||
std::ffi::OsStr::new(s)
|
||||
.encode_wide()
|
||||
.chain(std::iter::once(0))
|
||||
.collect()
|
||||
}
|
||||
|
||||
let operation = wide("open");
|
||||
let file = wide(url);
|
||||
|
||||
let ret = unsafe {
|
||||
ShellExecuteW(
|
||||
std::ptr::null_mut(),
|
||||
operation.as_ptr(),
|
||||
file.as_ptr(),
|
||||
std::ptr::null(),
|
||||
std::ptr::null(),
|
||||
SW_SHOWNORMAL,
|
||||
)
|
||||
};
|
||||
|
||||
if (ret as isize) <= 32 {
|
||||
tracing::warn!("failed to open url {url}: ShellExecuteW returned {}", ret as isize);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_image_to_clipboard(path: std::path::PathBuf) {
|
||||
std::thread::spawn(move || {
|
||||
let img = match image::open(&path) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue