plugins-workspace
plugins-workspace copied to clipboard
[positioner] `TrayCenter` not working on extended monitor when using multiple monitors [macOS]
When using menu.move_window(Position::TrayCenter)?;
to put a system tray menu on the menu icon center, it's works on main monitor. But not any response in the extended monitor, also no error throwed.
Main monitor:
Extended monitor:
Code:
/// Create new system tray window
pub fn handle_tray_menu(app: &AppHandle) -> Result<()> {
use tauri_plugin_positioner::{Position, WindowExt};
// get or create a new menu window
let (menu, is_build) = {
let window = app.get_window("menu");
if let Some(win) = window {
(win, false)
} else {
let win = WindowBuilder::new(app, "menu", WindowUrl::App("system-tray".into()))
.decorations(false)
.transparent(true)
.build()?;
win.set_size(Size::Logical(LogicalSize {
width: 300.0,
height: 600.0,
}))?;
(win, true)
}
};
if menu.is_visible()? && !is_build {
menu.hide()?;
} else {
menu.move_window(Position::TrayCenter)?;
menu.show()?;
menu.set_focus()?;
menu.set_always_on_top(true)?;
}
Ok(())
}