diff --git a/plugins/positioner/src/ext.rs b/plugins/positioner/src/ext.rs index 01d34cf5..4160728c 100644 --- a/plugins/positioner/src/ext.rs +++ b/plugins/positioner/src/ext.rs @@ -24,14 +24,20 @@ pub enum Position { #[cfg(feature = "system-tray")] TrayLeft, #[cfg(feature = "system-tray")] + TrayFixedLeft, + #[cfg(feature = "system-tray")] TrayBottomLeft, #[cfg(feature = "system-tray")] TrayRight, #[cfg(feature = "system-tray")] + TrayFixedRight, + #[cfg(feature = "system-tray")] TrayBottomRight, #[cfg(feature = "system-tray")] TrayCenter, #[cfg(feature = "system-tray")] + TrayFixedCenter, + #[cfg(feature = "system-tray")] TrayBottomCenter, } @@ -113,7 +119,23 @@ impl WindowExt for Window { y: tray_y - window_size.height, } } else { - panic!("tray position not set"); + panic!("Tray position not set"); + } + } + #[cfg(feature = "system-tray")] + TrayFixedLeft => { + if let(Some((tray_x, tray_y)), Some((_, tray_height))) = (tray_position, tray_size) { + let y = tray_y - window_size.height; + // Choose y value based on the target OS + #[cfg(target_os = "windows")] + let y = if y < 0 { tray_y + tray_height } else { y }; + + #[cfg(target_os = "macos")] + let y = if y < 0 { tray_y } else { y }; + + PhysicalPosition { x: tray_x, y } + } else { + panic!("Tray position not set"); } } #[cfg(feature = "system-tray")] @@ -140,6 +162,22 @@ impl WindowExt for Window { } } #[cfg(feature = "system-tray")] + TrayFixedRight => { + if let(Some((tray_x, tray_y)), Some((tray_width, tray_height))) = (tray_position, tray_size) { + let y = tray_y - window_size.height; + // Choose y value based on the target OS + #[cfg(target_os = "windows")] + let y = if y < 0 { tray_y + tray_height } else { y }; + + #[cfg(target_os = "macos")] + let y = if y < 0 { tray_y } else { y }; + + PhysicalPosition { x: tray_x + tray_width, y } + } else { + panic!("Tray position not set"); + } + } + #[cfg(feature = "system-tray")] TrayBottomRight => { if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) { @@ -164,6 +202,24 @@ impl WindowExt for Window { } } #[cfg(feature = "system-tray")] + TrayFixedCenter => { + if let (Some((tray_x, tray_y)), Some((tray_width, tray_height))) = (tray_position, tray_size) + { + let x = tray_x + tray_width / 2 - window_size.width / 2; + let y = tray_y - window_size.height; + // Choose y value based on the target OS + #[cfg(target_os = "windows")] + let y = if y < 0 { tray_y + tray_height } else { y }; + + #[cfg(target_os = "macos")] + let y = if y < 0 { tray_y } else { y }; + + PhysicalPosition { x, y } + } else { + panic!("Tray position not set"); + } + } + #[cfg(feature = "system-tray")] TrayBottomCenter => { if let (Some((tray_x, tray_y)), Some((tray_width, _))) = (tray_position, tray_size) {