Commit graph

692 commits

Author SHA1 Message Date
Simon Hausmann
68083243b2
Add an in-out boolean color-scheme property to Palette (#4701)
This allows applications to force dark/light mode, as well as determine
which mode is active.
2024-03-26 15:44:22 +01:00
Simon Hausmann
ed2816331e
Add support for raw-window-handle (#4918)
Add a `raw-window-handle-06` feature to the Rust API crates, which adds support for version 0.6 of rwh to slint::Window, by delegation adding a `window_handle()` function that returns a struct that implements the corresponding traits from rwh.

HasDisplayHandle could also be provided on the backend, but that can be
done separately if needed.

This is only implemented for the winit backend right now.

cc #877
2024-03-22 14:25:05 +01:00
Montel Laurent
fc0e8faae9
Accessibility: use tab-list for the tabwidget (#4909)
* Don't show tabwidget as tab
2024-03-21 17:48:42 +01:00
Montel Laurent
da30fa2663
Add ListView accessibility role (#4911) 2024-03-21 15:20:43 +01:00
Montel Laurent
4844b84e0c
Add Treeview accessibility support (#4907) 2024-03-21 15:18:52 +01:00
Montel Laurent
c2517008d8
Add TextInput as accessibility role (#4899) 2024-03-21 13:39:31 +01:00
Tobias Hunger
28b96ca6f6 janitor: manual cargo clippy fixes
Semi-random selection of clippy topics that were
uncontroversial before:-).

Leaves about 84 deduplicated issues in the code base
according to clippy from nightly.
2024-03-14 13:42:38 +01:00
Tobias Hunger
9873cfd7c0 janitor: Run cargo clippy --fix
Only the hand-picked sensible things, not all of it ;-)

Also fix a few typos that cspell complained about when I
tried to commit and some formatting changes that cargo fmt
insisted on when commiting.
2024-03-14 13:42:38 +01:00
Olivier Goffart
318fa02226 winit: Cache locally the last value of the minimize/maximize/fullscreen state
Workaround for https://github.com/slint-ui/slint/issues/4678
Ubuntu's window manager using XWayland would raise the window when calling
set_minimized(false) even it was not minimized

Fixes #4678
2024-02-29 13:13:38 +01:00
Olivier Goffart
2c5e654dd0 winit: Make sure to keep the minimized state in sync
Tested with kwin on X11 and on wayland
2024-02-26 15:51:05 +01:00
Olivier Goffart
8bc4c4e053 vtable: increase version number to account for breaking change in vtable::Dyn 2024-02-26 14:45:47 +01:00
Ralph Minderhoud
9cb1a4a4e0
Add API for minimize/maximize on Window component (#4581)
Closes #4400
2024-02-22 10:40:36 +01:00
Olivier Goffart
440b9ce9cc winit: Remove unused function and don't depend on copypasta on wasm
Nightly Rust start warning about these.
And in the case of wasm we don't even need to depend on copypasta since
we handle the copy paste ourselves
2024-02-21 10:52:04 +01:00
Simon Hausmann
99d87934c0 Fix build with --cfg=web_sys_unstable_apis
Amends fadcbdf726
2024-02-05 11:50:09 +01:00
Simon Hausmann
13b93a4af1 winit: Change window activation to default to false on for HTML canvas usage
Don't activate the canvas by default, as that causes winit to call focus() on the DOM element, which in turn will forcibly scroll the browser window.
That means any existing anchors are ignored and the user's scroll preference is disturbed.

Fixes #4431
2024-01-29 14:20:55 +01:00
Simon Hausmann
93142bf417 winit: Always make skia-opengl available
The Skia OpenGL renderer is portable and sometimes esp. on Windows produces better results, so make it always available as an open if `renderer-skia` is enabled. `renderer-skia-opengl` continues to select the GL renderer as default.
2024-01-24 18:20:04 +01:00
Olivier Goffart
9113b877bd winit: avoid to poll or call request_redraw too often
Otherwise there will be a huge queue of request redraw command that
accumulate within winit.
This makes operation such as resizing a bit more soomth

Tested on X11
2024-01-22 19:22:16 +01:00
Simon Hausmann
d9ddc865c2 Fix panic when shutting down process on Linux
Commit 41bfe66447 bumped accesskit
dependencies, which introduced a version that uses threads.

That means the action handler as well as the initial tree update source
closure are destroyed in a thread that's not the ui thread. That means
we destruct a SenderWrapper<Weak<WinitWindowAdapter>> in a thread that
is not the same as the one the wrapper was created in, which causes
Drop for SendWrapper to panic.

Replace the use of SendWrapper here with safely copyable window ids.
2024-01-17 17:07:38 +01:00
Simon Hausmann
8caa5acd30 winit: Avoid warnings about exiting fullscreen mode when compiled for the web
We call set_fullscreen(None) on startup for windows that aren't fullscreen (normally), and winit compiled for the web unconditionally calls canvas.exitFullscreen(), which
may produces warnings about exitFullscreen()
being called when not in fullscreen mode.
2024-01-15 15:22:15 +01:00
Olivier Goffart
a7934438ad Janitor: update some dependencies 2024-01-11 14:01:19 +01:00
Daniel
807a233849
feat: Add Key.Space to Key namespace. (#4311) 2024-01-10 16:25:31 +01:00
Simon Hausmann
438b9afeaa
Reduce WindowAdapter API slightly (#4304)
Move the set_fullscreen function added to the WindowAdapter trait in 779aff0b39
to be a function in WindowProperties instead.
That way it'll be easier in the future to extend this with other window states without
having to modify or break the WindowAdapter trait API.
2024-01-09 18:55:06 +01:00
Harold
779aff0b39
Added set_fullscreen API to WindowAdapter. (#4286)
See #3283
2024-01-09 15:23:23 +01:00
Olivier Goffart
9ff13faee8 Implement the quitting on windows close in i-slint-core and not in the platform
Step towards #1499
2024-01-08 21:17:52 +01:00
Olivier Goffart
b5032ca53f winit: add a hook to adjust the winit::WindowBuilder
This is still internal API but can help for the case of
https://github.com/slint-ui/slint/discussions/4284 where this could be
used to call winit::WindowBuilder::with_titlebar_transparent or others
https://docs.rs/winit/latest/x86_64-apple-darwin/winit/platform/macos/trait.WindowBuilderExtMacOS.html#tymethod.with_title_hidden
2024-01-08 15:17:34 +01:00
Simon Hausmann
f5bf6e5dc0 Skia: Clean up pre present notify callback API
Move this back out of render() again and make it stateful in the renderer. Reduces the amount of book-keeping required and it's always the same callback anyway.
2024-01-04 10:35:09 +01:00
Simon Hausmann
41bfe66447 Bump AccessKit dependencies
This brings lazy initialization of the accesskit adapter on Linux/dbus.

cc #3867
2024-01-04 10:00:55 +01:00
Simon Hausmann
3069e8e503 Add support for frame throttling on Wayland
Use winit's pre_present_notify() API to allow for the compositor to throttle rendering.

Fixes #4200
cc #1695
2024-01-04 09:21:53 +01:00
Simon Hausmann
d0616f31fb winit: Remove hack that makes request_redraw() during draw() work
Calling request_request() during RedrawRequested would not work on
Windows and wasm. Commit 372e6b0ffc worked
around this, but that can be reverted now, as this is fixed in winit.
For windows that was https://github.com/rust-windowing/winit/pull/3165
and for wasm I couldn't find the change, but could verify that it still
works.

I checked that #1574 does not regress.

Besides the cleanup, this is also needed for #1695.
2024-01-03 10:23:34 +01:00
Simon Hausmann
25579ab068 winit: Fix FocusScope's key-released not being invoked when releasing the space bar key
Upon pressing, event.text is set and all is well. But when the space bar is released, event.text is always
empty and we would not dispatch an event.
2024-01-02 15:29:24 +01:00
Simon Hausmann
007de3dd8d Use raw-window-handle 0.6 for accesskit
The new release defaults to using rwh 0.6, which implicitly also
enables rhw_06 on winit.
2023-12-18 17:07:30 +01:00
Horbin
9a1857fb36
Fix the window doesn't automatically resize. (#4032)
Try to fix the issue #3911.

In 1.3.0, the function "adjust_window_size_to_satisfy_constraints" is deleted.
I guess that, in Winit 0.29.x, the window will automatically resize, but, at least, it doesn't work on Windows.
So, I try to add this function back.
2023-11-29 21:04:12 +01:00
Jocelyn Turcotte
82916bc2ec Implement KeyEvent.repeat
Now that winit was upgraded do 0.29 we can use its KeyEvent::repeat field.
Also feed Qt's QKeyEvent::isAutoRepeat() in the Qt backend.
2023-11-29 09:31:31 +01:00
Olivier Goffart
8a841405c8 Revert "Fix timers not firing on Windows"
This reverts commit 1f5f07f65a.

Revert the work around that is no longer required with 0.29.4
(also add this version as a dependency)
2023-11-27 16:39:01 +01:00
Simon Hausmann
d68b981a16 Upate cocoa dependency
cc #3922
2023-11-14 19:23:32 +08:00
Olivier Goffart
0b70cbc9a9 Don't use workspace deps for dev-dependencies
They can't have version otherwise we can't upload to crates.io
2023-11-10 11:03:10 +01:00
Olivier Goffart
1f5f07f65a Fix timers not firing on Windows
On Windows, winit doesn't respect the set_control_flow from the
AboutToWait event.
This is a bug in winit, but we can easily work it around

Fix #3875
2023-11-08 22:10:24 +01:00
Olivier Goffart
8fe1dd9ff8 winit: WindowAdapter::set_visible shouldn't do anything if it is already in that state
calling show() on a visible window or hide() on a hidden window
shouldn't do anything.
Especially currently it would resize to the preferred size.
So that makes the preview UI to alsways resize to the preferred size
because we always call show()
2023-11-08 16:06:12 +01:00
Simon Hausmann
a5c3692fbc Add progress-indicator accessible role 2023-11-07 13:37:12 +01:00
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