Part of the Blinc UI Framework
This crate is a component of Blinc, a GPU-accelerated UI framework for Rust. For full documentation and guides, visit the Blinc documentation.
Desktop platform implementation for Blinc UI.
blinc_platform_desktop provides windowing, input handling, and event loop implementation for desktop platforms (macOS, Windows, Linux) using winit.
- macOS: 11.0+ (Big Sur and later)
- Windows: 10+
- Linux: X11 and Wayland
- Native Windowing: Platform-native window management
- Full Input Support: Mouse, keyboard, trackpad, touch
- High DPI: Automatic scale factor handling
- Multiple Windows: Create and manage multiple windows
- Platform Integration: Native look and feel
use blinc_platform_desktop::DesktopPlatform;
use blinc_platform::{Platform, WindowConfig};
fn main() {
let platform = DesktopPlatform::new();
let window = platform.create_window(WindowConfig {
title: "My App".to_string(),
width: 800,
height: 600,
..Default::default()
});
platform.run(|event| {
match event {
Event::RedrawRequested(_) => {
// Render your UI
}
Event::WindowEvent { event, .. } => {
// Handle window events
}
_ => {}
}
ControlFlow::Poll
});
}#[cfg(target_os = "macos")]
{
// Native title bar integration
window.set_titlebar_transparent(true);
// Vibrancy effects
window.set_background_appearance(NSVisualEffectMaterial::Sidebar);
// Full screen support
window.set_fullscreen(Some(Fullscreen::Borderless));
}#[cfg(target_os = "windows")]
{
// DWM composition
window.enable_blur_behind();
// Taskbar integration
window.set_taskbar_progress(0.5);
}#[cfg(target_os = "linux")]
{
// Wayland-specific
window.set_app_id("com.example.myapp");
// X11-specific
window.set_wm_class("MyApp", "myapp");
}platform.run(|event| {
match event {
// Window lifecycle
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => {
return ControlFlow::Exit;
}
// Input
Event::WindowEvent { event: WindowEvent::KeyboardInput { input, .. }, .. } => {
handle_key(input);
}
Event::WindowEvent { event: WindowEvent::CursorMoved { position, .. }, .. } => {
handle_mouse_move(position.x, position.y);
}
// Redraw
Event::RedrawRequested(_) => {
render();
}
_ => {}
}
ControlFlow::Poll
});- Xcode Command Line Tools
- Visual Studio Build Tools 2019+
- X11:
libxkbcommon-dev,libwayland-dev,libxrandr-dev - Wayland:
libwayland-dev,libxkbcommon-dev
MIT OR Apache-2.0