-
Notifications
You must be signed in to change notification settings - Fork 456
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
[feature] Choose screen behavior #647
Comments
I was digging into how to make it possible and I was able to accomplish it with almost no effort. The video I attach shows my local dev version opening in the screen in which the mouse pointer is at. Screencast.2023-01-13.20.59.02.mp4There are some caveats with my solution based entirely in my lack of competence in Electron and my intention of doing a quick prototype to see how it would work. Without understanding much why, I would have expected the code for this functionality to live in the "renderer" side of the application however to make it work I needed to use Electron's screen (https://www.electronjs.org/docs/latest/api/screen) which is only available in the main process. The code in my prototype looks like this app.whenReady().then(() => {
// We cannot require the screen module until the app is ready.
const { screen } = require('electron')
...
mainWindow.on('show', (event) => {
const cursorScreenPoint = screen.getCursorScreenPoint()
const nearestDisplay = screen.getDisplayNearestPoint(cursorScreenPoint)
const goalWidth = 650 // hardcoded now, should get from config or calculate accordingly
const goalX = Math.floor(nearestDisplay.bounds.x + (nearestDisplay.size.width - goalWidth) / 2)
const goalY = 200 // hardcoded now, should get from config or calculate accordingly
config.set('winPosition', [goalX, goalY])
}) I have only tested this example in Ubuntu 22.04 but the methods used from |
Hi thanks @emilioidk for the feature suggestion, always wanted to improve rendering on multiple screens, feel free to upload a pr so we can review |
…osest to the mouse pointer When displaying the main window for Cerebro so far the primary screen has been chosen. This is inconvenient for workstations with more than 1 screen. After this commit is applied the main window will be displayed in the screen containing the mouse pointer (or the screen closest to the pointer if the pointer is in between screens). fix cerebroapp#647
@oguhpereira I'd forgotten about it, sorry about that. I have now created a PR, looking forward to getting feedback. |
…osest to the mouse pointer (#678) When displaying the main window for Cerebro so far the primary screen has been chosen. This is inconvenient for workstations with more than 1 screen. After this commit is applied the main window will be displayed in the screen containing the mouse pointer (or the screen closest to the pointer if the pointer is in between screens). fix #647
Thanks @emilioidk |
Feature
Cerebro always opens in the middle of the first screen but for people using several screens (which I assume is quite common in the kind of people that would use Cerebro) it would be much more ergonomic to be able to set the screen behavior. By default Cerebro should open centered in the screen in which the mouse pointer is but the option to set a fixed screen to open Cerebro in could be very useful for many users.
The text was updated successfully, but these errors were encountered: