Skip to content

Commit

Permalink
chore(deps): update window-sys to 0.59
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Aug 15, 2024
1 parent d407869 commit 8d5b980
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ thiserror = "1.0"
serde = { version = "1", optional = true }

[target."cfg(target_os = \"windows\")".dependencies.windows-sys]
version = "0.52"
version = "0.59"
features = [
"Win32_UI_WindowsAndMessaging",
"Win32_Foundation",
Expand Down
2 changes: 1 addition & 1 deletion src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl Icon {
/// Create an icon from an HICON
#[cfg(windows)]
pub fn from_handle(handle: isize) -> Self {
let win_icon = PlatformIcon::from_handle(handle);
let win_icon = PlatformIcon::from_handle(handle as _);
Icon { inner: win_icon }
}
}
30 changes: 15 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ pub struct TrayIconAttributes {
/// ## Platform-specific
///
/// - **Linux:** The title will not be shown unless there is an icon
/// as well. The title is useful for numerical and other frequently
/// updated information. In general, it shouldn't be shown unless a
/// user requests it as it can take up a significant amount of space
/// on the user's panel. This may not be shown in all visualizations.
/// as well. The title is useful for numerical and other frequently
/// updated information. In general, it shouldn't be shown unless a
/// user requests it as it can take up a significant amount of space
/// on the user's panel. This may not be shown in all visualizations.
/// - **Windows:** Unsupported.
pub title: Option<String>,
}
Expand Down Expand Up @@ -216,7 +216,7 @@ impl TrayIconBuilder {
/// ## Platform-specific:
///
/// - **Linux:** Sometimes the icon won't be visible unless a menu is set.
/// Setting an empty [`Menu`](crate::menu::Menu) is enough.
/// Setting an empty [`Menu`](crate::menu::Menu) is enough.
pub fn with_icon(mut self, icon: Icon) -> Self {
self.attrs.icon = Some(icon);
self
Expand All @@ -237,10 +237,10 @@ impl TrayIconBuilder {
/// ## Platform-specific
///
/// - **Linux:** The title will not be shown unless there is an icon
/// as well. The title is useful for numerical and other frequently
/// updated information. In general, it shouldn't be shown unless a
/// user requests it as it can take up a significant amount of space
/// on the user's panel. This may not be shown in all visualizations.
/// as well. The title is useful for numerical and other frequently
/// updated information. In general, it shouldn't be shown unless a
/// user requests it as it can take up a significant amount of space
/// on the user's panel. This may not be shown in all visualizations.
/// - **Windows:** Unsupported.
pub fn with_title<S: AsRef<str>>(mut self, title: S) -> Self {
self.attrs.title.replace(title.as_ref().to_string());
Expand Down Expand Up @@ -295,7 +295,7 @@ impl TrayIcon {
/// ## Platform-specific:
///
/// - **Linux:** Sometimes the icon won't be visible unless a menu is set.
/// Setting an empty [`Menu`](crate::menu::Menu) is enough.
/// Setting an empty [`Menu`](crate::menu::Menu) is enough.
pub fn new(attrs: TrayIconAttributes) -> Result<Self> {
let id = TrayIconId(COUNTER.next().to_string());
Ok(Self {
Expand Down Expand Up @@ -354,10 +354,10 @@ impl TrayIcon {
/// ## Platform-specific:
///
/// - **Linux:** The title will not be shown unless there is an icon
/// as well. The title is useful for numerical and other frequently
/// updated information. In general, it shouldn't be shown unless a
/// user requests it as it can take up a significant amount of space
/// on the user's panel. This may not be shown in all visualizations.
/// as well. The title is useful for numerical and other frequently
/// updated information. In general, it shouldn't be shown unless a
/// user requests it as it can take up a significant amount of space
/// on the user's panel. This may not be shown in all visualizations.
/// - **Windows:** Unsupported
pub fn set_title<S: AsRef<str>>(&self, title: Option<S>) {
self.tray.borrow_mut().set_title(title)
Expand Down Expand Up @@ -410,7 +410,7 @@ impl TrayIcon {
/// ## Platform-specific:
///
/// - **Linux**: Unsupported. The event is not emmited even though the icon is shown
/// and will still show a context menu on right click.
/// and will still show a context menu on right click.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
Expand Down
11 changes: 6 additions & 5 deletions src/platform_impl/windows/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl RgbaIcon {
assert_eq!(and_mask.len(), pixel_count);
let handle = unsafe {
CreateIcon(
0,
std::ptr::null_mut(),
self.width as i32,
self.height as i32,
1,
Expand All @@ -46,7 +46,7 @@ impl RgbaIcon {
rgba.as_ptr(),
)
};
if handle != 0 {
if !handle.is_null() {
Ok(WinIcon::from_handle(handle))
} else {
Err(BadIcon::OsError(io::Error::last_os_error()))
Expand Down Expand Up @@ -78,6 +78,7 @@ impl WinIcon {

pub(crate) fn from_handle(handle: HICON) -> Self {
Self {
#[allow(clippy::arc_with_non_send_sync)]
inner: Arc::new(RaiiIcon { handle }),
}
}
Expand All @@ -93,15 +94,15 @@ impl WinIcon {

let handle = unsafe {
LoadImageW(
0,
std::ptr::null_mut(),
wide_path.as_ptr(),
IMAGE_ICON,
width as i32,
height as i32,
LR_DEFAULTSIZE | LR_LOADFROMFILE,
)
};
if handle != 0 {
if !handle.is_null() {
Ok(WinIcon::from_handle(handle as HICON))
} else {
Err(BadIcon::OsError(io::Error::last_os_error()))
Expand All @@ -121,7 +122,7 @@ impl WinIcon {
LR_DEFAULTSIZE,
)
};
if handle != 0 {
if !handle.is_null() {
Ok(WinIcon::from_handle(handle as HICON))
} else {
Err(BadIcon::OsError(io::Error::last_os_error()))
Expand Down
22 changes: 11 additions & 11 deletions src/platform_impl/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ impl TrayIcon {
let traydata = TrayUserData {
id,
internal_id,
hwnd: 0,
hpopupmenu: attrs.menu.as_ref().map(|m| m.hpopupmenu()),
hwnd: std::ptr::null_mut(),
hpopupmenu: attrs.menu.as_ref().map(|m| m.hpopupmenu() as _),
icon: attrs.icon.clone(),
tooltip: attrs.tooltip.clone(),
entered: false,
Expand All @@ -111,12 +111,12 @@ impl TrayIcon {
0,
CW_USEDEFAULT,
0,
HWND::default(),
HMENU::default(),
std::ptr::null_mut(),
std::ptr::null_mut(),
hinstance,
Box::into_raw(Box::new(traydata)) as _,
);
if hwnd == 0 {
if hwnd.is_null() {
return Err(crate::Error::OsError(std::io::Error::last_os_error()));
}

Expand All @@ -127,7 +127,7 @@ impl TrayIcon {
}

if let Some(menu) = &attrs.menu {
menu.attach_menu_subclass_for_hwnd(hwnd);
menu.attach_menu_subclass_for_hwnd(hwnd as _);
}

Ok(Self {
Expand Down Expand Up @@ -169,11 +169,11 @@ impl TrayIcon {

pub fn set_menu(&mut self, menu: Option<Box<dyn menu::ContextMenu>>) {
if let Some(menu) = &self.menu {
menu.detach_menu_subclass_from_hwnd(self.hwnd);
menu.detach_menu_subclass_from_hwnd(self.hwnd as _);
}

if let Some(menu) = &menu {
menu.attach_menu_subclass_for_hwnd(self.hwnd);
menu.attach_menu_subclass_for_hwnd(self.hwnd as _);
}

unsafe {
Expand Down Expand Up @@ -251,7 +251,7 @@ impl Drop for TrayIcon {
remove_tray_icon(self.hwnd, self.internal_id);

if let Some(menu) = &self.menu {
menu.detach_menu_subclass_from_hwnd(self.hwnd);
menu.detach_menu_subclass_from_hwnd(self.hwnd as _);
}

// destroy the hidden window used by the tray
Expand Down Expand Up @@ -292,7 +292,7 @@ unsafe extern "system" fn tray_proc(
}
WM_USER_UPDATE_TRAYMENU => {
let hpopupmenu = Box::from_raw(wparam as *mut Option<isize>);
userdata.hpopupmenu = *hpopupmenu;
userdata.hpopupmenu = (*hpopupmenu).map(|h| h as *mut _);
}
WM_USER_UPDATE_TRAYICON => {
let icon = Box::from_raw(wparam as *mut Option<Icon>);
Expand Down Expand Up @@ -486,7 +486,7 @@ unsafe fn register_tray_icon(
hicon: &Option<HICON>,
tooltip: &Option<String>,
) -> bool {
let mut h_icon = 0;
let mut h_icon = std::ptr::null_mut();
let mut flags = NIF_MESSAGE;
let mut sz_tip: [u16; 128] = [0; 128];

Expand Down

0 comments on commit 8d5b980

Please sign in to comment.