Window API

Window Management

Control window properties, size, position, and state in your DeskForge applications.

initWindow

Initialize window with configuration options.

async function initWindow(config: WindowConfig): Promise<void>

Parameters

PropertyTypeDescription
titlestring?Window title
widthnumber?Window width in pixels
heightnumber?Window height in pixels
minWidthnumber?Minimum window width
minHeightnumber?Minimum window height
resizableboolean?Whether window is resizable
fullscreenboolean?Start in fullscreen mode

Example

import { initWindow } from '@deskforge/runtime';

await initWindow({
  title: 'My Desktop App',
  width: 1200,
  height: 800,
  minWidth: 800,
  minHeight: 600,
  resizable: true,
  fullscreen: false,
});

minimizeWindow

Minimize the application window.

async function minimizeWindow(): Promise<void>

Example

import { minimizeWindow } from '@deskforge/runtime';

// Minimize on button click
button.addEventListener('click', async () => {
  await minimizeWindow();
});

maximizeWindow

Maximize the application window.

async function maximizeWindow(): Promise<void>

Example

import { maximizeWindow } from '@deskforge/runtime';

await maximizeWindow();

closeWindow

Close the application window.

async function closeWindow(): Promise<void>

Example

import { closeWindow } from '@deskforge/runtime';

// Close app on button click
closeButton.addEventListener('click', async () => {
  await closeWindow();
});

toggleFullscreen

Toggle fullscreen mode on/off.

async function toggleFullscreen(): Promise<void>

Example

import { toggleFullscreen } from '@deskforge/runtime';

// Toggle fullscreen with F11 key
document.addEventListener('keydown', async (e) => {
  if (e.key === 'F11') {
    e.preventDefault();
    await toggleFullscreen();
  }
});

showWindow

Show the application window if it's hidden.

async function showWindow(): Promise<void>

Example

import { showWindow } from '@deskforge/runtime';

await showWindow();

hideWindow

Hide the application window without closing it.

async function hideWindow(): Promise<void>

Example

import { hideWindow, showWindow } from '@deskforge/runtime';

// Hide window to system tray
await hideWindow();

// Show it again later
setTimeout(async () => {
  await showWindow();
}, 5000);

Best Practices

✓ Set Minimum Sizes

Always set minWidth and minHeight to prevent UI breaking at small sizes.

✓ Handle Errors

Wrap window operations in try-catch blocks to handle platform-specific limitations gracefully.

⚠ Platform Differences

Some window operations may behave differently on macOS, Windows, and Linux. Test on all target platforms.