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

added getCenterOfActiveScreen in Screen class #375

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

danielpetrica
Copy link
Contributor

Added a function that Returns the center of the screen where the mouse pointer is placed. Useful if you want to initialize a smaller window and place it exactly in the center of screen.

Closes this discussion idea #373

I ran pest and all tests passed. Also ran Phpstan on the specific file. Maybe it could be a good idea to add a test for it but don't know how.

Added function that Returns the center of the screen where the mouse pointer is placed. Useful if you want to initialise a smaller window and place it exactly in the center of screen.
@simonhamp
Copy link
Member

simonhamp commented Oct 18, 2024

I'd like to see part of this exposed via our Electron web service instead of being fully implemented here as Electron already supports some of what you're doing here. For example, you can use:

I'm imagining a Screen::active() method which returns the details of the currently active display.

This would be a useful primitive for other use-cases, not only for finding the center of the "current" screen. It would also be slightly more performant, as it would only need to make one cross-service API call instead of two (you're calling cursorPosition and displays).

Are you up for adapting this PR and creating the Electron side @danielpetrica?

@danielpetrica
Copy link
Contributor Author

@simonhamp Sounds like a better and cleaner idea. At the time I didn't have much confidence on working on electron. I'll try to look into it as this would simplify my work over time too

@simonhamp
Copy link
Member

No worries. I've created the Electron side for you - so you'd just need to use this in your PHP code.

@danielpetrica
Copy link
Contributor Author

Thank you a lot I'll change it this weekend then

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.

2 participants