Native Menus & Multi-Window
Relevant source files
The following files were used as context for generating this wiki page:
OpenHWP leverages the Deno desktop runtime to provide native OS integration for menus and window management. By separating the document engine (rhwp) from the platform shell, the application can offer a native desktop experience while maintaining a unified rendering logic across macOS, Windows, and Linux.
The system is designed to handle multiple document windows, each potentially embedding an editor or viewer, wired to native operating system menus through Deno's bindings and desktop APIs. This ensures that features like "Save" or "Open" appear in the expected platform-specific locations and interact correctly with the host environment.
Sources: README.en.md:10-18, README.md:11-19
System Architecture
The architecture of OpenHWP's desktop integration relies on the interaction between the Deno toolchain and the platform-specific webview.
The diagram shows the relationship between the Deno desktop shell and the CEF-based webview, where native menus and bindings communicate with the frontend.
Sources: README.en.md:10-18, README.md:11-19
Component Breakdown
The multi-window and menu system is composed of several key technological pillars:
| Component | Description | Technical Implementation |
|---|---|---|
| Desktop Shell | The host container for the application. | deno desktop |
| Native Menus | OS-level menu bars (File, Edit, etc.). | Deno desktop menus |
| Native Bindings | Communication bridge between Deno and JS. | bindings API |
| Window Management | Handling of multiple document instances. | Native windows webview |
Sources: README.en.md:12-18, README.md:13-19
Multi-Window Management
The project roadmap identifies "multiple windows" as a core requirement for the Editor phase. This allows users to open and edit several HWP/HWPX documents simultaneously in independent native windows.
Window Lifecycle Flow
The following sequence illustrates how a new document window is initiated and how it interacts with the file system.
Sequence diagram depicting the creation of a new window and the initialization of the editor component.
Sources: README.en.md:38-46, README.en.md:63-65
Native Menu Integration
OpenHWP utilizes native menus to provide a standard desktop experience. These menus are intended to trigger document-specific actions such as saving, opening, and exporting.
Integration with File System Access API
Because OpenHWP uses the Chromium Embedded Framework (CEF) backend, it leverages the standard File System Access API. This removes the need for Deno to provide a separate native file picker, as the webview handles file selection directly while remaining in a secure context (localhost).
- Open: Restricted to
.hwpand.hwpxtypes usingwindow.showOpenFilePicker. - Save: Reuses the
FileSystemFileHandleobtained during the "Open" action to write data back to the disk without repetitive prompts.
Sources: README.en.md:23-28, README.en.md:41-55, README.md:43-57
Implementation Roadmap
The implementation of native menus and multi-window support is staged across the project roadmap:
- Phase 1 (Viewer): Basic window creation and rendering of HWP pages to SVG.
- Phase 2 (Editor): Full integration of
@rhwp/editorwithin multiple native windows and wiring of native menus to "Save" and "Save As" actions usingFileSystemFileHandle. - Phase 3 (Output): Implementation of the webview print path and PDF export triggered via menus.
Sources: README.en.md:61-68, README.md:63-70
Development and Tooling
OpenHWP requires Deno version 2.9.0 or later, as this version introduced the deno desktop command necessary for native window and menu management.
# Building a binary with native support
deno desktop main.ts --backend cef
Sources: README.en.md:57-60, CONTRIBUTING.md:13-16
The application uses a single toolchain, avoiding external dependencies like Node.js or Bun. Dependencies and environment setups for the desktop environment are managed via deno install and configuration files like orca.yaml for worktree setups.
Sources: orca.yaml:12-16, CONTRIBUTING.md:13-16
The Native Menus and Multi-Window system in OpenHWP serves as the bridge between the high-performance Rust-based HWP engine and the host operating system, providing a familiar and efficient desktop workflow for document management.