Skip to content

Commit

Permalink
Merge pull request #51 from jcalado/master
Browse files Browse the repository at this point in the history
custom window resolutions
  • Loading branch information
steveseguin authored Mar 3, 2021
2 parents 9d49ad3 + fbc7d51 commit 7ce42fc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,36 @@ contextMenu({
let factor = screen.getDisplayNearestPoint(point).scaleFactor;
browserWindow.setSize(640/factor, 360/factor);
}
},
{
label: 'Custom resolution',
// Only show it when right-clicking text
visible: true,
click: () => {
var URL = browserWindow.webContents.getURL();
prompt({
title: 'Custom window resolution',
label: 'Enter a resolution:',
value: browserWindow.getSize()[0] + 'x' + browserWindow.getSize()[1],
inputAttrs: {
type: 'string',
placeholder: '1280x720'
},
type: 'input'
})
.then((r) => {
if(r === null) {
console.log('user cancelled');
} else {
console.log('Window resized to ', r);
if (browserWindow.isMaximized()){browserWindow.unmaximize();}
let point = screen.getCursorScreenPoint();
let factor = screen.getDisplayNearestPoint(point).scaleFactor;
browserWindow.setSize(r.split('x')[0]/factor, r.split('x')[1]/factor);
}
})
.catch(console.error);
}
}
]
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"dependencies": {
"electron-context-menu": "^2.4.0",
"electron-is-dev": "^1.0.1",
"electron-prompt": "^1.6.1",
"yargs": "^15.4.1"
}
}

0 comments on commit 7ce42fc

Please sign in to comment.