Open Aukstkalnis opened 5 months ago
mayebe you can use js api screen.width
screen.height
or screen.availWidth
or screen.availHeight
to get screent size
then you can get browser size
Then we can get x and y after a small amount of calculations
This is just a solution I proposed, I have not tested whether it is feasible
Try this:
function centerWindow() {
const screenWidth = screen.width;
const screenHeight = screen.height;
const width = window.outerWidth;
const height = window.outerHeight;
const centerX = (screenWidth - width) / 2;
const centerY = (screenHeight - height) / 2;
window.moveTo(centerX, centerY);
}
centerWindow();
It kinda works but I can see the change in position. I guess we can close this issue, but can be feature for the future to implement functions get position, monitor size, mult-imonitor positioning. etc.. Anyway, thanks :)
webui is not like the other GUI libraries, a webui window
is a web browser window, so just let the browser handle the size and position. If you still want to to get the current window info just use JavaScript, example run JS from your backend:
"return window.outerWidth;"
"return window.outerHeight;"
Hi. I want to set window to the center of my screen. How do I do it? There is no current method to get total of the current screen and there is no method to set in directly to the center. I only have SetPosition method.
I am using Go programing language and fedora 39 OS.