After creating the winit window we end up issuing a request_redraw() on
the window adapter after setting the component. This is before show().
With regular windowing systems the redraw event will be delivered when
the window is actually shown, but winit delivers it right away.
In our draw() implementation we don't do anything before show() is
called, as the size won't be correct.
Therefore content is never rendered.
To work around this behavior, we can use the redraw_requested state and
draw right away in show() on wasm.
After commit 7df902b53c, the winit window
is not created when calling show() anymore but it's now created at
component creation time. That means the event loop workaround removed
in 459f810bd8 is now needed at
construction time.
Since this is a winit and wasm specific issue, it's now dealt with in
the wasm interpreter implementation, by invoking the creation from the
event loop from there and returning a promise in the API.
This changes the API therefore: create() can only be called after the
event loop is running.
We would pass `physical_size_to_slint(&self.winit_window().inner_size())`, which is
identical to `slint::Window::size()`, which
calls `size()` on the WindowAdapter, which
returns the above.
show() used to create the window, which required access to the event
loop (target), which in turn required workarounds like in #1603. Since
the winit window exists now in show(), we don't need this workaround
anymore.
The same applies to hide(), we don't need an event loop target, all we
need is the event loop proxy to dispatch a WindowHidden event.
Add WindowEvent::ScaleFactorChanged and made set_scale_factor on
WindowInner private.
This achieves what #2486 tried to do, but using the clean platform
window event interface.
There's on guarantee that the pointers returned by get_proc_address are
always valid. Our implementation might, but since the trait isn't
sealed, somebody else could implement it badly.
Accept the OpenGL context as trait impl. This means we can also move the rendering notifier
into the femtovg renderer create and get rid of
the proxy Renderer trait impl.
Don't require passing a dyn WindowAdapter. This was only used for
calling request_redraw(), which a proper window adapter should do anyway
if has_active_animations() is true.
This is a regression from https://github.com/slint-ui/slint/pull/2708,
where previously we would have destroyed the winit window and that's how
it would have disappeared. Now we just need to call set_visible(false);
Now that we always create a window, we end up also creating an event
loop, and that's inherently incompatible with the rust test harness that
creates threads.
We can try to re-enable this later on platforms where we can run an
event loop in a thread. I have a local WIP patch for that.
Remove the generic window handle owner part of the API. Instead assume
that the caller provides safety for the given window handles, like we do
for FemtoVG and like softbuffer does it in its public API.
This simplifies the logic for how to apply window related requests as
they can be applied to the winit window immediately.
It also simplifies the state handling in the WinitWindowAdapter, as
there's no more distinction between mapped and unmapped. We always map
now (winit does).
One related change in core is that the window properties are now sent to
the backend before calling show(), instead of after.
Don't try to include the slint preview here, we don't need it. An
alternative would be to also add a docs symlink here, but this seems
more pragmatic for the time being.
The old version depends on an old version of xcb that crashes.
Even if cargo update should fix the problem, it won't happen automatically with old Cargo.lock
Fixes#2682
Despite the documentation of softbuffer claiming that the high bits
should be 0, it seems to be interpreted as an alpha value when the
window is actually transparent.
And the values are considered as premultiplied alpha
Also use a Premultiplied aplha for the buffer so we can even have
transparent window with the software renderer
Instead leave it out and return Default::default() in Rc::new_cyclic().
The map state handling gets quite ugly, because it needs to go into a OnceCell. On the upside, if we succeed with creating the winit window
in new() in the future, then that entire cell goes away.
The creation of the renderer might fail, for example if we tried to
create an OpenGL renderer on a display that doesn't support OpenGL. We
should catch that in the future and fall back to the software renderer.
We must tell winit that we want a transparent surface by default, to
avoid that winit sets an opaque region on the wayland surface.
In terms of the surface, we already prefer a GL config with a color
buffer that supports transparency.