fix(native): windows 0.61 API paths — repair the CI Windows compile
Four unresolved-import/type errors from the release build (first real compile): - toast.rs: generic IMap moved to the windows-collections crate; read the reply from the ValueSet returned by UserInput() directly (HasKey/Lookup are exposed on the class). - jumplist.rs: PROPVARIANT lives in Win32::System::Com::StructuredStorage (not windows::core); IObjectArray/IObjectCollection in Win32::System::Com (not UI::Shell); PKEY_Title in Win32::Storage::EnhancedStorage (feature added); build the title PROPVARIANT via From<&str> (VT_LPWSTR). - smtc.rs: event registrations return a plain i64 token in windows 0.61 (the EventRegistrationToken newtype is gone). - thumbbar.rs: HICON was imported inside the fn body but used in its signature — fully qualify the return type. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,7 @@ windows = { version = "0.61", features = [
|
|||||||
"UI_Notifications", # P5-41 WinRT toast notifications
|
"UI_Notifications", # P5-41 WinRT toast notifications
|
||||||
# Win32 namespaces
|
# Win32 namespaces
|
||||||
"Win32_Foundation",
|
"Win32_Foundation",
|
||||||
|
"Win32_Storage_EnhancedStorage", # P5-36 jump list (PKEY_Title)
|
||||||
"Win32_Graphics_Gdi",
|
"Win32_Graphics_Gdi",
|
||||||
"Win32_Networking_NetworkListManager", # P5-49 network awareness
|
"Win32_Networking_NetworkListManager", # P5-49 network awareness
|
||||||
"Win32_System_Com",
|
"Win32_System_Com",
|
||||||
|
|||||||
@@ -42,16 +42,17 @@ pub fn set_jump_list(app: AppHandle, items: Vec<JumpItem>) -> Result<(), String>
|
|||||||
|
|
||||||
use std::os::windows::ffi::OsStrExt;
|
use std::os::windows::ffi::OsStrExt;
|
||||||
use windows::{
|
use windows::{
|
||||||
core::{w, Interface, HSTRING, PCWSTR, PROPVARIANT},
|
core::{w, Interface, PCWSTR},
|
||||||
Win32::{
|
Win32::{
|
||||||
|
Storage::EnhancedStorage::PKEY_Title,
|
||||||
System::Com::{
|
System::Com::{
|
||||||
CoCreateInstance, CoInitializeEx, CoUninitialize, CLSCTX_INPROC_SERVER,
|
CoCreateInstance, CoInitializeEx, CoUninitialize, IObjectArray,
|
||||||
|
IObjectCollection, StructuredStorage::PROPVARIANT, CLSCTX_INPROC_SERVER,
|
||||||
COINIT_APARTMENTTHREADED,
|
COINIT_APARTMENTTHREADED,
|
||||||
},
|
},
|
||||||
UI::Shell::{
|
UI::Shell::{
|
||||||
DestinationList, EnumerableObjectCollection, ICustomDestinationList,
|
DestinationList, EnumerableObjectCollection, ICustomDestinationList,
|
||||||
IObjectArray, IObjectCollection, IShellLinkW, ShellLink,
|
IShellLinkW, PropertiesSystem::IPropertyStore, ShellLink,
|
||||||
PropertiesSystem::{IPropertyStore, PKEY_Title},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -109,7 +110,8 @@ pub fn set_jump_list(app: AppHandle, items: Vec<JumpItem>) -> Result<(), String>
|
|||||||
// The visible label comes from System.Title on the link's
|
// The visible label comes from System.Title on the link's
|
||||||
// property store (a bare IShellLink has no display name).
|
// property store (a bare IShellLink has no display name).
|
||||||
let store: IPropertyStore = link.cast()?;
|
let store: IPropertyStore = link.cast()?;
|
||||||
let title = PROPVARIANT::from(&HSTRING::from(item.title.as_str()));
|
// From<&str> builds a VT_LPWSTR PROPVARIANT (what System.Title expects).
|
||||||
|
let title = PROPVARIANT::from(item.title.as_str());
|
||||||
store.SetValue(&PKEY_Title, &title)?;
|
store.SetValue(&PKEY_Title, &title)?;
|
||||||
store.Commit()?;
|
store.Commit()?;
|
||||||
|
|
||||||
|
|||||||
@@ -38,8 +38,9 @@ struct Ev {
|
|||||||
struct SmtcState {
|
struct SmtcState {
|
||||||
controls: std::sync::Mutex<Option<windows::Media::SystemMediaTransportControls>>,
|
controls: std::sync::Mutex<Option<windows::Media::SystemMediaTransportControls>>,
|
||||||
// Kept alive so the ButtonPressed handler stays registered for the app's
|
// Kept alive so the ButtonPressed handler stays registered for the app's
|
||||||
// lifetime; never unregistered.
|
// lifetime; never unregistered. (windows 0.61 event registrations return a
|
||||||
_token: windows::Foundation::EventRegistrationToken,
|
// plain i64 token — the EventRegistrationToken newtype is gone.)
|
||||||
|
_token: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called once from `native::setup()`. Creates and configures the SMTC on
|
/// Called once from `native::setup()`. Creates and configures the SMTC on
|
||||||
|
|||||||
@@ -186,7 +186,10 @@ enum Glyph {
|
|||||||
/// added tooltip-only). `slashed` overlays a transparent diagonal cut to signal
|
/// added tooltip-only). `slashed` overlays a transparent diagonal cut to signal
|
||||||
/// the muted / deafened state.
|
/// the muted / deafened state.
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
fn make_icon(glyph: Glyph, slashed: bool) -> Option<HICON> {
|
fn make_icon(
|
||||||
|
glyph: Glyph,
|
||||||
|
slashed: bool,
|
||||||
|
) -> Option<windows::Win32::UI::WindowsAndMessaging::HICON> {
|
||||||
use windows::core::BOOL;
|
use windows::core::BOOL;
|
||||||
use windows::Win32::Foundation::COLORREF;
|
use windows::Win32::Foundation::COLORREF;
|
||||||
use windows::Win32::Graphics::Gdi::{
|
use windows::Win32::Graphics::Gdi::{
|
||||||
@@ -194,7 +197,7 @@ fn make_icon(glyph: Glyph, slashed: bool) -> Option<HICON> {
|
|||||||
DeleteDC, DeleteObject, Ellipse, GetDC, LineTo, MoveToEx, ReleaseDC, RoundRect,
|
DeleteDC, DeleteObject, Ellipse, GetDC, LineTo, MoveToEx, ReleaseDC, RoundRect,
|
||||||
SelectObject, BITMAPINFO, BITMAPINFOHEADER, BI_RGB, DIB_RGB_COLORS, PS_SOLID,
|
SelectObject, BITMAPINFO, BITMAPINFOHEADER, BI_RGB, DIB_RGB_COLORS, PS_SOLID,
|
||||||
};
|
};
|
||||||
use windows::Win32::UI::WindowsAndMessaging::{CreateIconIndirect, HICON, ICONINFO};
|
use windows::Win32::UI::WindowsAndMessaging::{CreateIconIndirect, ICONINFO};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let size = 32i32;
|
let size = 32i32;
|
||||||
|
|||||||
@@ -222,13 +222,14 @@ fn show_windows_toast(
|
|||||||
fn read_reply(
|
fn read_reply(
|
||||||
args: &windows::UI::Notifications::ToastActivatedEventArgs,
|
args: &windows::UI::Notifications::ToastActivatedEventArgs,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
use windows::core::{HSTRING, IInspectable, Interface};
|
use windows::core::{HSTRING, Interface};
|
||||||
use windows::Foundation::Collections::IMap;
|
|
||||||
use windows::Foundation::IReference;
|
use windows::Foundation::IReference;
|
||||||
|
|
||||||
// UserInput() is an IPropertySet (IMap<String, Object>); the text input value
|
// UserInput() returns a ValueSet; windows 0.61 exposes its IMap methods
|
||||||
// is boxed as an IReference<HSTRING>.
|
// (HasKey/Lookup) directly on the class (the generic IMap interface itself
|
||||||
let inputs: IMap<HSTRING, IInspectable> = args.UserInput().ok()?.cast().ok()?;
|
// moved to the separate windows-collections crate). The text input value is
|
||||||
|
// boxed as an IReference<HSTRING>.
|
||||||
|
let inputs = args.UserInput().ok()?;
|
||||||
let key = HSTRING::from("reply");
|
let key = HSTRING::from("reply");
|
||||||
if !inputs.HasKey(&key).ok()? {
|
if !inputs.HasKey(&key).ok()? {
|
||||||
return None;
|
return None;
|
||||||
|
|||||||
Reference in New Issue
Block a user