-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
added getCenterOfActiveScreen in Screen class #375
Conversation
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.
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 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 Are you up for adapting this PR and creating the Electron side @danielpetrica? |
@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 |
No worries. I've created the Electron side for you - so you'd just need to use this in your PHP code. |
Thank you a lot I'll change it this weekend then |
hi @simonhamp I tried using the newly creatited active method but it returns a null value trigering a type error. while investigating I tried to call
|
I changed the electron pluign to track dev-main so it's updated and in the vendor I can see the new updates for the active endpoint. I tried running yarn install and also stoping and starting the native:serve command |
While debbugging I saw that in the server api routes the new routes are missing https://github.com/NativePHP/electron/blob/main/resources/js/electron-plugin/dist/server/api/screen.js |
I've managed to build the electron plugin by running |
Glad you found this! I was going to reply earlier with exactly those instructions Well done 👍🏼 |
made the changes required. thanks for pointing the issues out for me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final thing... please can we return to single-quoted strings where we're not explicitly using interpolation?
Basically this is everywhere you have double-quotes now
Yes I'll fix this |
pushed the update. I'm sorry for all the formatting issues. My IDE applied my default to the project. I'll be more careful next time |
No apology needed. Thanks for putting in the work 🙏🏼 |
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.