diff --git a/src/components/windows/Window.jsx b/src/components/windows/Window.jsx index 362bbf5..8c409da 100644 --- a/src/components/windows/Window.jsx +++ b/src/components/windows/Window.jsx @@ -6,9 +6,9 @@ import { ReactSVG } from "react-svg"; import { useWindowsManager } from "../../hooks/windows/WindowsManagerContext.js"; import Draggable from "react-draggable"; import { useEffect, useRef, useState } from "react"; -// eslint-disable-next-line no-unused-vars + import Application from "../../features/applications/application.js"; -// eslint-disable-next-line no-unused-vars + import Vector2 from "../../features/math/vector2.js"; /** @@ -42,10 +42,19 @@ export function Window({ id, app, size, position, focused = false, onInteract, o resizeObserver.observe(document.getElementById("root")); }); - const close = () => { + const close = (event) => { + event.preventDefault(); windowsManager.close(id); }; + const focus = (event) => { + if (event.defaultPrevented) + return; + + if ((event.target.closest(".Handle") == null || event.target.closest("button") == null)) + onInteract(event); + }; + const classNames = [styles["Window-container"]]; if (maximized) classNames.push(styles.Maximized); @@ -68,7 +77,7 @@ export function Window({ id, app, size, position, focused = false, onInteract, o cancel="button" nodeRef={nodeRef} disabled={maximized} - onMouseDown={onInteract} + onMouseDown={focus} >
{ - if (!event.defaultPrevented) - onInteract(event); - }} + onClick={focus} >
@@ -91,7 +97,7 @@ export function Window({ id, app, size, position, focused = false, onInteract, o -