# Fullscreen Feature Implementation

## Overview

Adding a `-fullscreen` option to launch the message box window in fullscreen mode (like pressing F11 in a browser).

## Features

- Start window in fullscreen mode (no borders, title bar, or decorations)
- Window fills entire screen
- Can exit fullscreen with Escape key or F11
- Works with all content types (message, HTML, URL)
- Compatible with other options (zoom, detach, etc.)

## Implementation Plan

### 1. TypeScript API (index.ts)

Add `fullscreen?: boolean` to `MessageBoxOptions` interface and pass it to the Rust binary.

**Location:** Around line 17 in the interface definition

**Add:**
```typescript
interface MessageBoxOptions {
    // ... existing options ...
    fullscreen?: boolean;     // Start window in fullscreen mode
}
```

**Location:** Around line 60-65 where JSON is constructed

**Add to the config object:**
```typescript
const config = {
    // ... existing properties ...
    fullscreen: options.fullscreen || false
};
```

### 2. CLI Handler (clihandler.ts)

Add CLI flag parsing for `-fullscreen` option.

**Location:** Add to `CliOptions` interface (around line 15)

**Add:**
```typescript
interface CliOptions {
    // ... existing options ...
    fullscreen?: boolean;
}
```

**Location:** Flag parsing section (after line 113)

**Add:**
```typescript
        } else if (arg === '-fullscreen' || arg === '--fullscreen') {
            cli.fullscreen = true;
            i++;
```

**Location:** Options construction (around line 170)

**Add:**
```typescript
        fullscreen: cli.fullscreen
```

**Location:** Help text (around line 38)

**Add:**
```
  -fullscreen, --fullscreen   Start window in fullscreen mode (F11 to exit)
```

### 3. Rust Binary (main.rs)

Configure the window to start in fullscreen mode using tao's WindowBuilder.

**File:** `msger-native/src/main.rs`

**Location:** Config struct (around line 10)

**Add:**
```rust
#[derive(Deserialize)]
struct Config {
    // ... existing fields ...
    #[serde(default)]
    fullscreen: bool,
}
```

**Location:** Window creation (around line 120-130)

**Replace:**
```rust
let window = WindowBuilder::new()
    .with_title(&config.title)
    .with_inner_size(PhysicalSize::new(width, height))
    .with_resizable(true)
    .with_position(position)
    .build(&event_loop)?;
```

**With:**
```rust
let mut window_builder = WindowBuilder::new()
    .with_title(&config.title)
    .with_inner_size(PhysicalSize::new(width, height))
    .with_resizable(true)
    .with_position(position);

// Set fullscreen mode if requested
if config.fullscreen {
    window_builder = window_builder.with_fullscreen(Some(tao::window::Fullscreen::Borderless(None)));
}

let window = window_builder.build(&event_loop)?;
```

**Location:** JavaScript event handling (around line 185-195, in the keydown handler)

**Enhance Escape key to exit fullscreen:**
```javascript
document.addEventListener('keydown', function(e) {{
    if (e.key === 'Escape') {{
        // Try to exit fullscreen first
        if (document.fullscreenElement) {{
            document.exitFullscreen();
        }} else {{
            const result = {{ button: '{}', dismissed: true }};
            window.ipc.postMessage(JSON.stringify(result));
        }}
    }} else if (e.key === 'F11') {{
        // Toggle fullscreen
        e.preventDefault();
        if (!document.fullscreenElement) {{
            document.documentElement.requestFullscreen();
        }} else {{
            document.exitFullscreen();
        }}
    }} else if (e.key === 'Enter') {{
        // ... existing Enter handler ...
    }}
}});
```

## How It Works

### Fullscreen Modes

**tao** (the windowing library) provides two fullscreen options:

1. **Borderless Fullscreen** (recommended) - `Fullscreen::Borderless(None)`
   - Window fills the screen
   - No decorations
   - Faster switching
   - Works across all monitors

2. **Exclusive Fullscreen** - `Fullscreen::Exclusive(video_mode)`
   - Changes display resolution
   - Better for games
   - More invasive

We use **Borderless** for better compatibility and user experience.

### Fullscreen Control

Users can exit fullscreen via:
- **Escape** - Exits fullscreen if active, otherwise dismisses the window
- **F11** - Toggles fullscreen on/off (standard browser behavior)

## Use Cases

### 1. Full-Screen Presentations
```bash
msger -fullscreen -url "https://slides.example.com/presentation"
```

### 2. Kiosk Mode Displays
```bash
msger -fullscreen -url "http://localhost:3000/dashboard" -detach
```

### 3. Full-Screen Notifications
```bash
msger -fullscreen -html "<h1 style='font-size:200px;text-align:center'>BREAK TIME</h1>"
```

### 4. Immersive Content
```bash
msger -fullscreen -url "file:///path/to/video-player.html"
```

### 5. API Usage
```typescript
await showMessageBox({
    title: 'Presentation',
    url: 'https://example.com/slides',
    fullscreen: true,
    alwaysOnTop: true
});
```

## Combining with Other Features

### With Detach
```bash
# Launch fullscreen window that stays open after script exits
msger -fullscreen -detach -url "http://localhost:8080/monitor"
```

### With Zoom
```bash
# Fullscreen with 150% zoom for visibility
msger -fullscreen -zoom 150 -message "Large text display"
```

### With Always On Top
```bash
# Fullscreen notification that can't be hidden
msger -fullscreen -ontop -timeout 10 -message "ALERT: System reboot in 10 seconds"
```

## Platform Support

| Platform | Support | Notes |
|----------|---------|-------|
| Windows | ✅ Full | Uses native fullscreen API |
| Linux x64 | ✅ Full | Uses GTK fullscreen |
| Linux ARM64 | ✅ Full | Uses GTK fullscreen |

## Behavior Details

### Startup
- Window starts immediately in fullscreen mode
- No transition animation
- Original window size is remembered for when exiting fullscreen

### Exiting Fullscreen
- **F11** toggles fullscreen (returns to window mode)
- **Escape** exits fullscreen first, then dismisses window on second press
- Closing window works normally (clicks button or window close)

### Multi-Monitor
- Default: Fullscreen on current/primary monitor
- With `-screen N`: Can specify which monitor (Windows only)

## Testing Checklist

- [ ] Test `-fullscreen` flag launches fullscreen window
- [ ] Test F11 toggles fullscreen on/off
- [ ] Test Escape exits fullscreen before dismissing
- [ ] Test with `-message` (simple text)
- [ ] Test with `-html` (HTML content)
- [ ] Test with `-url` (web page)
- [ ] Test with `-detach` (stays open after parent exits)
- [ ] Test with `-zoom` (initial zoom level)
- [ ] Test with `-ontop` (stays on top)
- [ ] Test multi-monitor with `-screen` (Windows only)
- [ ] Test buttons work in fullscreen
- [ ] Test input fields work in fullscreen
- [ ] Test window close button (if visible)

## Building After Changes

```bash
# Rebuild TypeScript
tsc

# Rebuild Rust binary (Windows)
cd msger-native
cargo build --release
copy target\release\msgernative.exe bin\

# Rebuild for Linux (via WSL)
npm run build:native:wsl

# Rebuild for ARM64 (via Pi)
npm run build:native:pi
```

## Files to Modify

1. ✅ `index.ts` - Add interface and JSON config
2. ✅ `clihandler.ts` - Add flag parsing and help text
3. ✅ `main.rs` - Add fullscreen window configuration
4. ✅ `README.md` - Add documentation and examples

## Examples

### CLI Examples

```bash
# Simple fullscreen message
msger -fullscreen -message "Hello in fullscreen!"

# Fullscreen web page
msger -fullscreen -url "https://example.com"

# Fullscreen HTML with custom styling
msger -fullscreen -html "<div style='display:flex;align-items:center;justify-content:center;height:100vh;font-size:5em'>BIG TEXT</div>"

# Fullscreen with timeout
msger -fullscreen -timeout 5 -message "This will close in 5 seconds"

# Fullscreen detached browser
msger -fullscreen -detach -url "http://localhost:3000"
```

### API Examples

```typescript
// Fullscreen confirmation
const result = await showMessageBox({
    title: 'Confirm',
    message: 'Are you sure you want to continue?',
    fullscreen: true,
    buttons: ['Cancel', 'Confirm']
});

// Fullscreen presentation
await showMessageBox({
    url: 'https://slides.example.com',
    fullscreen: true,
    alwaysOnTop: true
});

// Fullscreen with input
const result = await showMessageBox({
    message: 'Enter password:',
    fullscreen: true,
    allowInput: true,
    buttons: ['Cancel', 'OK']
});
```

## Security Considerations

- Fullscreen mode can be disorienting or used maliciously
- Users can always exit with Escape or F11
- Window close button may be hidden depending on platform
- Consider adding clear exit instructions in displayed content

## Future Enhancements

- Add `fullscreenMode: 'borderless' | 'exclusive'` option
- Add option to lock fullscreen (prevent F11 exit)
- Add fullscreen on specific monitor by index
- Add fullscreen toggle button in HTML content

## Notes

- Fullscreen windows still respect `-ontop` flag
- Zoom works normally in fullscreen mode
- Multi-monitor positioning requires platform support
- Some platforms may show a notification about fullscreen mode
- Detached fullscreen windows continue running independently
