mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-30 05:28:15 +03:00
Fixed windows scaling for different gnome themes
This commit is contained in:
parent
37e6a1162c
commit
4c16ce1de3
3 changed files with 35 additions and 66 deletions
|
@ -172,16 +172,25 @@
|
|||
Configs.get('theme').then((theme) => switchTheme(theme as string));
|
||||
|
||||
// Do some stuff when all the content will be loaded
|
||||
onMount(() => {
|
||||
Window.current.show();
|
||||
onMount(async () => {
|
||||
await Window.current.show();
|
||||
await Window.current.center(900, 600);
|
||||
|
||||
Window.current.setSize({
|
||||
width: 900,
|
||||
height: 600,
|
||||
resizable: false
|
||||
});
|
||||
const resizer = () => {
|
||||
if (window.innerWidth < 700)
|
||||
setTimeout(resizer, 10);
|
||||
|
||||
Window.current.center(900, 600);
|
||||
else
|
||||
{
|
||||
Window.current.setSize({
|
||||
width: 900 + (900 - window.innerWidth),
|
||||
height: 600 + (600 - window.innerHeight),
|
||||
resizable: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(resizer, 10);
|
||||
});
|
||||
|
||||
Neutralino.events.on('windowClose', async () => {
|
||||
|
|
|
@ -83,18 +83,27 @@ export default class State
|
|||
});
|
||||
};
|
||||
|
||||
this.update().then(() => {
|
||||
this.update().then(async () => {
|
||||
IPC.write('launcher-loaded');
|
||||
|
||||
Window.current.show();
|
||||
await Window.current.show();
|
||||
await Window.current.center(1280, 700);
|
||||
|
||||
Window.current.setSize({
|
||||
width: 1280,
|
||||
height: 700,
|
||||
resizable: false
|
||||
});
|
||||
const resizer = () => {
|
||||
if (window.innerWidth < 1000)
|
||||
setTimeout(resizer, 10);
|
||||
|
||||
Window.current.center(1280, 700);
|
||||
else
|
||||
{
|
||||
Window.current.setSize({
|
||||
width: 1280 + (1280 - window.innerWidth),
|
||||
height: 700 + (700 - window.innerHeight),
|
||||
resizable: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(resizer, 10);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -36,15 +36,6 @@ declare const Neutralino;
|
|||
|
||||
class Window
|
||||
{
|
||||
public static waylandUpscales = {
|
||||
width: 46,
|
||||
height: 74
|
||||
};
|
||||
|
||||
public static upscaleOnWayland = true;
|
||||
|
||||
protected static isWaylandSession?: boolean;
|
||||
|
||||
public static get current(): any
|
||||
{
|
||||
return {
|
||||
|
@ -53,11 +44,6 @@ class Window
|
|||
center(windowWidth: number, windowHeight: number)
|
||||
{
|
||||
Neutralino.window.move(Math.round((window.screen.width - windowWidth) / 2), Math.round((window.screen.height - windowHeight) / 2));
|
||||
},
|
||||
|
||||
setSize(size: WindowSize)
|
||||
{
|
||||
Window.upscaleSize(size).then(Neutralino.window.setSize);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -85,41 +71,6 @@ class Window
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static isWayland(): Promise<boolean>
|
||||
{
|
||||
return new Promise((resolve) => {
|
||||
if (this.isWaylandSession !== undefined)
|
||||
resolve(this.isWaylandSession);
|
||||
|
||||
else Neutralino.os.getEnv('XDG_SESSION_TYPE').then((value) => {
|
||||
this.isWaylandSession = value === 'wayland';
|
||||
|
||||
resolve(this.isWaylandSession);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static upscaleSize(size: WindowSize): Promise<WindowSize>
|
||||
{
|
||||
return new Promise(async (resolve) => {
|
||||
// Upscale is required only if the window is not resizable
|
||||
if (Window.upscaleOnWayland && size.resizable !== undefined && !size.resizable && await Window.isWayland())
|
||||
{
|
||||
// Upscale width
|
||||
for (const prop of ['minWidth', 'maxWidth', 'width'])
|
||||
if (size[prop] !== undefined)
|
||||
size[prop] += Window.waylandUpscales.width;
|
||||
|
||||
// Upscale height
|
||||
for (const prop of ['minHeight', 'maxHeight', 'height'])
|
||||
if (size[prop] !== undefined)
|
||||
size[prop] += Window.waylandUpscales.height;
|
||||
}
|
||||
|
||||
resolve(size);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export type {
|
||||
|
|
Loading…
Reference in a new issue