Commit graph

703 commits

Author SHA1 Message Date
Simon Hausmann
7b61e455eb Initial implementation of a Slint event loop sitting on top of Node.js
At the moment this is implemented using polling.

cc #2477
2023-11-06 11:37:45 +01:00
Simon Hausmann
ee9f1a52a8 winit: Make it possible to resume the event loop while maintaining state
This way if for example the application quits the event loop while
pressed is true, and then resumes shortly afterwards, we maintain the
pressed state correctly.
2023-11-06 11:37:45 +01:00
Simon Hausmann
3a9288003d
Re-enable accesskit (#3833)
Port to the latest accesskit and accesskit_winit:

- NodeId is now a u64 instead of u128, so trim the component/item encoding.
- Adjust to some enum renamings.
- TreeUpdate now always requires a focus node, which we set to the root.
- Fixed focus handling on macOS: Report FocusIn to the accesskit
  adapter, so that it can update its internal host_is_focused state
  correctly.
2023-11-05 09:04:05 +01:00
Olivier Goffart
19954d39ac Call set_resizable before setting the constraints
Not sure why, but it fixes that applying the constraints is otherwise
not working with winit on X11

This is not the first time we do this fix:
723f89d342 and 1891e4489a
2023-11-03 18:51:49 +01:00
Simon Hausmann
ed570053a9 Fix copy & paste in wasm builds
Commit f24014a2dd made the insert function
private. Let's solve this differently by creating a private WASM
clipboard and invoking copy() and paste() on the Text item instead.

The first attempt was implementing a ClipboardProvider just for the wasm
build, just like with SilentClipboard, but unfortunately that doesn't
work because in the backend's set_clipboard_text()/clipboard_text()
functions, there's no currently running winit event loop that we could
access, becaused the call stack starts directly at the DOM event
handler, not in our winit event handler.
2023-11-03 17:36:58 +01:00
Simon Hausmann
bc14ce66c2 Fix resizing of windows on Wayland
On wayland, we may not be getting a resize event, after issuing `request_inner_size()`.
Without that, we would fail to size the EGL surface correctly.

Centralize all request_inner_size() call sites
and dispatch a "local" resize event if the new size is returned by winit.

Fixes #1671
2023-11-03 16:33:21 +01:00
Olivier Goffart
de86c6049c Adapt wasm to the latest changes 2023-11-02 12:16:40 +01:00
Olivier Goffart
f24014a2dd Refactor the internal IME event
Base the info on what's discussed in #3811
but this is just the internal event and not the public API
2023-11-02 12:16:40 +01:00
Olivier Goffart
1efd83621d Refactor: Merge KeyInputEvent and KeyEvent
Both structure are bascially the same and only used internally, no need
to have the two.

The only difference was that one had the modifiers and the other one
not. But we can just set the modifier at the point we were converting
between the two.
2023-11-02 12:16:40 +01:00
Olivier Goffart
bebec49398 Refactor input_method_request
Part of #3811

But this is still on the internal trait for now
2023-11-02 12:16:40 +01:00
Olivier Goffart
b2645dff6c Wasm: use the winit spawn() api to run the event loop for the interpreter
This seems to solve the bug that the wasm interpreter (or slintpad) is
not working when compiled in release since the winit0.29 update
2023-10-30 14:17:10 +01:00
Simon Hausmann
725db9f2bb winit: Clean up event loop state handling part 2
Move all of the event processing into EventLoopState.
2023-10-30 14:17:10 +01:00
Simon Hausmann
0032d74dc2 winit: Clean up event loop state handling part 1
Encapsulate the mouse state in a struct.
2023-10-30 14:17:10 +01:00
Simon Hausmann
f941357337 Upgrade to glutin 0.31.1 to fix window transparency on macOS
Fixes #3760
2023-10-30 08:58:25 +01:00
Olivier Goffart
0c529cd345 janitor: Some no-brainer deps update 2023-10-27 19:11:38 +02:00
Olivier Goffart
3deb620953 Skia: disable skia software renderer for android
softbuff doen't compile on android
2023-10-26 14:52:07 +02:00
Simon Hausmann
9884b14ee0 Make GL rendering work again on macOS
Disable transparency support to work around https://github.com/rust-windowing/glutin/issues/1640
2023-10-25 08:43:42 +02:00
Simon Hausmann
11ce7a2d59 Don't compile glutin twice
Use the same glutin version everywhere
2023-10-25 08:43:42 +02:00
Simon Hausmann
30c810be00 winit: Propagate errors when winit fails to initialize the event loop
For the backend selector, this means that when a backend is selected explicitly,
and initialization fails, don't try `create_default_backend()` but
propagate the error.

For the Rust code generator, propagate the first ensure_backend()
errors. Any subsequent onces (unlikely, since the first thing any
public new() calls is ensure_backend) will unwrap.
2023-10-24 15:47:08 +02:00
Olivier Goffart
0359071b1e
Winit initial size adjustments and wasm size fixes
Following the winit 0.29 merge, a few adjustments are in order:

 - Make slint::Window.set_size() before show keep the size
 - on wasm, attempt to keep the size of the canvas from CSS
 - on wasm, one must set the width and height explicitly on the canvas
   otherwise there is wierd scaling
 - on wasm, we can't set None as maximum or minimum size otherwise winit
   panics
 - It seems that the hack we had to keep the size in range is no longer
   necessary
 - The hack in the slide puzzle can be removed. (but unfortunately it
   doesn't follow resizes

Unfortunatelly we always call set_inner_size to avoid infinite loop when
the css properties are not specificed, so this will override layouts

Also we don't default anymore to the preferred size

* Update internal/backends/winit/winitwindowadapter.rs
2023-10-24 15:28:18 +02:00
Simon Hausmann
670fed7dbd Reduce softbuffer features
Only pull in wayland or x11 and skip kms for now.
2023-10-23 14:54:21 +02:00
Olivier Goffart
0597313af8 Skia needs raw-window-handle 0.5
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-10-23 14:22:48 +02:00
Olivier Goffart
28c67294cb softbuffer needs raw-window-handler 0.5 traits 2023-10-23 14:22:48 +02:00
Olivier Goffart
087ed3a8c5 Update to released version of winit 0.29 and glutin 2023-10-23 14:22:48 +02:00
Olivier Goffart
e3dae193f6 winit: Use run_ondemand instead of pump_events
That should be the same, but run_ondemand is showing the intend more
2023-10-23 14:22:48 +02:00
Olivier Goffart
58e5d62a02 Winit port: Fix wasm build
Port everything from instant to web-time
2023-10-23 14:22:48 +02:00
Olivier Goffart
12cd8e71f1 WIP: some polish over the winit update to 0.29 2023-10-23 14:22:48 +02:00
Olivier Goffart
0fac958ebf Revert "Fix touch events not working for wasm builds"
This reverts commit 5879e1ec71.

We will update to next version of winit:
Closes #2424

 Conflicts:
	internal/backends/winit/Cargo.toml
	internal/backends/winit/event_loop.rs
	internal/backends/winit/glwindow.rs
	internal/renderers/skia/Cargo.toml
2023-10-23 14:22:48 +02:00
Tobias Hunger
58d61606cc Winit update to master
Conflicts:
	internal/backends/winit/event_loop.rs
	internal/common/key_codes.rs
2023-10-23 14:22:48 +02:00
Tobias Hunger
1e8574aa74 cleanup: rename a private function 2023-10-23 14:22:48 +02:00
Simon Hausmann
e0cc2e30a3 skia: Avoid unsafe in favor of bytemuck::cast_slice_mut 2023-10-23 13:55:23 +02:00
Simon Hausmann
3855de0794 winit: Add support for selecting Skia's software renderer directly
That might be useful for debugging
2023-10-23 13:55:23 +02:00
Simon Hausmann
f7d666b948 winit backend: clean up renderer creation
Pass around a factory function to create the renderer,
instead of a factory function that creates the window adapter. The adapter is
always the same anyway, and this way the WinitWindowAdapter's new
also doesn't have to be generic.

This also prepares for adding a second skia renderer
constructor later to select a specific variant.
2023-10-23 13:55:23 +02:00
Simon Hausmann
0aa4c42989 skia: Add support for Skia's software renderer 2023-10-23 13:55:23 +02:00
Tobias Hunger
b12575a4c4 janitor: Go over our spell checking setup
* Extend the cspell word list
* Remove those extensions from individual source files
* white-list licenses and such as we should not meddle with those
* Fix spelling
2023-10-16 09:01:51 +02:00
Olivier Goffart
852b4d906d Rename ComponentVTable to ItemTreeVTable
and their related name.
Also move the component module in the item_Tree module
register_component -> register_item_tree
ComponentItemTree -> ItemTreeNodeArray

For #3323

Rationale from that issue:

Right now, we use the term `component` in the Slint language and in the compiler to be a a tree of elements that can be used as an element in a .slint file.

The term is also currently used in the runtime as a tree of runtime Items that are allocated together. (declared in ComponentVTable)

But there are no 1 to 1 mapping between a `component` in the slint language, and a runtime Component.
(for example, the items behind a `if` or `for` or `PopupMenu` are in a different runtime component. And `component` declared in Slint are often inlined)

So we should rename the internal runtime `Component` to  `ItemTree`

The currently public `slint::ComponentHandle` wraps the "root" of the ItemTree, but that's ok because it is generated from a .slint `component`,  so it doesn't change name
2023-10-09 11:01:56 +02:00
Simon Hausmann
afbe73414e
Fix winit backend crate description 2023-10-02 23:02:33 +02:00
Olivier Goffart
89c269e1b9 Unpin winit version
The new version of winit fixes an important bug for macOS Sonoma,
and the bugvix for the workaround won't happen before winit 0.29.
The branch that port to winit 0.29 already removed the workaround

Fixes #3559
2023-09-28 10:10:58 +02:00
Tobias Hunger
85e1c6020b janitor: Use workspace dependnecies for the slint crates
This moves most of the version information we need to update into one
place.

Note that the workplace dependency features are in *addition* to any
feature set when using the workspace dependency. So we have all
workspace dependencies defined with `no-default-features = true`.
2023-09-25 16:34:16 +02:00
Tobias Hunger
d6695c55cb Janitor: Use cargo workspace package data more 2023-09-25 16:34:16 +02:00
Olivier Goffart
4446a17b24 Skia renderer: reset the surface when the app is resumed on android
Part of #3430
2023-09-21 17:23:08 +02:00
Simon Hausmann
fd123b27bd Default to vsync for OpenGL rendering
Fixes #3516
2023-09-20 12:00:04 +02:00
Olivier Goffart
46ec7875ed Software renderer: partial rendering with winit and fix non-opaque background
Implement the partial rendering with winit and our software renderer.

When the background is not opaque, we must still initialize all the
pixel with 0 otherwise we blend over the previous frame.
(That wasn't visible before because the buffer was always empty)
2023-09-13 16:08:57 +02:00
Simon Hausmann
906430416f Update softbuffer dependency
This way we're sure to pull in the fix for rendering
on X11 wire protocol, used under WSL.
2023-09-12 09:32:22 +02:00
Simon Hausmann
3652f58a3f Change item indices from usize to u32
So that the compiler and run-time can never disagree on the
number of bytes the item index can use.
2023-09-12 08:53:58 +02:00
Olivier Goffart
6e1132726a winit-sw: Loop over the buffer instead of using indices
It is possible that softbuf allocate a larger buffer than in needs?

Prospective fix for #3406
2023-09-06 16:04:03 +02:00
tronical
b8b9db4e42 Bump version number to 1.3.0 2023-09-05 15:46:36 +02:00
Olivier Goffart
95b6eda10b Make sure PLatformError is Send+Sync as it is needed for anyhow 2023-08-31 20:52:10 +02:00
Olivier Goffart
fde561a56a Some improvements to Window visibility
- From C++, always call the Window::show() and hide() function instead
   of going through set_visible directly as it doesn't set the size of
   the WindowItem
 - show() should also call resize on the renderer
 - remove the is_visible in the WindowAdapterInternal as it is no longer
   needed
2023-08-30 13:05:35 +02:00
Simon Hausmann
65f9e6f1eb Move the OpenGLInterface back to the FemtoVG renderer
At the moment it's only needed there, so let's
have it there and move it to core later if the need arises.
2023-08-28 13:33:15 +02:00