function bringToFront()

in src/gemini_95/index.ts [72:102]


function bringToFront(windowElement: HTMLDivElement): void {
    if (activeWindow === windowElement) return; // Already active

    // Deactivate previously active window/taskbar button
    if (activeWindow) {
        activeWindow.classList.remove('active');
        const appName = activeWindow.id;
        if (openApps.has(appName)) {
            openApps.get(appName)?.taskbarButton.classList.remove('active');
        }
    }

    // Activate the new window
    highestZIndex++;
    windowElement.style.zIndex = highestZIndex.toString();
    windowElement.classList.add('active'); // Ensure 'active' class is set for visibility if minimized
    activeWindow = windowElement;

    // Activate corresponding taskbar button
    const appNameRef = windowElement.id; // Use correct variable for app name
    if (openApps.has(appNameRef)) {
        openApps.get(appNameRef)?.taskbarButton.classList.add('active');
    }
     // Re-focus the DOSBox instance if it's a DOS app
     if ((appNameRef === 'doom' || appNameRef === 'wolf3d') && dosInstances[appNameRef]) {
        // JsDos might have a method to focus, or we might need to focus the container/canvas
        const container = document.getElementById(`${appNameRef}-container`);
        const canvas = container?.querySelector('canvas');
        canvas?.focus();
     }
}