global hotkeys wired up
This commit is contained in:
+18
-4
@@ -2,11 +2,12 @@
|
||||
import { onMount } from "svelte"
|
||||
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"
|
||||
|
||||
const win = getCurrentWebviewWindow()
|
||||
|
||||
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()
|
||||
@@ -14,15 +15,27 @@
|
||||
height = Math.round(size.height / scale)
|
||||
}
|
||||
updateSize()
|
||||
const unlisten = win.onResized(updateSize)
|
||||
const unlistenPromise = win.onResized(updateSize)
|
||||
return () => {
|
||||
unlisten.then((fn) => fn())
|
||||
unlistenPromise.then((fn) => fn())
|
||||
}
|
||||
})
|
||||
|
||||
function startDrag(e: MouseEvent) {
|
||||
if (e.button === 0) {
|
||||
e.preventDefault()
|
||||
void win.startDragging().catch((err) => console.error("startDragging", err))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="frame">
|
||||
<div class="titlebar" data-tauri-drag-region>
|
||||
<div
|
||||
class="titlebar"
|
||||
data-tauri-drag-region
|
||||
onmousedown={startDrag}
|
||||
role="presentation"
|
||||
>
|
||||
<span class="grip" data-tauri-drag-region>⠿</span>
|
||||
<span class="dim" data-tauri-drag-region>{width} x {height}</span>
|
||||
</div>
|
||||
@@ -59,6 +72,7 @@
|
||||
font: 11px ui-monospace, monospace;
|
||||
cursor: grab;
|
||||
flex-shrink: 0;
|
||||
user-select: none;
|
||||
}
|
||||
.titlebar:active {
|
||||
cursor: grabbing;
|
||||
|
||||
Reference in New Issue
Block a user