tauri-apps / tauri-apps/plugins-workspace

[positioner] `TrayCenter` not working on extended monitor when using multiple monitors [macOS]

Open
#724 3 comments 3 reactions 0 assignees View on GitHub
platform: macos plugin: positioner type: bug
Dominant language
Rust
Stars
1.8k
Forks
602
Avg merge
4d 14h
Merged PRs (30d)
9

Description

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:

image

Extended monitor:

![image](https://github.com/tauri-apps/plugins-workspace/assets/25033493/4bbeb4ab-7289-431c-9328-b322940d20c7)

Code:

```rust
/// 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(())
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.