Makepad Platform Skill
Version: makepad-widgets (dev branch) | Last Updated: 2026-01-19
Check for updates: https://crates.io/crates/makepad-widgets
You are an expert at Makepad cross-platform development. Help users by:
- Understanding platforms: Explain supported platforms and backends
- Platform-specific code: Help with conditional compilation and platform APIs
When to Use
- You need to understand or target specific platforms and graphics backends in Makepad.
- The task involves platform compatibility, conditional compilation, or OS-specific behavior across desktop, mobile, or web.
- You need guidance on backend differences such as Metal, D3D11, OpenGL, WebGL, or platform modules.
Documentation
Refer to the local files for detailed documentation:
./references/platform-support.md - Platform details and OsType
IMPORTANT: Documentation Completeness Check
Before answering questions, Claude MUST:
- Read the relevant reference file(s) listed above
- If file read fails or file is empty:
- Inform user: "本地文档不完整,建议运行
/sync-crate-skills makepad --force 更新文档"
- Still answer based on SKILL.md patterns + built-in knowledge
- If reference file exists, incorporate its content into the answer
Supported Platforms
| Platform |
Graphics Backend |
OS Module |
| macOS |
Metal |
apple/metal_*.rs, apple/cocoa_*.rs |
| iOS |
Metal |
apple/metal_*.rs, apple/ios_*.rs |
| Windows |
D3D11 |
mswindows/d3d11_*.rs, mswindows/win32_*.rs |
| Linux |
OpenGL |
linux/opengl_*.rs, linux/x11*.rs, linux/wayland*.rs |
| Web |
WebGL2 |
web/*.rs, web_browser/*.rs |
| Android |
OpenGL ES |
android/*.rs |
| OpenHarmony |
OHOS |
open_harmony/*.rs |
| OpenXR |
VR/AR |
open_xr/*.rs |
OsType Enum
pub enum OsType {
Unknown,
Windows,
Macos,
Linux { custom_window_chrome: bool },
Ios,
Android(AndroidParams),
OpenHarmony,
Web(WebParams),
OpenXR,
}
// Check platform in code
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
match cx.os_type() {
OsType::Macos => { /* macOS-specific */ }
OsType::Windows => { /* Windows-specific */ }
OsType::Web(_) => { /* Web-specific */ }
_ => {}
}
}
Platform Detection
// In Cx
impl Cx {
pub fn os_type(&self) -> OsType;
pub fn gpu_info(&self) -> &GpuInfo;
pub fn xr_capabilities(&self) -> &XrCapabilities;
pub fn cpu_cores(&self) -> usize;
}
Conditional Compilation
// Compile-time platform detection
#[cfg(target_os = "macos")]
fn macos_only() { }
#[cfg(target_os = "windows")]
fn windows_only() { }
#[cfg(target_os = "linux")]
fn linux_only() { }
#[cfg(target_arch = "wasm32")]
fn web_only() { }
#[cfg(target_os = "android")]
fn android_only() { }
#[cfg(target_os = "ios")]
fn ios_only() { }
Platform-Specific Features
Desktop (macOS/Windows/Linux)
- Window management (resize, minimize, maximize)
- File dialogs
- System menu
- Drag and drop
- Multiple monitors
Mobile (iOS/Android)
- Touch input
- Virtual keyboard
- Screen orientation
- App lifecycle (foreground/background)
Web (WebGL2)
- DOM integration
- Browser events
- Local storage
- HTTP requests
Entry Point
// App entry macro
app_main!(App);
pub struct App {
ui: WidgetRef,
}
impl LiveRegister for App {
fn live_register(cx: &mut Cx) {
// Register components
crate::makepad_widgets::live_design(cx);
}
}
impl AppMain for App {
fn handle_event(&mut self, cx: &mut Cx, event: &Event) {
// Handle app events
self.ui.handle_event(cx, event, &mut Scope::empty());
}
}
When Answering Questions
- Makepad compiles to native code for each platform (no runtime interpreter)
- Shaders are compiled at build time for each graphics backend
- Platform-specific code is in
platform/src/os/ directory
- Use
cx.os_type() for runtime platform detection
- Use
#[cfg(target_os = "...")] for compile-time platform detection
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
1---2name: makepad-platform3description: 'CRITICAL: Use for Makepad cross-platform support. Triggers on:45 makepad platform, makepad os, makepad macos, makepad windows, makepad linux,67 makepad android, makepad ios, makepad web, makepad wasm, makepad metal,89 makepad d3d11, makepad opengl, makepad webgl, OsType, CxOs, makepad 跨平台, makepad10 平台支持'11risk: safe12source: community13license: MIT14metadata:15 source: https://skillmd.com/skills/jantoniofc/makepad-platform16---1718# Makepad Platform Skill1920> **Version:** makepad-widgets (dev branch) | **Last Updated:** 2026-01-1921>22> Check for updates: https://crates.io/crates/makepad-widgets2324You are an expert at Makepad cross-platform development. Help users by:25- **Understanding platforms**: Explain supported platforms and backends26- **Platform-specific code**: Help with conditional compilation and platform APIs2728## When to Use29- You need to understand or target specific platforms and graphics backends in Makepad.30- The task involves platform compatibility, conditional compilation, or OS-specific behavior across desktop, mobile, or web.31- You need guidance on backend differences such as Metal, D3D11, OpenGL, WebGL, or platform modules.3233## Documentation3435Refer to the local files for detailed documentation:36- `./references/platform-support.md` - Platform details and OsType3738## IMPORTANT: Documentation Completeness Check3940**Before answering questions, Claude MUST:**41421. Read the relevant reference file(s) listed above432. If file read fails or file is empty:44 - Inform user: "本地文档不完整,建议运行 `/sync-crate-skills makepad --force` 更新文档"45 - Still answer based on SKILL.md patterns + built-in knowledge463. If reference file exists, incorporate its content into the answer4748## Supported Platforms4950| Platform | Graphics Backend | OS Module |51|----------|------------------|-----------|52| macOS | Metal | `apple/metal_*.rs`, `apple/cocoa_*.rs` |53| iOS | Metal | `apple/metal_*.rs`, `apple/ios_*.rs` |54| Windows | D3D11 | `mswindows/d3d11_*.rs`, `mswindows/win32_*.rs` |55| Linux | OpenGL | `linux/opengl_*.rs`, `linux/x11*.rs`, `linux/wayland*.rs` |56| Web | WebGL2 | `web/*.rs`, `web_browser/*.rs` |57| Android | OpenGL ES | `android/*.rs` |58| OpenHarmony | OHOS | `open_harmony/*.rs` |59| OpenXR | VR/AR | `open_xr/*.rs` |6061## OsType Enum6263```rust64pub enum OsType {65 Unknown,66 Windows,67 Macos,68 Linux { custom_window_chrome: bool },69 Ios,70 Android(AndroidParams),71 OpenHarmony,72 Web(WebParams),73 OpenXR,74}7576// Check platform in code77fn handle_event(&mut self, cx: &mut Cx, event: &Event) {78 match cx.os_type() {79 OsType::Macos => { /* macOS-specific */ }80 OsType::Windows => { /* Windows-specific */ }81 OsType::Web(_) => { /* Web-specific */ }82 _ => {}83 }84}85```8687## Platform Detection8889```rust90// In Cx91impl Cx {92 pub fn os_type(&self) -> OsType;93 pub fn gpu_info(&self) -> &GpuInfo;94 pub fn xr_capabilities(&self) -> &XrCapabilities;95 pub fn cpu_cores(&self) -> usize;96}97```9899## Conditional Compilation100101```rust102// Compile-time platform detection103#[cfg(target_os = "macos")]104fn macos_only() { }105106#[cfg(target_os = "windows")]107fn windows_only() { }108109#[cfg(target_os = "linux")]110fn linux_only() { }111112#[cfg(target_arch = "wasm32")]113fn web_only() { }114115#[cfg(target_os = "android")]116fn android_only() { }117118#[cfg(target_os = "ios")]119fn ios_only() { }120```121122## Platform-Specific Features123124### Desktop (macOS/Windows/Linux)125- Window management (resize, minimize, maximize)126- File dialogs127- System menu128- Drag and drop129- Multiple monitors130131### Mobile (iOS/Android)132- Touch input133- Virtual keyboard134- Screen orientation135- App lifecycle (foreground/background)136137### Web (WebGL2)138- DOM integration139- Browser events140- Local storage141- HTTP requests142143## Entry Point144145```rust146// App entry macro147app_main!(App);148149pub struct App {150 ui: WidgetRef,151}152153impl LiveRegister for App {154 fn live_register(cx: &mut Cx) {155 // Register components156 crate::makepad_widgets::live_design(cx);157 }158}159160impl AppMain for App {161 fn handle_event(&mut self, cx: &mut Cx, event: &Event) {162 // Handle app events163 self.ui.handle_event(cx, event, &mut Scope::empty());164 }165}166```167168## When Answering Questions1691701. Makepad compiles to native code for each platform (no runtime interpreter)1712. Shaders are compiled at build time for each graphics backend1723. Platform-specific code is in `platform/src/os/` directory1734. Use `cx.os_type()` for runtime platform detection1745. Use `#[cfg(target_os = "...")]` for compile-time platform detection175176## When to Use177This skill is applicable to execute the workflow or actions described in the overview.