Files
tolaria/src/hooks/useDragRegion.ts
lucaronin 021597566d feat: remove native titlebar, implement custom drag regions
- titleBarStyle: Overlay + hiddenTitle: true — removes native title bar,
  traffic lights float in sidebar area
- Add core:window:allow-start-dragging capability
- Add useDragRegion hook using startDragging() API (more reliable than
  data-tauri-drag-region with Overlay style)
- Apply drag regions: SidebarTitleBar, NoteList header, TabBar empty zone,
  Inspector header
- Increase header heights 45→52px to give traffic lights breathing room
- Open devtools automatically in debug builds
2026-02-25 21:43:16 +01:00

19 lines
646 B
TypeScript

import { useCallback } from 'react'
import { getCurrentWindow } from '@tauri-apps/api/window'
/**
* Returns a mousedown handler that triggers Tauri window drag via startDragging().
* More reliable than data-tauri-drag-region with titleBarStyle: Overlay in Tauri v2.
*/
export function useDragRegion() {
const onMouseDown = useCallback((e: React.MouseEvent) => {
if (e.button !== 0) return
const target = e.target as HTMLElement
if (target.closest('button, input, select, a, [data-no-drag]')) return
e.preventDefault()
getCurrentWindow().startDragging().catch(() => { /* ignore */ })
}, [])
return { onMouseDown }
}