Commit graph

692 commits

Author SHA1 Message Date
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
Olivier Goffart
d2fb69c182 winit backend: remove the GLOBAL_PROXY
We have a proxy in the backend, use it
2025-04-09 08:50:39 +02:00
Simon Hausmann
42e65da8e2 Minor cleanup in winit backend
Replace thread-local window registry with the pattern we recommend: reference counted data shared between the backend and the window adapters.
2025-04-09 08:50:39 +02:00
Simon Hausmann
ac256d61d8 winit: replace special private function to spawn event loop with public API in the winit backend builder
This means the event loop spawning goes through the backend, which will permit for state from the Backend struct to be available when spinning the event loop even when spawning it merely.
2025-04-09 08:50:39 +02:00
Simon Hausmann
6aa4c691f0 winit: Simplify default canvas element handling
The winit backend defaults to locating a canvas element with the id "canvas". After the parent commit, this id can't be overridden by the API, so we can remove the function parameters.

(The parent commit implements the override via an attribute hook)
2025-04-09 08:50:39 +02:00
Simon Hausmann
4e65998016 Clean up wasm-interpreter / winit interface
Use the window attributes hook instead of a private function in the winit backend.
2025-04-09 08:50:39 +02:00
Olivier Goffart
23aa4ed8c6 Fixup menu separator with muda 2025-04-03 15:49:35 +02:00
Olivier Goffart
e5289af154 Introduce MenuSeparator
Fixes #7790
2025-04-02 11:50:45 +02:00
Simon Hausmann
3797ed79bc Fix crash when opening ComboBox
Don't do partial tree rebuilds if we know that a full rebuild is pending and that the current focus node may thus not be node mapped yet.

Amends 5ff5c0464c

Fixes #7854
2025-04-02 11:49:54 +02:00
Tobias Hunger
cd6f2e2cf2 ci: Format toml files
... using taplo with default settings

I tried this with 4 spaces indentation, but the patch is almost as
big as this one, so I went with default settings instead as that
is just easier:-)
2025-04-02 11:03:41 +02:00
Simon Hausmann
072bff8c42
wasm: Fix some shortcuts on macOS (such as cmd+a) (#7908)
The core library expects command to be mapped to control, and control to meta, for the shortcut detection. This needs to be done separately for the wasm input handling.

This helps with #7477 by fixing cmd+a. Unfortunately, the "copy" and "paste" events, while intercepted by Safari, aren't somehow delivered to our canvas element.
2025-03-22 11:53:49 +01:00
Arnold Loubriat
6aa7744868 Expose more kinds of text edit widgets to AccessKit 2025-03-17 14:27:08 +01:00