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 #5667Fixes#5657
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.
* 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
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.
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>
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>
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.
- 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)
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.
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.
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
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
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.
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.