Skip to main content

Window Manager

The WindowManager is the core system responsible for managing all window operations in Time Capsule. It handles window lifecycle, positioning, dragging, focus management, z-index ordering, and workspace assignment.

Overview

WindowManager is implemented as a singleton module pattern with private state and exposed public methods:

Key Concepts

Window Registration

All windows must be registered with WindowManager to enable management features:

Dynamic Scanning

WindowManager uses a MutationObserver to automatically detect and register new windows:

Z-Index Management

Layered Z-Index System

Z-indexes are managed in separate layers to prevent conflicts:

Focus and Z-Index

Focusing a window assigns it the highest z-index in its layer:

Drag and Drop

Drag State Management

Pointer-Based Dragging

Dragging uses PointerEvents for unified mouse/touch support:

Mouse Acceleration

Mouse movement supports configurable acceleration:

Viewport Constraints

Windows are constrained to stay within viewport bounds:

Opaque vs Wireframe Dragging

Drag Completion

Window Operations

Minimize

Maximize

Window Shading

Double-click titlebar to “shade” (roll up) a window:

Focus Management

Focus Modes

Two focus modes are supported:
Default mode. Windows receive focus when clicked.

Workspace Management

Virtual Desktops

WindowManager supports 4 virtual workspaces:

Workspace Assignment

Windows are automatically assigned to the current workspace when opened:

Mobile Considerations

Disabled Features

Certain features are disabled on mobile for better UX:

Automatic Centering

Windows are automatically centered on mobile devices:

Resize Handling

Windows are normalized when viewport resizes:

Global Exposure

WindowManager functions are exposed globally for legacy compatibility:

Best Practices

Ensure windows have proper structure and are registered:
Use updateWindowSession after position/state changes:
Check isMobile() before drag/resize operations:

Architecture

Overall system architecture overview

Storage

Window session persistence mechanism

Virtual Filesystem

File operations in window contexts

Development

Build applications using WindowManager