Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Use mousepollingrate as maximum frame rate of displays
Browse files Browse the repository at this point in the history
  • Loading branch information
seo-rii committed Aug 17, 2020
1 parent 3ee60fc commit a62ff26
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const os = require("os");
const eBrowserWindow = require("electron").BrowserWindow;
const {nativeTheme, screen} = require("electron");
const supportedType = ['light', 'dark', 'appearance-based'];
const {getMonitorInfo} = require('display-info');

function isWindows10() {
if (process.platform !== 'win32') return false;
Expand Down Expand Up @@ -35,8 +36,15 @@ class vBrowserWindow extends eBrowserWindow {
const win = new eBrowserWindow(props);
vBrowserWindow._bindAndReplace(win, vBrowserWindow.setVibrancy);

let pollingRate = 0;
let monitorInfo = getMonitorInfo();

for (let i of monitorInfo) {
if (i.frameRate > pollingRate) pollingRate = i.frameRate;
}
if (!pollingRate) pollingRate = 60;

// Replace window moving behavior to fix mouse polling rate bug
const pollingRate = 144;
win.on('will-move', (e) => {
e.preventDefault()

Expand Down
43 changes: 11 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electron-acrylic-window",
"version": "0.3.1",
"version": "0.3.2",
"description": "Add vibrancy effect for electron",
"main": "index.js",
"keywords": [
Expand Down Expand Up @@ -35,7 +35,8 @@
"dependencies": {
"bindings": "^1.5.0",
"node-gyp": "^7.0.0",
"node-addon-api": "^3.0.0"
"node-addon-api": "^3.0.0",
"display-info": "^0.0.1"
},
"devDependencies": {
"electron": "^9.1.1"
Expand Down

0 comments on commit a62ff26

Please sign in to comment.