Commit graph

703 commits

Author SHA1 Message Date
Olivier Goffart
666a892fa6
winit: Don't forward synthetic event to the application
Fixes #5823
2024-08-12 14:37:38 +02:00
Simon Hausmann
11ce002314 macOS: Fix windows not resizing/redrawing correctly when showing again after calling hide
Don't assume that any pending redraw request will be delivered when the window his shown/hidden.

Amends 9113b877bd

Fixes #5658
2024-07-23 13:35:35 +02:00
Simon Hausmann
28f7ee7c7d winit: Prefer X11 over Wayland when running in WSL
This is a workaround for the compositor on WSL tending to crash.
Unfortunately we can't just try to create an event loop with x11 first
and then re-try with wayland, winit doesn't allow that. So just avoid
wayland for now.

The long term solution #5667

Fixes #5657
2024-07-22 14:12:14 +02:00
Simon Hausmann
0be2d4521e API Review: Remove suspend/resume related functions from FemtoVG renderer
This could've been `set_opengl_context` taking an `Option`, but it turns
out that makes for an awkward interface when wanting to pass None,
because that also then requires a dummy type for the OpenGL context even
though none is wanted.
2024-07-08 12:23:56 +02:00
Simon Hausmann
89b80eb00e API review: move {window,display}_handle_06_rc() into WindowAdapterInternal 2024-07-05 20:48:02 +02:00
Olivier Goffart
7c93c7438b Rename resize-border => resize-border-width 2024-07-05 12:50:16 +02:00
Noah Sweilem
6095398374
Winit window event filter (#5531)
* Add winit window event filter (#3066)

* Winit window event filter changelog entry

* Format fixes

* More format fixes

* Make requested changes

- Callback gets a ref to the Slint window
- Callback returns an enum
- Callback is no longer `Send`

* Format fixes

* More format fixes

* Merge conflict fixes

* Rename members of `WinitWindowEventResult`

Closes #3066
2024-07-04 17:41:57 +02:00
Simon Hausmann
1ab68d53ed winit: remove unnecessary helper function to access winit window 2024-07-03 18:01:48 +02:00
Simon Hausmann
cc1038baf8 Oops, fix non-wasm build 2024-07-03 16:06:47 +02:00
Simon Hausmann
c1e1a81b93 Fix some wasm build warnings 2024-07-03 15:46:28 +02:00
Simon Hausmann
38bc37f72a Add missing dispatch of resize event to the window item when the user resizes the window while being hidden 2024-07-03 14:22:30 +02:00
Simon Hausmann
dd49ecacf3 Make an effort to avoid returning None from WindowAdapter::position() when we have no native window
When the user queries the physical position of the window after setting a logical position, but we don't have a window, use the last known scale factor.
2024-07-03 14:22:30 +02:00
Simon Hausmann
8c1ee12f84 Remove outdated comment
The new enum keeps the winit::window in an Rc (and we did before as well).
2024-07-03 14:22:30 +02:00
Simon Hausmann
a75b9fe643 Clean up WinitWindowAdapter construction
Call resume() on the renderer in one place, instead of several.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2024-07-03 14:22:30 +02:00
Simon Hausmann
49df131625 Fix slint::Window::hide() on Wayland with winit
On Wayland hiding a window requires destroying the surface, which
means destroying the winit window as well as the underlying graphics
surface. The latter is tricky as we have to keep the renderer around,
as our WindowAdapter trait's `renderer()` function returns a `&dyn
Renderer` and that also has to work without a window (to obtain text
metrics).

Fixes #4225

Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2024-07-03 14:22:30 +02:00
Simon Hausmann
862b1e1dfe winit software: remove unneccessary winit_window rc field
We can obtain that from the softbuffer surface.
2024-07-03 14:22:30 +02:00
Simon Hausmann
5afb9768c5
Fix crash on app shutdown on Wayland (#5534)
Valgrind would report invalid reads on the wayland clipboard shutdown code, suggesting that the wayland
display has already been destroyed.

Since the display handle isn't refcounted, we must make sure that the wayland clipboard is around as long as the wayland display handle, provided by the winit event loop.
2024-07-03 13:05:06 +02:00
Olivier Goffart
60569673b5 Remove some cargo:rustc-check-cfg output:
- The cfg_aliases crate does it out of the box already
 - Don't create a build.rs for this only purpose when it can be added in
   Cargo.toml lints group. (This wasn't possible when the warning was
   first introduced in nightly)
2024-07-02 13:33:48 +02:00
Olivier Goffart
1baf227e9e Update AccessKit 2024-07-02 11:45:46 +02:00
Tobias Hunger
dbde3c2f9e janitor: Remove unused variable warning in winit 2024-06-28 18:59:01 +02:00
Simon Hausmann
bf919d300d Work around sometimes missing resize event on macOS with winit
Fixes #5509
2024-06-28 15:26:36 +02:00
Olivier Goffart
f4085cfd13 winit: Fix setting the size with set_size before showing the window
Fixes #5489

We shouldn't resize the window to the size of the WindowItem after
start. This happens when set_size is called before show. The the
resize event didn't yet propagate the size to the WindowItem properties.
2024-06-27 16:12:35 +02:00
Arnold Loubriat
ce2db77e88
Add the accessible-placeholder-text property (#5464) 2024-06-26 12:59:22 +02:00
Tobias Hunger
87e4cb8951 janitor: Fix warning about unused import 2024-06-24 14:59:47 +02:00
Tobias Hunger
cd3b60c889 janitor: Fix clippy "creates a reference which is immediately dereferenced" 2024-06-24 14:59:47 +02:00
Simon Hausmann
83e7f8c6af Fix wasm build 2024-06-18 17:48:17 +02:00
Olivier Goffart
5d9682b2ad Remove PhantomData 2024-06-18 17:48:17 +02:00
Simon Hausmann
d7670d4feb Fix visibility warning with Rust 1.73 2024-06-18 17:48:17 +02:00
Simon Hausmann
9e94ec5fe4 winit: Use run_app_* instead of the deprecated functions
That requires implementing the ApplicationHandler trait and adds an extra dispatching impl to ensure the active event loop ref is set in TLS.

Also allow the deprecated create_window() for now.
2024-06-18 17:48:17 +02:00
Simon Hausmann
045ceec0a3 Fix two winit deprecation warnings 2024-06-18 17:48:17 +02:00
Simon Hausmann
7e7a3f72f0 Fix wasm build 2024-06-18 17:48:17 +02:00
Olivier Goffart
dc9f1d5bf1 WIP: upgrade accesskit and accesskit_winit 2024-06-18 17:48:17 +02:00
Simon Hausmann
4c888bf1ae Port the Skia renderer to rwh06 and the new softbuffer
... by accepting an Rc<dyn Has*Handle> in the interface. This is required for softbuffer use.
2024-06-18 17:48:17 +02:00
Simon Hausmann
40f2833bac Fix macOS build of glutin setup code used for FemtoVG renderer in winit backend 2024-06-18 17:48:17 +02:00
Olivier Goffart
865e3e940d WIP: update winit, glutin, raw-window-handle 2024-06-18 17:48:17 +02:00
Olivier Goffart
46623a658b winit backend: move the clipboard info outside of the event loop
It doesn't belong there and this will make further refactoring easier
2024-06-18 17:48:17 +02:00
Wannes Van Leemput
9f3eef8960 Allow one winit touch id at the time 2024-06-17 14:46:21 +02:00
Simon Hausmann
97df6b1be1 Mark AccessibleRole as non-exhaustive
That way we can add new variants in the future, while still exporting this in our public API.
2024-06-11 08:02:10 -07:00
Simon Hausmann
0e67654431 Fix jitter when resizing a window on macOS
Commit 1e450abc9c originally fixed this. Meanwhile, after many refactorings, this doesn't work anymore for the FemtoVG renderer. That's because the contents placement (or layer's contents gravity) is set before the hidden layer NSOpenGLContext creates is associated with the view.

For the Skia GL surface that already works, but for clarify the code is moved into the same location.

For Skia Metal rendering, apply the same on the metal layer (through the view). For this to work the contents scale also needs to be applied. To avoid further visual effects, the scale needs to be applied as early as possible, so apply it right after creating the
surface and latest at rendering time.

Fixes #5258
2024-06-06 08:34:58 -07:00
Olivier Goffart
ec0ddbc5b9 Add missing license header from previous commit 2024-06-06 11:18:15 +02:00
Luc Fauvel
44a537d902
Implemented resizing for non-decorated winit windows (#5026)
Fixes #5023

* Implemented resizing for non-decorated winit windows

* Fixed formatting

* Changed direction match to use a tuple, reduced resize border size, returned after handling resize

* Added is resizable check for before resizing winit window

* Added resize-border property to window

* Formatted code

* Change resize-border from float to length
2024-06-06 11:17:05 +02:00
Arnold Loubriat
8ece16321b Add DefaultActionVerb to AccessKit nodes 2024-06-06 00:01:29 -07:00
Tobias Hunger
d9224cd58f janitor: Use more workspace dependencies 2024-06-04 14:58:29 +02:00
Arnold Loubriat
2e5ebe2668 Address review comments 2024-06-03 01:38:06 -07:00
Arnold Loubriat
f97de46c6f Set accessible min/max values on progress indicator widgets 2024-06-03 01:38:06 -07:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Simon Hausmann
ed0030efe8 Pick the Skia renderer over FemtoVG
If Skia is available, pick that over FemtoVG. We end up recommending
Skia for most customers, so it should be enough to enable the feature
and not require additionally setting the `SLINT_BACKEND` environment
variable.

This change also means that the live-preview in the language server will
default to Skia on desktop installations. On the downside, this means
that Slintpad and the VS Code extension for the web will be using a
different renderer (FemtoVG).

Cherry picked from commit 90da6a9d7e,
as the parent commit of this change fixes the issue that required
reverting it.
2024-05-06 12:01:05 +02:00
Simon Hausmann
518681cc02 Fix live-preview not working with Skia backend
When the winit backend creates the Skia renderer, there is no associated surface to render into. Only the winit Resume event would cause a call to set_window_handle() and thus surface creation. This was done for the earlier Android backend, and is generally good practice.

When running for example slint-viewer with SLINT_BACKEND=winit-skia, we would create the skia renderer (no surface), then start the winit event loop, get a resume event, initialize the surface, and it all works.

With the live-preview inside the lsp, we'd create the event loop, get a resume event (but there's no window yet), and then we'd create the skia renderer without a surface... ever.

It's not ideal, but for now call resume() explicitly since we _do_ have a winit window, and we're not calling this on Android anymore.
2024-05-06 12:01:05 +02:00
Simon Hausmann
43e3c57b3b Prospective fix for rustdoc warnings about unknown cfg's
Let cargo know about our internal cfgs.
2024-05-06 12:00:44 +02:00