Commit graph

703 commits

Author SHA1 Message Date
Simon Hausmann
3101104f5c Switch from WGPU 24 to WGPU 25
- Use a version of FemtoVG that uses WGPU 25
- Rename the unstable-wgpu-24 feature and wgpu_24 module
- Fetch bevy from a revision on master branch that switches to WGPU 25
- Move the bevy example out of the common workspace: That way users of the repo don't get bevy pulled from git, unless they want to build the bevy example.
2025-07-09 11:30:05 +02:00
Simon Hausmann
b2b3a09d52 winit: Bump AccessKit versions 2025-07-08 13:16:10 +02:00
Simon Hausmann
bf8729d7f3
winit: Add support for timer based frame throttling (#8828)
Fixes #8826
2025-07-02 09:37:57 +02:00
Simon Hausmann
fae218fa6b winit: Fix the maximize window not being disabled for fixed-size windows
The workaround of PR #6997 does not work anymore as the window is created much later. Apply the workaround when creating the window.
2025-06-26 22:45:37 +02:00
Joshua Goins
c09ed19a85 Menu: Add icon property
This adds an icon that is displayed to the left of the title, and is
also shown for Menus are inside of a parent menu.

Closes #7791

ChangeLog: Added icon property to MenuItem and Menu
2025-06-26 18:45:37 +02:00
Olivier Goffart
526c5da24c Don't use the extended debug of the DisplayHandle in the error message
Keep the error message in one line.
Error such as

```
Error: Error creating OpenGL display (Ok(
    DisplayHandle(
        Wayland(
            WaylandDisplayHandle {
                display: 0x00005641c528e590,
            },
        ),
    ),
)) with glutin: not found
```

Are not easy to parse because of all the new lines
2025-06-25 15:06:21 +02:00
Simon Hausmann
b7926f17f5 winit: Fix window constraints (min, max, pref) not being applied sometimes
Some checks are pending
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / build_and_test (--exclude bevy-example, ubuntu-22.04, 1.82) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, --exclude bevy-example, windows-2022, 1.82) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
We convert constraints into physical sizes so that an overriding scale factor is applied, instead of the windowing system one. However, that breaks when the window isn't known yet *and* there's no overriding scale factor. Store window constraints and pending sizes as logical sizes first.

When applying to a window directly, convert to physical using our own scale factor. When applying on window creation, apply only an overriding scale factor, otherwise let winit apply the scale factor, because we don't know the final value only after window creation.

Fixes #8765
Fixes #8736
2025-06-24 22:30:45 +02:00
kilavvy
069313f39e Update winitwindowadapter.rs
Some checks failed
CI / tree-sitter (push) Has been cancelled
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, --exclude bevy-example, windows-2022, 1.82) (push) Has been cancelled
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Has been cancelled
CI / build_and_test (--exclude bevy-example, ubuntu-22.04, 1.82) (push) Has been cancelled
CI / build_and_test (ubuntu-22.04, nightly) (push) Has been cancelled
CI / node_test (macos-14) (push) Has been cancelled
CI / node_test (ubuntu-22.04) (push) Has been cancelled
CI / node_test (windows-2022) (push) Has been cancelled
CI / python_test (macos-14) (push) Has been cancelled
CI / python_test (ubuntu-22.04) (push) Has been cancelled
CI / python_test (windows-2022) (push) Has been cancelled
CI / cpp_test_driver (macos-13) (push) Has been cancelled
CI / cpp_test_driver (ubuntu-22.04) (push) Has been cancelled
CI / cpp_test_driver (windows-2022) (push) Has been cancelled
CI / cpp_cmake (macos-14, 1.82) (push) Has been cancelled
CI / cpp_cmake (ubuntu-22.04, stable) (push) Has been cancelled
CI / cpp_cmake (windows-2022, nightly) (push) Has been cancelled
CI / cpp_package_test (push) Has been cancelled
CI / vsce_build_test (push) Has been cancelled
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Has been cancelled
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Has been cancelled
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Has been cancelled
CI / mcu-embassy (push) Has been cancelled
CI / ffi_32bit_build (push) Has been cancelled
CI / updater_test (0.3.0) (push) Has been cancelled
CI / fmt_test (push) Has been cancelled
CI / esp-idf-quick (push) Has been cancelled
CI / android (push) Has been cancelled
CI / miri (push) Has been cancelled
CI / test-figma-inspector (push) Has been cancelled
2025-06-21 08:00:10 +02:00
Olivier Goffart
836b217002 Update muda dependency
... which get rid of the unused gtk dependency

