-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[Electron] Splash screen display in error location #15056
Comments
Thanks for the report and analysis 💟 ! Do you have some cycles available to contribute a fix for this issue? |
Sorry, currently, I haven't any idea to fix this issue. I thought this issue maybe including two sub issues.
I thought the first problem is the primary issue since I using the following codes in an electron project to calcuate the Theia splash screen position: import { screen } from 'electron';
function ttt() {
calcActualSize({x: 400, y: 300})
xxx(3200, 2000)
console.log("------------------")
xxx(1600, 1000)
console.log("------------------")
xxx(800, 500)
}
function xxx(w: muber, h: number) {
const rev = determineSplashScreenBounds(w, h, {x:120, y:100, width: 2000, height: 1200 })
console.log(`=====@@ 2000 x 1200 ===${rev.x}, ${rev.y}, ${rev.width}, ${rev.height} =====`)
const rev2 = determineSplashScreenBounds(w, h, splashScreen.getBounds())
console.log(`=====@@ ${splashScreen.getBounds().width} x ${splashScreen.getBounds().height} ===${rev2.x}, ${rev2.y}, ${rev2.width}, ${rev2.height} =====`)
}
function calcActualSize(point: {x: number, y: number}) {
const display = screen.getDisplayNearestPoint(point);
console.log(`Size: width=${display.size.width}, height=${display.size.height}`);
console.log(`Logic: width=${display.bounds.width}, height=${display.bounds.height}`);
console.log(`scaleFactor: ${display.scaleFactor}`);
const actualWidth = display.bounds.width * display.scaleFactor;
const actualHeight = display.bounds.height * display.scaleFactor;
console.log(`Real: width=${actualWidth}, height=${actualHeight}`);
}
function determineSplashScreenBounds(w: number, h: number, initialWindowBounds: { x: number, y: number, width: number, height: number })
{
const width = w;
const height = h;
// determine the screen on which to show the splash screen via the center of the window to show
const windowCenterPoint = { x: initialWindowBounds.x + (initialWindowBounds.width / 2), y: initialWindowBounds.y + (initialWindowBounds.height / 2) };
const { bounds } = screen.getDisplayNearestPoint(windowCenterPoint);
console.log(`=====@@ centPoint ===${windowCenterPoint.x}, ${windowCenterPoint.y}, --bound: ${bounds.x}, ${bounds.y}, ${bounds.width}, ${bounds.height} =====`)
// place splash screen center of screen
const screenCenterPoint = { x: bounds.x + (bounds.width / 2), y: bounds.y + (bounds.height / 2) };
const x = screenCenterPoint.x - (width / 2);
const y = screenCenterPoint.y - (height / 2);
return {
x, y, width, height
};
} the function And the following is the output:
So, for the first case: 1600 * 1000, the display location is not following the function So I think the display logic is the import key for solving this issue. The position calcuating logic with whether using the |
Bug Description:
Two cases:
Steps to Reproduce:
prepare
Reproduce case 1
theia\frontend\config\electron\splashScreenOptions
inapplication/electron/package.json
with width 1600, height 1000yarn clean && yarn && yarn build && yarn download:plugins && yarn electron start
the screen capture is following:
Reproduce case 2
theia\frontend\config\electron\splashScreenOptions
inapplication/electron/package.json
with width 3200, height 2000yarn clean && yarn && yarn build && yarn download:plugins && yarn electron start
Nothing is displayed!
Issue location
In source code:
Theia 1.58.1:
packages/core/src/electron-main/electron-main-application.ts
line 297,
function determineSplashScreenBounds(...)
In this function, line 305:
screen.getDisplayNearestPoint(windowCenterPoint)
returned a display object. The function is using the bound member, but not using thescaleFactor
member.In my computer,the display data is:
PS: My monitor resolution ratio shown in Windows 11 settings is 2240 x 1400
Additional Information
The text was updated successfully, but these errors were encountered: