mirror of
https://github.com/block/buzz.git
synced 2026-10-28 04:51:40 +00:00
## Summary - add an opt-in native glass sidebar with opacity controls and live theme previews - refine sidebar spacing and Buzz-only active rows while preserving production defaults - unify settings section cards, subtitles, and agent runtime rows ## Validation - repository format, lint, type, and file-size checks - 4,538 desktop tests and 2,270 native desktop tests - desktop and web production builds - 1,261 mobile tests in the completed full gate - focused Playwright appearance, sidebar, settings, pairing, and runtime coverage --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Kenny Lopez <klopez4212@gmail.com> Signed-off-by: Wes <wesbillman@users.noreply.github.com> Signed-off-by: Fast Fizz <2df81cb51f05a9d5387ef24d7b9ecb8fcdfcd1c70ffabc67061c9596e1b5b1c4@buzz.block.builderlab.xyz> Co-authored-by: Carl <3c4caeafb646d23867f1c4832e68211d77e2561946171625f75c3ce1a3f2670f@buzz.block.builderlab.xyz> Co-authored-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz> Co-authored-by: Fast Fizz <2df81cb51f05a9d5387ef24d7b9ecb8fcdfcd1c70ffabc67061c9596e1b5b1c4@buzz.block.builderlab.xyz>
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import * as React from "react";
|
|
import { getCurrentWindow } from "@tauri-apps/api/window";
|
|
|
|
import { isWindowDragHandleEvent } from "@/app/AppShell.helpers";
|
|
import { performTitleBarDoubleClickAction } from "@/shared/lib/titleBarActions";
|
|
|
|
export function useTauriWindowDrag() {
|
|
React.useEffect(() => {
|
|
function handlePointerDown(event: PointerEvent) {
|
|
if (
|
|
event.button !== 0 ||
|
|
event.detail > 1 ||
|
|
!isWindowDragHandleEvent(event)
|
|
) {
|
|
return;
|
|
}
|
|
|
|
// A native window drag replaces the browser's normal pointer gesture.
|
|
// Cancel that gesture before handing control to Tauri so moving from the
|
|
// titlebar across page copy cannot start a text selection.
|
|
event.preventDefault();
|
|
void getCurrentWindow().startDragging();
|
|
}
|
|
|
|
function stopTauriDragRegionHandler(event: MouseEvent) {
|
|
if (event.button !== 0 || !isWindowDragHandleEvent(event)) {
|
|
return;
|
|
}
|
|
|
|
// Tauri's injected data-tauri-drag-region listener hardcodes maximize on
|
|
// double-click. Buzz handles drag and double-click itself so macOS title
|
|
// bar preferences can be respected.
|
|
event.stopImmediatePropagation();
|
|
}
|
|
|
|
function handleDoubleClick(event: MouseEvent) {
|
|
if (event.button !== 0 || !isWindowDragHandleEvent(event)) {
|
|
return;
|
|
}
|
|
|
|
event.preventDefault();
|
|
event.stopImmediatePropagation();
|
|
void performTitleBarDoubleClickAction();
|
|
}
|
|
|
|
window.addEventListener("pointerdown", handlePointerDown, true);
|
|
window.addEventListener("mousedown", stopTauriDragRegionHandler, true);
|
|
window.addEventListener("mouseup", stopTauriDragRegionHandler, true);
|
|
window.addEventListener("dblclick", handleDoubleClick, true);
|
|
return () => {
|
|
window.removeEventListener("pointerdown", handlePointerDown, true);
|
|
window.removeEventListener("mousedown", stopTauriDragRegionHandler, true);
|
|
window.removeEventListener("mouseup", stopTauriDragRegionHandler, true);
|
|
window.removeEventListener("dblclick", handleDoubleClick, true);
|
|
};
|
|
}, []);
|
|
}
|