clip screenshot crops correctly when HIDPI display is used

This commit is contained in:
zadam
2020-10-09 22:07:26 +02:00
parent b61149382e
commit 28eb3f2aae
2 changed files with 7 additions and 3 deletions

1
.idea/vcs.xml generated
View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -36,7 +36,12 @@ function cropImage(newArea, dataUrl) {
async function takeScreenshot(cropRect) {
const activeTab = await getActiveTab();
const zoom = await browser.tabs.getZoom(activeTab.id);
const isFirefox = typeof InstallTrigger !== 'undefined';
// Chrome/blink do not incorporate automatically the devicePixelRatio so we need to do it manually
const zoom = await browser.tabs.getZoom(activeTab.id)
* (isFirefox ? 1 : window.devicePixelRatio);
const newArea = Object.assign({}, cropRect);
newArea.x *= zoom;
newArea.y *= zoom;
@@ -332,4 +337,4 @@ browser.runtime.onMessage.addListener(async request => {
else if (request.name === 'send-trilium-search-status') {
triliumServerFacade.sendTriliumSearchStatusToPopup();
}
});
});