Skip to content

Commit

Permalink
custom window resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
jcalado committed Mar 3, 2021
1 parent 34fa6db commit fbc7d51
Showing 1 changed file with 30 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

0 comments on commit fbc7d51

Please sign in to comment.