From 19e251bbdc028c53c23004197cf66d93f196d601 Mon Sep 17 00:00:00 2001 From: darkuss Date: Sat, 22 Aug 2026 22:03:34 +0200 Subject: update --- src/desktop/window.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/desktop/window.tsx') diff --git a/src/desktop/window.tsx b/src/desktop/window.tsx index ef5cdab..a493bcf 100644 --- a/src/desktop/window.tsx +++ b/src/desktop/window.tsx @@ -3,8 +3,6 @@ import { useLiveSignal } from "@preact/signals/utils"; import { ComponentChildren, Ref, RefObject } from "preact"; import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks"; import { Task } from "."; -import { flushSync } from "preact/compat"; - type UseDragFunction = (onStartDrag: (e: MouseEvent) => void, onUpdatePosition: (e: MouseEvent) => void) => [Signal, (e: MouseEvent) => void] @@ -25,7 +23,7 @@ export function Window(props: Window.Props) { }, [onUpdatePosition]); const startDrag = useCallback((e: MouseEvent) => { - if (e.button === 0 && !maximized.value.value) { + if (e.button === 0) { if (dragTimeout.current !== null) { clearTimeout(dragTimeout.current); dragTimeout.current = null; @@ -44,6 +42,7 @@ export function Window(props: Window.Props) { }, [props]) const windowRef: Ref = useRef(null); + const titlebarRef: Ref = useRef(null); const source = useLiveSignal(props.task.source); const title = useLiveSignal(props.task.title); @@ -73,6 +72,15 @@ export function Window(props: Window.Props) { // Naturally, I have to add the border width here, because offset* uses padding-edge for the calculations initialOffsetX.current = e.offsetX + BORDER_WIDTH + (e.target as HTMLDivElement).offsetLeft initialOffsetY.current = e.offsetY + BORDER_WIDTH + (e.target as HTMLDivElement).offsetTop + if (maximized.value.value) { + maximized.value.value = false + const w: number = width.value as number / 2 + const h: number = titlebarRef.current!.getBoundingClientRect().height as number / 2 + x.value = initialOffsetX.current - w + y.value = initialOffsetY.current - h + initialOffsetX.current = w + initialOffsetY.current = h + } document.getSelection()?.empty() }, []) @@ -197,7 +205,7 @@ export function Window(props: Window.Props) { } onPointerDown={onFocus} > -
+
{title.value.value ?? "[404 Title Not Found]"}
-- cgit v1.2.3