also looking at this
feat: portable typed window controls on Linux and Windows
#326
9 files
+652
-32
| @@ -32,8 +32,10 @@ The `craft-native` SDK returns a typed `Window` handle. Runtime-created | ||
| 32 | 32 | windows are available on macOS, Linux, and Windows and must provide either |
| 33 | 33 | `html` or `url` content. The common create, close, title, geometry, and event |
| 34 | 34 | routes are cross-platform; some advanced window controls remain macOS-only. |
| 35 | On Linux, the window manager may ignore position requests, especially before | |
| 36 | the window is shown. | |
| 35 | Bounds, centering, resizing constraints, resizability and fullscreen controls | |
| 36 | also work on the typed handle on all three desktop platforms. On Linux, | |
| 37 | position and fullscreen requests are advisory to the window manager (and | |
| 38 | global positioning can be unavailable under Wayland). | |
| 37 | 39 | |
| 38 | 40 | ```typescript |
| 39 | 41 | import { createWindow } from 'craft-native' |
| @@ -62,7 +64,21 @@ const settings = await createWindow({ | ||
| 62 | 64 | }) |
| 63 | 65 | |
| 64 | 66 | await settings.setTitle('Settings — Account') |
| 65 | ``` | |
| 67 | await settings.setBounds({ x: 120, y: 80, width: 800 }) | |
| 68 | await settings.setMinimumSize(480, 360) | |
| 69 | await settings.setMaximumSize(1600, 1200) | |
| 70 | await settings.setResizable(false) | |
| 71 | const canResize = await settings.isResizable() | |
| 72 | await settings.center() | |
| 73 | await settings.setFullscreen(true) | |
| 74 | await settings.toggleFullscreen() | |
| 75 | ``` | |
| 76 | ||
| 77 | The bounds update preserves omitted coordinates and dimensions. Native window | |
| 78 | managers can adjust requested geometry for decorations or screen constraints; | |
| 79 | read `getBounds()` after a resize event if you need the actual result. | |
| 80 | Creation-time `minWidth`/`minHeight` and `maxWidth`/`maxHeight` may constrain | |
| 81 | either axis independently; the native window system's own minimum still applies. | |
| 66 | 82 | |
| 67 | 83 | The older `createWindow(html, options)` overload remains available when the |
| 68 | 84 | content is already in a string. |