Commit graph

1483 commits

Author SHA1 Message Date
Florian Blasius
6d6b18300a
added focus state to StandardLIstView (#4086)
* added focus state to StandardLIstView

* (wip) focus handling for qt style

* Update CHANGELOG.md

Co-authored-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>

* Share StandardListView between all styles

* Update internal/compiler/widgets/material-base/combobox.slint

Co-authored-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>

* code review feedback

---------

Co-authored-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
2023-12-08 10:58:58 +01:00
Tobias Hunger
3a87342073 testing: Add a method to the testing interface to query the mocked time
I find this helpful when debugging tests using mocked time.
2023-12-01 17:36:18 +01:00
Simon Hausmann
19f6840452 Remove now unused Qt license files 2023-12-01 14:48:07 +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
Olivier Goffart
a266e63549 Testing: Add some tests for setting the mouse cursor 2023-11-23 07:25:46 +01:00
Simon Hausmann
cb51fdfe81 janitor: bump xkbcommon dependency 2023-11-14 16:00:56 +01:00
Simon Hausmann
269b327cff janitor: bump calloop dependency 2023-11-14 15:56:24 +01:00
Simon Hausmann
d68b981a16 Upate cocoa dependency
cc #3922
2023-11-14 19:23:32 +08:00
Simon Hausmann
58f9cf5d36 Port to new vulkano
This might fix the issue with resizing causing swapchain re-creation
errors, because "Swapchain creation no longer returns an error when the
swapchain extent doesn't match the current surface extent."

cc #3850
2023-11-13 12:39:59 +01:00
Simon Hausmann
0118363bec Fix build with only backend-linuxkms
Activate the kms feature of softbuffer correctly, when building without
default features.
2023-11-13 11:14:03 +01: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
f03507ee6a Fix CI build: intra links don't work on non-android in the android backend 2023-11-02 17:53:57 +01:00
Olivier Goffart
45d6cd1f7f
Android: add readme for the backend (#3836)
To serve as docs while the backend is still internal

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2023-11-02 17:17:06 +01:00
Olivier Goffart
5f36eaca9a Android: handle InputEvent::TextEvent 2023-11-02 12:16:40 +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
1864257f29 Silence error when rendering SVG in an 0x0 size
Make the size argument to svg::render optional to mean that it is the
default size of the image.
Otherwise, passing None as the size to ImageInner::render_to_buffer
would not render the image which is possible in some backend (eg: the
button image icon with the qt backend)

And if the image is really rendered on an empty because of layouting or
so, we don't need to show a warning anyway.

Fix #3790
2023-11-02 11:09:20 +01:00
Olivier Goffart
51dbd441b0 android-activity backend: Don't use the public slint crate 2023-10-31 16:22:11 +01:00
Olivier Goffart
cf9f9a4f15 Disable all backends on android 2023-10-31 16:22:11 +01:00
Olivier Goffart
d63ff9c4c6 WIP: introduce an android-activity backend 2023-10-31 16:22:11 +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
9ffe26459f Layout: when using a fixed window size, dissociate the WiondowItem's size with the slint size
If you have a window like so:
```
component W inherits Window {
   width: 200px; // or some other bindings
}
```

Before this patch, it will be converted by the compiler to something like

```
component W inherits Window {
   width: 200px; // or some other bindings
   min-width: width; // (not actual property, but part of the layout_info)
   max-width: width;
}
```

When the window is on the screen, the platform backend will set the max
with and min width on the window manager window to the value from the
layout info.
But slint will also set the width and the height of the WindowItem to
the actual value.  This will break the binding for width if any, and
will also cause the min and max with do be updated, which is wrong.

We haven't had much problem with that before, but with the
ComponentContainer, this becomes a problem as we want to set the width
and height of the inner from the outer by adding a two way binding,
which cause a binding loop at runtime.

The behavior change is that if you have a fixed window size and use that
on a MCU or platform that has a different size, the window will be
cropped or padded but will no longer be resized
2023-10-27 17:45:46 +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
7b4d9de590 Silence compiler warning 2023-10-26 14:41:07 +02:00
Thorbjørn Lindeijer
081e7fe456 Qt: Fix executable name passed to QApplication
The name passed was always "Slint", which can show up in the task
switcher, as seen on Linux/Xfce. Instead, we now use std::env::args() to
pass the actual first argument.

I think ideally this should use std::env::args_os() since we don't need
the data to be valid unicode (in which case this will panic). However,
stable Rust does not appear to provide a way to get at the bytes of an
OsString.
2023-10-25 16:58:28 +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
3a8c64c946 Show errors from all backends of initialization fails 2023-10-24 15:47:08 +02:00
Simon Hausmann
6fb325ebea Make it possible to run apps with linuxkms while winit is enabled
In the backend selector try all available backends.
2023-10-24 15:47:08 +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
Tobias Hunger
49571c8bf2 qt: Silence warning during Slint build
Silence this warning:

```
warning: i-slint-backend-qt@1.3.0: qt_window.rs:1536:17: warning: ignoring temporary created by a constructor declared with 'nodiscard' attribute [-Wunused-value]
```
2023-10-23 16:52:42 +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