From 997847e14608c7ceaea4da5d80769e2f8ee4f3c6 Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Sun, 26 Dec 2021 23:47:33 -0800 Subject: [PATCH] high dpi detection --- index.js | 6 ++++-- src/main/cider-base.js | 2 ++ src/renderer/index.js | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 14ab84b0..307027e7 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ require('v8-compile-cache'); -const { app } = require('electron'); +const { app, screen } = require('electron'); // Analytics for debugging. const ElectronSentry = require("@sentry/electron"); @@ -61,7 +61,6 @@ switch (app.cfg.get("visual.hw_acceleration")) { break; } - // Creating the Application Window and Calling all the Functions function CreateWindow() { if (app.isQuiting) { app.quit(); return; } @@ -82,6 +81,9 @@ app.commandLine.appendSwitch('js-flags', '--max-old-space-size=1024') app.on('ready', () => { if (app.isQuiting) { app.quit(); return; } + app.commandLine.appendSwitch('high-dpi-support', 1) + app.commandLine.appendSwitch('force-device-scale-factor', 1) + console.log('[Cider] Application is Ready. Creating Window.') if (!app.isPackaged) { console.info('[Cider] Running in development mode.') diff --git a/src/main/cider-base.js b/src/main/cider-base.js index c55d7c39..92455dff 100644 --- a/src/main/cider-base.js +++ b/src/main/cider-base.js @@ -194,6 +194,8 @@ const CiderBase = { ipcMain.on('setScreenScale', (event, scale) => { win.webContents.setZoomFactor(parseFloat(scale)) }) + + win.webContents.setZoomFactor(screen.getPrimaryDisplay().scaleFactor) return win }, diff --git a/src/renderer/index.js b/src/renderer/index.js index 0c8c51dc..16e3997d 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -2574,4 +2574,3 @@ webGPU().then() let screenWidth = screen.width; let screenHeight = screen.height; -ipcRenderer.send("setScreenScale" , (screenHeight * 16 / 9) / (1536)) \ No newline at end of file