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

feat: add monitor::from_point() #187

Closed
srsholmes opened this issue Aug 12, 2021 · 4 comments
Closed

feat: add monitor::from_point() #187

srsholmes opened this issue Aug 12, 2021 · 4 comments

Comments

@srsholmes
Copy link

Add a method called monitor::from_point(). Apologies I am not 100% sure what this method is for, but it was discussed by @amrbashir in this thread.

Possibly for allow calculations to position windows between workspaces / monitors.

@amrbashir
Copy link
Member

amrbashir commented Aug 12, 2021

yeah this is necessary for apps that want to show itself relative to the screen, for example an overlay music player

They would need to get cursor position first, then get the monitor from it then calculate their window position as they want.

@CNLHC
Copy link
Contributor

CNLHC commented Jun 17, 2022

Do we have any plans to support this feature?
I am willing to contribute something but I am not sure whether the PR is welcomed here or not.

@amrbashir
Copy link
Member

@CNLHC PRs are always welcome.

@CNLHC
Copy link
Contributor

CNLHC commented Oct 31, 2022

I wrote a draft PR that tries to solve this issue.

Since we already have the available_monitors method, a simple way to achieve monitor::from_point is by enumerating all the available monitors and returning the monitor that contains the given point.

Besides the monitor::from_point() method, this pr also exposes a monitor_from_point in the window namespace.

Currently, this PR only contains macOS implementation, if any reviewer thinks it is the correct way to solve this problem, I will complete this PR by supporting other platforms : ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants