# Windows The `windows` feature builds `ltk::run` for Windows 10 1703 or later: the app runs in a Win32 window with Windows's own frame, drawn through ANGLE's EGL and OpenGL ES when ANGLE is beside the executable, and in software through GDI otherwise. An app's code is the same as on Linux; only the build and what ships with the executable differ. ## Building The backends are exclusive, so a Windows build turns the default `wayland` feature off: ```toml [target.'cfg(windows)'.dependencies] ltk = { version = "0.3", default-features = false, features = [ "windows" ] } [target.'cfg(not(windows))'.dependencies] ltk = { version = "0.3" } ``` On Windows, with the MSVC toolchain: ```bash cargo build --release --target x86_64-pc-windows-msvc ``` From Debian, which packages no std for Windows, std is compiled from `rust-src` with `-Zbuild-std`, as for Android, and MinGW links. `make windows-deps` installs both, and `make windows-check` typechecks ltk; a build of the same shape is: ```bash RUSTC_BOOTSTRAP=1 \ CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc \ cargo build --release -Zbuild-std=std,panic_abort --target x86_64-pc-windows-gnu --no-default-features --features windows ``` With rustup instead, `rustup target add x86_64-pc-windows-gnu` installs the target's std and the plain `cargo build --target x86_64-pc-windows-gnu` works. A GUI app should not open a console window beside its own; `#![windows_subsystem = "windows"]` at the top of its `main.rs` does that, at the cost of losing ltk's `[ltk]` lines on standard error, so leave it out while debugging. ## What ships beside the executable ``` app.exe libEGL.dll ANGLE, optional libGLESv2.dll ANGLE, optional ltk\ themes\default\ the theme, as ltk-theme-default installs it on Debian fonts\ fonts the theme names, found by file name keyboards\ on-screen keyboard layouts, if the app uses them mime\globs2 shared-mime-info's globs, for ltk::files' MIME types ``` `ltk\` is the app's resource bundle ([`ltk::resource_dir`]): themes, fonts, keyboard layouts and MIME globs are looked up there as on Android they are in the APK, and a font a theme names by a Debian path, such as `/usr/share/fonts/opentype/sora/Sora-Regular.otf`, is found in `ltk\fonts\` by its file name. An app that keeps its resources elsewhere calls `ltk::set_resource_dir` before its theme is first used. `LTK_THEMES_DIR` and `LTK_KEYBOARDS_DIR` still take precedence, and the user's own themes go under `%APPDATA%\ltk\themes\`. ANGLE's two DLLs come with Chromium-based browsers and with the ANGLE releases built for Windows; any recent build that exposes `EGL_DEFAULT_DISPLAY` on Direct3D 11 works. Without them, or with `LTK_FORCE_SOFTWARE=1`, the window is drawn in software, and `[ltk] render backend:` on standard error says which path was taken. The executable's icon, which the window, the taskbar and Alt+Tab show, is its icon resource 1, as the `embed-resource` and `winres` crates put it. ## What the backend does | Area | On Windows | | --- | --- | | Window | One main window with Windows's frame, titled by `App::window_title`, its client area sized by `App::window_size_hint` (800 × 600 logical pixels by default) at the display's DPI, fixed when `App::window_resizable` says so. `App::fullscreen` fills the display without the frame. `WindowButton` and the app's own chrome move, resize and minimise it through Windows's modal loop. The view keeps drawing while the window is moved or resized. | | Scale | Per-monitor DPI awareness: the scale is the display's DPI over 96, fractional at 125 % or 150 %, and follows the window from one display to another. The accessibility setting for text size (`TextScaleFactor`) is followed as GNOME's text scale is on Linux. | | Input | Mouse, wheel and touchpad scrolling, the back side button, touch through `WM_POINTER` (several fingers), pens as a mouse, and keys with Windows's own repeat, dead keys and AltGr. The input method's committed text arrives as typed characters. | | Clipboard | The system clipboard, read again whenever it changes. There is no primary selection; the middle button pastes what was selected within the app. | | Fonts | ltk's embedded Sora as the face, as on Android; the fallback chain for other scripts and emoji is Segoe UI, Nirmala UI, Leelawadee UI, Segoe UI Symbol, Segoe UI Emoji, Malgun Gothic and Microsoft YaHei from `C:\Windows\Fonts`. Consolas is the monospace face. | | Files | `ltk::files` and the file chooser on the file system; the chooser offers the user's profile folders and the root of each drive. | | Locale | `LANG` when set, otherwise the user's locale (`es-ES` as `es_ES`), for the on-screen keyboard. | | Session state | `App::save_state` is saved into `%LOCALAPPDATA%\\` every 30 seconds, on exit and when the user signs out or shuts down, and handed back to `App::restore_state` after a crash, or on every launch when `App::restore_on_launch` says so, as on Wayland. | | Folders | `ltk::dirs` gives the user's folders: `APPDATA` for data and settings, `LOCALAPPDATA` for the cache and state, `USERPROFILE` as the home. | Not done yet: overlays, secondary surfaces and subsurfaces are not created; the input method has no preedit or candidate window placement; accessibility is not exposed (AccessKit's Windows adapter would do it); and the built-in on-screen keyboard is off, as on any desktop, while Windows's touch keyboard does not come up for ltk's fields on its own, so a tablet without a keyboard cannot type into them yet.