mirror of
https://github.com/wez/wezterm.git
synced 2024-11-29 01:34:46 +03:00
Use newer windows crate
This commit is contained in:
parent
9879005f87
commit
3b05dac0c6
52
Cargo.lock
generated
52
Cargo.lock
generated
@ -691,12 +691,6 @@ dependencies = [
|
|||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "const-sha1"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fb58b6451e8c2a812ad979ed1d83378caa5e927eef2622017a45f251457c2c9d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
@ -5015,30 +5009,46 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows"
|
name = "windows"
|
||||||
version = "0.11.0"
|
version = "0.33.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "25b270ca3fa1282aa091f122551348f8186f07888dffdfe64df17206ad3b56d0"
|
checksum = "0128fa8e65e0616e45033d68dc0b7fbd521080b7844e5cad3a4a4d201c4b2bd2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const-sha1",
|
"windows_aarch64_msvc",
|
||||||
"windows_gen",
|
"windows_i686_gnu",
|
||||||
"windows_macros",
|
"windows_i686_msvc",
|
||||||
|
"windows_x86_64_gnu",
|
||||||
|
"windows_x86_64_msvc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_gen"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.11.0"
|
version = "0.33.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44bd40154eb69ba3c80f11752494a2a34d1b448b06b80449238edfbd00ec7eef"
|
checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_macros"
|
name = "windows_i686_gnu"
|
||||||
version = "0.11.0"
|
version = "0.33.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bae6942e04aa5792bbf3b3cf5ded1b7590a7ffd76d53ea179210b87911b6587f"
|
checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e"
|
||||||
dependencies = [
|
|
||||||
"syn",
|
[[package]]
|
||||||
"windows_gen",
|
name = "windows_i686_msvc"
|
||||||
]
|
version = "0.33.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.33.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.33.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winreg"
|
name = "winreg"
|
||||||
|
@ -18,7 +18,6 @@ anyhow = "1.0"
|
|||||||
[target.'cfg(windows)'.build-dependencies]
|
[target.'cfg(windows)'.build-dependencies]
|
||||||
embed-resource = "1.3"
|
embed-resource = "1.3"
|
||||||
cc = "1.0"
|
cc = "1.0"
|
||||||
windows = "0.11"
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
@ -83,7 +82,6 @@ window = { path = "../window" }
|
|||||||
[target."cfg(windows)".dependencies]
|
[target."cfg(windows)".dependencies]
|
||||||
shared_library = "0.1"
|
shared_library = "0.1"
|
||||||
uds_windows = "1.0"
|
uds_windows = "1.0"
|
||||||
windows = "0.11"
|
|
||||||
winapi = { version = "0.3", features = [
|
winapi = { version = "0.3", features = [
|
||||||
"winuser",
|
"winuser",
|
||||||
"consoleapi",
|
"consoleapi",
|
||||||
@ -93,6 +91,9 @@ winapi = { version = "0.3", features = [
|
|||||||
"synchapi",
|
"synchapi",
|
||||||
"winsock2",
|
"winsock2",
|
||||||
]}
|
]}
|
||||||
|
windows = { version="0.33.0", features = [
|
||||||
|
"Win32_UI_Shell",
|
||||||
|
]}
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
k9 = "0.11.0"
|
k9 = "0.11.0"
|
||||||
|
@ -149,8 +149,6 @@ END
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
embed_resource::compile(rcfile_name);
|
embed_resource::compile(rcfile_name);
|
||||||
|
|
||||||
windows::build!(Windows::Win32::UI::Shell::SetCurrentProcessExplicitAppUserModelID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
@ -844,12 +844,6 @@ pub fn run_ls_fonts(config: config::ConfigHandle, cmd: &LsFontsCommand) -> anyho
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
mod win_bindings {
|
|
||||||
::windows::include_bindings!();
|
|
||||||
pub use self::Windows::Win32::UI::Shell::SetCurrentProcessExplicitAppUserModelID;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run() -> anyhow::Result<()> {
|
fn run() -> anyhow::Result<()> {
|
||||||
// Inform the system of our AppUserModelID.
|
// Inform the system of our AppUserModelID.
|
||||||
// Without this, our toast notifications won't be correctly
|
// Without this, our toast notifications won't be correctly
|
||||||
@ -857,7 +851,10 @@ fn run() -> anyhow::Result<()> {
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
win_bindings::SetCurrentProcessExplicitAppUserModelID("org.wezfurlong.wezterm").is_ok();
|
::windows::Win32::UI::Shell::SetCurrentProcessExplicitAppUserModelID(
|
||||||
|
::windows::core::PCWSTR(wide_string("org.wezfurlong.wezterm").as_ptr()),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,10 @@ core-foundation = "0.7"
|
|||||||
objc = "0.2"
|
objc = "0.2"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
windows = "0.11"
|
windows = { version="0.33.0", features = [
|
||||||
|
"Data_Xml_Dom",
|
||||||
|
"Foundation",
|
||||||
|
"UI_Notifications",
|
||||||
|
"Win32_Foundation",
|
||||||
|
]}
|
||||||
xml-rs = "0.8"
|
xml-rs = "0.8"
|
||||||
|
|
||||||
[target.'cfg(windows)'.build-dependencies]
|
|
||||||
windows = "0.11"
|
|
||||||
|
@ -2,13 +2,4 @@ fn main() {
|
|||||||
if cfg!(target_os = "macos") {
|
if cfg!(target_os = "macos") {
|
||||||
println!("cargo:rustc-link-lib=framework=UserNotifications");
|
println!("cargo:rustc-link-lib=framework=UserNotifications");
|
||||||
}
|
}
|
||||||
#[cfg(windows)]
|
|
||||||
{
|
|
||||||
windows::build!(
|
|
||||||
Windows::Data::Xml::Dom::XmlDocument,
|
|
||||||
Windows::Foundation::*,
|
|
||||||
Windows::UI::Notifications::*,
|
|
||||||
Windows::Win32::Foundation::E_POINTER,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,23 +3,18 @@
|
|||||||
use crate::ToastNotification as TN;
|
use crate::ToastNotification as TN;
|
||||||
use xml::escape::escape_str_pcdata;
|
use xml::escape::escape_str_pcdata;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
use windows::core::{Error as WinError, IInspectable, Interface, HSTRING};
|
||||||
mod bindings {
|
use windows::Data::Xml::Dom::XmlDocument;
|
||||||
::windows::include_bindings!();
|
use windows::Foundation::TypedEventHandler;
|
||||||
}
|
use windows::Win32::Foundation::E_POINTER;
|
||||||
|
use windows::UI::Notifications::{
|
||||||
use bindings::Windows::Data::Xml::Dom::XmlDocument;
|
ToastActivatedEventArgs, ToastNotification, ToastNotificationManager,
|
||||||
use bindings::Windows::Foundation::*;
|
};
|
||||||
use bindings::Windows::UI::Notifications::*;
|
|
||||||
use windows::{Error as WinError, IInspectable, Interface};
|
|
||||||
|
|
||||||
fn unwrap_arg<T>(a: &Option<T>) -> Result<&T, WinError> {
|
fn unwrap_arg<T>(a: &Option<T>) -> Result<&T, WinError> {
|
||||||
match a {
|
match a {
|
||||||
Some(t) => Ok(t),
|
Some(t) => Ok(t),
|
||||||
None => Err(WinError::new(
|
None => Err(WinError::new(E_POINTER, HSTRING::from("option is none"))),
|
||||||
crate::windows::bindings::Windows::Win32::Foundation::E_POINTER,
|
|
||||||
"option is none",
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +31,7 @@ fn show_notif_impl(toast: TN) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
""
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
xml.LoadXml(format!(
|
xml.LoadXml(HSTRING::from(format!(
|
||||||
r#"<toast duration="long">
|
r#"<toast duration="long">
|
||||||
<visual>
|
<visual>
|
||||||
<binding template="ToastGeneric">
|
<binding template="ToastGeneric">
|
||||||
@ -49,7 +44,7 @@ fn show_notif_impl(toast: TN) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
escape_str_pcdata(&toast.title),
|
escape_str_pcdata(&toast.title),
|
||||||
escape_str_pcdata(&toast.message),
|
escape_str_pcdata(&toast.message),
|
||||||
url_actions
|
url_actions
|
||||||
))?;
|
)))?;
|
||||||
|
|
||||||
let notif = ToastNotification::CreateToastNotification(xml)?;
|
let notif = ToastNotification::CreateToastNotification(xml)?;
|
||||||
|
|
||||||
@ -82,7 +77,9 @@ fn show_notif_impl(toast: TN) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}))?;
|
}))?;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let notifier = ToastNotificationManager::CreateToastNotifierWithId("org.wezfurlong.wezterm")?;
|
let notifier = ToastNotificationManager::CreateToastNotifierWithId(HSTRING::from(
|
||||||
|
"org.wezfurlong.wezterm",
|
||||||
|
))?;
|
||||||
|
|
||||||
notifier.Show(¬if)?;
|
notifier.Show(¬if)?;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub mod windows;
|
pub mod windows;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub use windows::*;
|
pub use self::windows::*;
|
||||||
|
|
||||||
#[cfg(feature = "wayland")]
|
#[cfg(feature = "wayland")]
|
||||||
pub mod wayland;
|
pub mod wayland;
|
||||||
|
@ -9,7 +9,7 @@ pub use connection::*;
|
|||||||
pub use event::*;
|
pub use event::*;
|
||||||
|
|
||||||
/// Convert a rust string to a windows wide string
|
/// Convert a rust string to a windows wide string
|
||||||
fn wide_string(s: &str) -> Vec<u16> {
|
pub fn wide_string(s: &str) -> Vec<u16> {
|
||||||
use std::os::windows::ffi::OsStrExt;
|
use std::os::windows::ffi::OsStrExt;
|
||||||
std::ffi::OsStr::new(s)
|
std::ffi::OsStr::new(s)
|
||||||
.encode_wide()
|
.encode_wide()
|
||||||
|
Loading…
Reference in New Issue
Block a user