From d06784958d73159b5e4abafe5114804662114ed7 Mon Sep 17 00:00:00 2001 From: Ryan Schanzenbacher Date: Thu, 9 Jul 2026 22:15:53 -0400 Subject: move ubersicht modules in tree --- .../lib/components/aerospace/window.jsx | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/window.jsx (limited to 'users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/window.jsx') diff --git a/users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/window.jsx b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/window.jsx new file mode 100755 index 0000000..04b54d6 --- /dev/null +++ b/users/ryan/modules/simple-bar/simple-bar-source/lib/components/aerospace/window.jsx @@ -0,0 +1,99 @@ +import * as Uebersicht from "uebersicht"; +import * as AppIcons from "../../app-icons"; +import { SuspenseIcon } from "../icons/icon.jsx"; +import { useSimpleBarContext } from "../simple-bar-context.jsx"; +import * as Utils from "../../utils"; +import * as Aerospace from "../../aerospace"; + +const { React } = Uebersicht; + +/** + * Window component to display a window in the process bar. + * @param {Object} props - The component props. + * @param {Object} props.window - The window object. + * @returns {JSX.Element|null} The rendered component. + */ +export default function Window({ window }) { + // Get settings from context + const { settings } = useSimpleBarContext(); + // Create a ref for the button element + const ref = React.useRef(); + // Destructure settings + const { + displayOnlyCurrent, + hideWindowTitle, + displayOnlyIcon, + expandAllProcesses, + } = settings.process; + // Destructure window properties + const { + focused, + "app-name": appName, + "window-title": title, + "window-id": id, + } = window; + + // If displayOnlyCurrent is true and the window is not focused, return null + if (displayOnlyCurrent && !focused) { + return null; + } + + // Get the icon for the app or use the default icon + const Icon = AppIcons.apps[appName] || AppIcons.apps.Default; + + /** + * Handle click event on the window button. + * @param {Event} e - The click event. + */ + const onClick = (e) => { + !displayOnlyCurrent && Utils.clickEffect(e); + Aerospace.focusWindow(id); + }; + + /** + * Handle mouse enter event on the window button. + */ + const onMouseEnter = () => { + Utils.startSliding(ref.current, ".process__inner", ".process__name"); + }; + + /** + * Handle mouse leave event on the window button. + */ + const onMouseLeave = () => { + Utils.stopSliding(ref.current, ".process__name"); + }; + + // Generate class names based on settings and window state + const classes = Utils.classNames("process__window", { + "process__window--expanded": expandAllProcesses, + "process__window--focused": !displayOnlyCurrent && focused, + "process__window--only-current": displayOnlyCurrent, + "process__window--only-icon": displayOnlyIcon, + }); + + // Clean up the window title + const cleanedUpName = + appName !== title && title.length ? `${appName} / ${title}` : appName; + const processName = hideWindowTitle ? appName : cleanedUpName; + + // Render the window button + return ( + + ); +} -- cgit v1.3