region capture overlay window

This commit is contained in:
2026-05-12 00:06:31 +03:00
parent 03af276a1d
commit 14d02cdad4
11 changed files with 305 additions and 14 deletions
+73
View File
@@ -0,0 +1,73 @@
<script lang="ts">
import { onMount } from "svelte"
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"
let width: number = $state(0)
let height: number = $state(0)
onMount(() => {
const win = getCurrentWebviewWindow()
const updateSize = async () => {
const size = await win.innerSize()
const scale = await win.scaleFactor()
width = Math.round(size.width / scale)
height = Math.round(size.height / scale)
}
updateSize()
const unlisten = win.onResized(updateSize)
return () => {
unlisten.then((fn) => fn())
}
})
</script>
<div class="frame">
<div class="titlebar" data-tauri-drag-region>
<span class="grip" data-tauri-drag-region>⠿</span>
<span class="dim" data-tauri-drag-region>{width} x {height}</span>
</div>
</div>
<style>
:global(html), :global(body), :global(#overlay) {
margin: 0;
padding: 0;
background: transparent;
height: 100vh;
width: 100vw;
overflow: hidden;
}
.frame {
box-sizing: border-box;
height: 100vh;
width: 100vw;
border: 2px solid #4a8;
display: flex;
flex-direction: column;
background: transparent;
}
.titlebar {
height: 22px;
background: rgba(74, 170, 136, 0.85);
color: #0e1a16;
display: flex;
align-items: center;
gap: 8px;
padding: 0 8px;
font: 11px ui-monospace, monospace;
cursor: grab;
flex-shrink: 0;
}
.titlebar:active {
cursor: grabbing;
}
.grip {
font-size: 14px;
opacity: 0.7;
}
.dim {
font-variant-numeric: tabular-nums;
}
</style>