Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2::tauri_plugin_positioner] Fix window positioning relative to tray icon #1128

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

pronebird
Copy link

@pronebird pronebird commented Mar 29, 2024

Hi,

I suppose that event.{x, y} received with TrayIconEvent corresponds to the mouse click position on screen, so if we want to position the window relative to the tray item, then we should rely on icon_rect.{left, top} instead.

It's worth to note that when positioning for TrayBottomCenter the y coordinate for window must be pinned to icon_rect.bottom but that doesn't work because icon_rect has invalid coordinates to begin with, for example:

icon_rect: Rectangle {
  left: 2364.0,
  top: 48.0,
  right: 2422.0,
  bottom: 96.0,
},

I suppose that the tray icon should actually have a top coordinate set to 0 and with the height of 22, double it on my retina and it comes down to:

{
  top: 0,
  bottom: 48.0
}

Which means that icon_rect.top corresponds to the bottom of menubar on macOS.

So unless there is some funny business going on in AppKit, which is possible but unlikely, I'd say that the layer that converts menubar icon frame to screen coordinates on macOS has a bug, so that's something to look into down the road.

@pronebird pronebird requested a review from a team as a code owner March 29, 2024 18:20
@pronebird pronebird changed the title [v2::tauri_plugin_positioner] Fix x,y position of tray icon [v2::tauri_plugin_positioner] Fix window positioning relative to tray icon Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant