-
-
Notifications
You must be signed in to change notification settings - Fork 403
Description
Feature Request: Implement Window Controls Overlay API
Is your feature request related to a problem? Please describe.
When building modern desktop applications with Wry, developers often want to create custom title bars that seamlessly integrate with their web content. Currently, achieving this requires complex workarounds:
- Manual implementation burden: Developers need to manually implement window control buttons (minimize, maximize, close) and dragging functionality using CSS properties like
-webkit-app-region: dragor--app-region: drag - Inconsistent appearance: Custom-implemented window controls often don't match the system's native appearance, especially when system themes change
- Complex behavior handling: Implementing proper window state management (maximize/minimize/restore) requires additional native code integration
- Cross-platform compatibility: Solutions that work on one platform may not work on another
- Accessibility challenges: Custom controls often lack proper accessibility support
This results in increased development time, inconsistent user experiences, and higher maintenance costs for developers building modern desktop apps with Wry.
Describe the solution you'd like
I would like Wry to implement the Window Controls Overlay API, similar to what WebView2 already provides. This API would allow developers to:
- Display native window controls on top of web content: Let Wry draw the system's native window control buttons (minimize, maximize, close) on top of the web view
- Customize title bar appearance: Allow developers to create custom title bars in their web content while preserving native window controls
- Maintain native functionality: Ensure the window control buttons still properly maximize, minimize, and close the window
- Access CSS environment variables: Provide access to CSS env() variables like
titlebar-area-x,titlebar-area-y,titlebar-area-width,titlebar-area-heightto help position content around the controls - JavaScript API for control: Offer a JavaScript API to detect when the window controls overlay is visible, its geometry, and to handle events
- Cross-platform support: Implement this feature consistently across all platforms Wry supports
Key features requested:
- ✅ Native window control buttons rendered on top of web content
- ✅ Customizable title bar area in web content
- ✅ CSS environment variables for positioning
- ✅ JavaScript API for overlay management
- ✅ Consistent behavior across platforms
- ✅ Proper accessibility support
- ✅ Theme-aware controls that match system appearance
Describe alternatives you've considered
-
Fully custom title bars: Implementing window controls entirely in web content using CSS and JavaScript. This approach is flexible but requires significant effort to match native appearance and behavior.
-
System default title bars: Using the platform's default title bar. This provides native appearance and behavior but offers limited customization options.
-
Electron's title bar API: Electron provides a similar feature, but it's tied to Electron's ecosystem and not available in Wry.
-
Platform-specific native code: Writing platform-specific native code to implement custom title bars. This approach is complex and difficult to maintain across multiple platforms.
-
CSS
app-regionproperties: Using-webkit-app-region: dragor--app-region: dragto create draggable areas. This works for dragging but doesn't solve the problem of native window controls.
Additional context
WebView2 Implementation Reference
WebView2 already provides a Window Controls Overlay feature that demonstrates the desired functionality:
- It renders native window controls on top of web content
- It exposes CSS environment variables for positioning content
- It provides a JavaScript API to interact with the overlay
- It maintains native button functionality
Use Cases
This feature would benefit various types of applications:
- Modern productivity apps: Custom title bars that blend with the app's design language
- Media players: Minimalist interfaces with integrated controls
- Creative tools: Maximized workspace with subtle window controls
- Web-based apps: Desktop versions of web apps with native-like interfaces
- Cross-platform apps: Consistent title bar behavior across all platforms
Example Usage
<!DOCTYPE html>
<html>
<head>
<style>
/* Use CSS env variables to position content around window controls */
body {
margin: 0;
padding-top: env(titlebar-area-height, 0px);
}
/* Custom title bar */
.custom-titlebar {
position: fixed;
top: 0;
left: 0;
right: 0;
height: env(titlebar-area-height, 32px);
background-color: #2563eb;
color: white;
display: flex;
align-items: center;
padding-left: env(titlebar-area-x, 0px);
/* Make the title bar draggable */
-webkit-app-region: drag;
}
/* Content area */
.content {
padding: 20px;
}
</style>
</head>
<body>
<div class="custom-titlebar">
<h1>My App</h1>
</div>
<div class="content">
<p>Content goes here...</p>
</div>
<script>
// JavaScript API example
if (window.windowControlsOverlay) {
console.log('Window Controls Overlay supported');
console.log('Overlay geometry:', window.windowControlsOverlay.getGeometry());
// Listen for overlay changes
window.windowControlsOverlay.addEventListener('geometrychange', (event) => {
console.log('Overlay geometry changed:', event.geometry);
});
}
</script>
</body>
</html>Benefits for Wry
Implementing the Window Controls Overlay API would:
- Improve developer experience: Reduce the complexity of creating custom title bars
- Enhance app appearance: Enable modern, native-looking interfaces
- Increase platform consistency: Provide a consistent solution across all platforms
- Attract more developers: Make Wry more appealing for building modern desktop apps
- Align with modern web standards: Follow the direction of other web-based desktop frameworks
This feature would position Wry as a more competitive alternative to other desktop frameworks by providing modern UI capabilities while maintaining its lightweight nature.