Fixes #7800
2025-06-20 09:45:42 +02:00
Simon Hausmann
4c0d85e9b1 doc: Extend WinitWindowAccessor docs with the caveat of the active event loop 2025-06-18 14:25:13 +02:00
Simon Hausmann
1147e2fdf8 winit: Abort the event loop if creating a window failed
This was fatal in previous released and still should be fatal. Otherwise failure will result in a silent perceived hang, as the event loop continues to spin.
2025-06-16 11:06:20 +02:00
Olivier Goffart
7785308c0e winit: Fix warnings and docs of the CustomApplicationHandler change
Some checks are pending
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
2025-06-10 16:59:47 +02:00
Simon Hausmann
f123e50978 WIP: winit: introduce CustomApplicationHandler trait 2025-06-10 16:59:47 +02:00
Olivier Goffart
73d6095535 winit: Rename some function and add docs cross reference
CC https://github.com/slint-ui/slint/issues/8631#issuecomment-2957986384
2025-06-10 16:21:58 +02:00
Olivier Goffart
c0cac46009 Add --generate-link-to-definition in the docs of all our published crate
This is a nice nightly rustdoc feature and we should make use of it
2025-06-06 21:47:36 +02:00
Olivier Goffart
7b4d2fd3d3 Renames after the API review
CC #8631
2025-06-06 12:31:50 +02:00
Avery Townsend
8c4ccabf7d
Expose FocusReason to .slint as an argument in focus-event-changed and add focus-gained and focus-lost callbacks (#8569)
This exposes FocusReason to .slint, and adds it as an argument to focus-event-changed callback on FocusScope to close #8387. It also adds two new callbacks, focus-gained and focus-lost, which are identical to focus-event-changed but are only invoked on focus gain or loss respectively.

In addition to this, it removes the FocusEventReason::AccessKit variant, replacing it with the mouse variant to hopefully make AccessKit more compatible with any Slint code that will use FocusEventReason.

Finally, I added two tests based on focus_change_event.slint, one for testing the FocusEventReason argument and another for testing the new callbacks.

close #8387

ChangeLog: Added `focus-gained` and `focus-lost` callback to FocusScope.  Pass an `FocusReason` enum to the FocusScope callbacks
2025-06-04 09:51:26 +02:00
Luke Jones
fd6bf2900a Update zbus crate to 5.7 for winit backend
Signed-off-by: Luke Jones <luke@ljones.dev>
2025-06-02 08:56:37 +02:00
Avery Townsend
c41d4a4df3
Add FocusEventReason to FocusEvent and add a select all on keyboard focus for TextInput (#8523)
Closes #5992

Adds the enum FocusEventReason and makes it an argument for FocusEvent. This reason could eventually be exposed in Slint to solve #8387.

Using the focus reason tracking, I also added a select all on keyboard focus for TextInputs (except on macOS), which should close #5992.

ChangeLog: TextInput selects its content when focused with the keyboard on Windows and Linux
2025-05-27 07:56:13 +02:00
Simon Hausmann
23c1989e59 winit: Fix preferred window size not being taken into account when it changes multiple times between window creation and the resize event received from the window manager
Some checks failed
CI / ffi_32bit_build (push) Has been cancelled
CI / updater_test (0.3.0) (push) Has been cancelled
CI / fmt_test (push) Has been cancelled
CI / esp-idf-quick (push) Has been cancelled
CI / android (push) Has been cancelled
CI / miri (push) Has been cancelled
CI / test-figma-inspector (push) Has been cancelled
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Has been cancelled
CI / build_and_test (ubuntu-22.04, 1.82) (push) Has been cancelled
CI / build_and_test (ubuntu-22.04, nightly) (push) Has been cancelled
CI / node_test (macos-14) (push) Has been cancelled
CI / node_test (ubuntu-22.04) (push) Has been cancelled
CI / node_test (windows-2022) (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / python_test (windows-2022) (push) Has been cancelled
CI / cpp_test_driver (macos-13) (push) Has been cancelled
CI / cpp_test_driver (ubuntu-22.04) (push) Has been cancelled
CI / cpp_test_driver (windows-2022) (push) Has been cancelled
CI / wasm (push) Has been cancelled
CI / cpp_cmake (macos-14, 1.82) (push) Has been cancelled
CI / cpp_cmake (ubuntu-22.04, stable) (push) Has been cancelled
CI / cpp_cmake (windows-2022, nightly) (push) Has been cancelled
CI / cpp_package_test (push) Has been cancelled
CI / wasm_demo (push) Has been cancelled
CI / tree-sitter (push) Has been cancelled
CI / vsce_build_test (push) Has been cancelled
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Has been cancelled
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Has been cancelled
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Has been cancelled
CI / mcu-embassy (push) Has been cancelled
In this phase between the window being resized and receiving the resize event, the pending_requested_size variable tracks the value to be used in adjust_window_size_to_satisfy_constraints. Unfortunately,
it was never set.

Amends commit 1c73144b09.

Fixes #8452
2025-05-17 10:13:08 +02:00
Simon Hausmann
94a41864ff winit: Add support for SVG icons in the window title
Use the render_to_buffer function to handle not just loaded pixel images.
2025-05-12 16:21:17 +02:00
Simon Hausmann
126955fd1e
winit backend: Don't update the window icon unnecessarily (#8439)
Fixes #7994
2025-05-12 14:47:30 +02:00
Simon Hausmann
92f3a9a5ac winit backend: Enable Skia by default on iOS, etc. (but not macOS) 2025-05-09 20:54:47 +02:00
Simon Hausmann
435e2c4c34 Fill initial window size on IOS 2025-05-09 20:54:47 +02:00
Simon Hausmann
bd0a486da8 Clean up cfgs for Apple operating systems
Replace ios specific cfgs with "apple but not macOS", dubbed
ios_and_friends, so that we also cover iPadOS, etc.. What those have in
common is that they don't have user-resizable windows. (We might want to
add visionOs in the future)

Also, simplify a few macos or ios cfgs with just target_vendor =
"apple", for what applies to all the operating systems.
2025-05-09 20:54:47 +02:00
Arnold Loubriat
5a9dc2152b Set size of set on AccessKit container nodes 2025-05-09 15:23:31 +02:00
Simon Hausmann
6070324848 winit: Remove ACTIVE_EVENT_LOOP thread-local
Process pending inactive windows to create at the end of each event loop cycle.
2025-05-09 13:17:34 +02:00
Simon Hausmann
f6f144ed87 Update to accesskit 0.19 and accesskit_winit 0.26 2025-05-09 13:07:50 +02:00
Simon Hausmann
6aafdeefad Update to accesskit 0.18 and accesskit_winit 0.26
Fixes #8148
2025-05-09 13:07:50 +02:00
Simon Hausmann
644a57a29e Fix panic when starting the gallery
- When initializing the muda adapter, don't try to borrow from winit_window_or_none (how did this ever work?)
- When attempting to invoke the accesskit adapter, try to borrow winit_window_or_none. This may fail when updating the menu shadow tree (for which accessibility isn't handled by accesskit).

Amends 1c73144b09
2025-05-09 10:27:42 +02:00
Simon Hausmann
1c73144b09 Winit: Implement the "resume protocol"
In future versions of winit, it'll only be possible to create windows
when the active event loop signals availability. To upgrade to the latest
accesskit version as well as to run on iOS, we're going to implement support
for this earlier and stop using the deprecrated create_window() function
on the regular (not running) EventLoop.

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2025-05-09 09:36:37 +02:00
Simon Hausmann
98a68b8a0c winit: Minor cleanup
Inline the code to create the event loop to the single call site.
2025-05-09 09:36:37 +02:00
Simon Hausmann
0002df2520
slint crate: Expose parts of the winit backend's previously private API (#8315)
Similar to the wgpu access, the `unstable-winit-030` feature exposes a
`slint::winit_030` module, which in turn re-exports `winit` but also
provides access to the `WinitWindowAccessor` trait. The
`BackendSelector` is extended to provide a way to hook into window
attribute creation as well as providing a custom event loop builder,
similar to what `i_slint_backend_winit::BackendBuilder` provides.
2025-05-02 09:21:13 +02:00
Simon Hausmann
4d41be428e CI: Fix build with unstable-wgpu-24 and renderer-skia feature flags 2025-05-01 21:11:19 +02:00
Simon Hausmann
302926edfa
Skia: Improve multi-window rendering resource consumption (#8304)
Share Vulkan instance as well as Metal device and command queue across windows.
2025-04-29 18:58:09 +02:00
Simon Hausmann
33581182ef backend-selector: Add the ability to configure WGPU
The `require_wgpu_24` function accepts either a fully setup WGPU, or one
can configure individual aspects such as features/limits.

The wgpu_texture example uses this to add push constants to the required
features and thus eliminates the need for uniform buffers.
2025-04-29 17:46:57 +02:00
Simon Hausmann
da5e7d5b22 WGPU: Add support for using WGPU textures in Slint
This adds a `unstable-wgpu-24` feature that exposes WGPU types in the
GraphicsAPI enum, adds `require_wgpu_24()` to the backend selector,
and adds a conversion from `wgpu::Texture` to `slint::Image`.

The `require_wgpu_24()` function in the selector will be extended in the
future (before the next release) to permit specifying additional aspects
of the WGPU configuration.

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2025-04-29 17:46:57 +02:00
Simon Hausmann
8261e405d3 doc: Fix markdown syntax 2025-04-29 16:52:14 +02:00
Simon Hausmann
a50b8f8793
FemtoVG: Add support for WGPU based rendering (#8268)
Enable via the `renderer-femtovg-wgpu` feature flag.

cc #171
2025-04-25 14:37:32 +02:00
Simon Hausmann
98dc4a8657 FemtoVG: Abstract the rest of the FemtoVGRenderer type to be independent from OpenGL
The main visible external change is that FemtoVGRenderer is now a generic type, but in the public Slint API the type alias that uses the OpenGL backend is re-exported under the old name. This looks a little different in rustdoc
but appears to be source compatible.
2025-04-25 10:08:38 +02:00
Simon Hausmann
6595aee73c
Replace use of Rc<winit:🪟:Window> with Arc (#8257)
In preparation for wgpu usage, where the wgpu API requires the window
handle to be send, i.e. Arc<dyn HasWindowHandle>.
2025-04-24 13:28:51 +02:00
Simon Hausmann
b098bccc32 Propagate default font properties into PopupWindow 2025-04-24 09:18:45 +02:00
U-ALDEBERAN\Nate
a80e261d1d Resurrected create_winit_window
With a previous PR, I added a hook to enable the creation of a winit window, which necessitated accessing the winit event loop (https://github.com/slint-ui/slint/pull/7227).  This hook was removed in `cd29bdd367` because the Slint event loop was moved to `SharedBackendData`.

I'm very open to the possibility that this is not the correct change, perhaps due to one or more of the following
- Making `shared_backend_data` public
- The `unwrap()` calls
- The possibility that exposing `with_event_loop()` may be a better solution
2025-04-15 11:52:31 +02:00
Olivier Goffart
ce904dd518 muda: Implement the enabled flag
Follow-up of https://github.com/slint-ui/slint/pull/8145
2025-04-15 08:54:10 +02:00
Olivier Goffart
25a037437e janitor: Fix compilation warning about unused import
when compiling winit backend with software renderer only
2025-04-11 18:48:33 +02:00
Simon Hausmann
3116ccf6d5
winit: separate menubar vbox from muda adapter (#8109)
The latter's life time is tied to the winit window and should live in WinitWindowOrNone.

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2025-04-11 13:02:34 +02:00
Simon Hausmann
cd29bdd367 Winit: remove maybe_loop_instance thread local
In the future, the plain winit::event_loop::EventLoop won't be usable for window creation anymore. There are two places where we need it:

1. From places where we also have access to the shared backend data.
2. From the top-level create_winit_window() function.

The latter we have to eliminate in the future, so might as well do it now and clean up to have one thread local less.
2025-04-11 09:37:03 +02:00
Simon Hausmann
fe56fdd5e4 Minor cleanup
Reduce access to CURRENT_WINDOW_TARGET thread-local
(via renamed with_event_loop function) from the renderer adapters.
2025-04-11 09:37:03 +02:00
Olivier Goffart
78a3757b7f
Remormat all the toml file again to fix npm upload
Commit cd6f2e2 reformated the .toml, but the 80 char width column is
judged too small to be practical

Add a .taplo.toml file

Also do not split feature array
2025-04-09 15:06:00 +02:00
Simon Hausmann
390c56a30e Winit: Clean up EventLoopInterface
In preparation for removing it altogether, remove the call to winit::platform::wayland::EventLoopExtWayland::is_wayland() with a matches!(winit_window.window_handle(), WindowHandle::Wayland(...))
2025-04-09 08:53:07 +02:00