Fix Compositor concurrent initialization

It seems that initializing the compositor in a
different thread can cause issues in some environments.
This commit is contained in:
Héctor Ramón Jiménez 2025-04-02 20:33:22 +02:00
parent d203392c9d
commit 1b22d7d5fc
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
8 changed files with 37 additions and 14 deletions

View file

@ -10,7 +10,7 @@ use thiserror::Error;
use std::borrow::Cow;
/// A graphics compositor that can draw to windows.
pub trait Compositor: Sized + MaybeSend {
pub trait Compositor: Sized {
/// The iced renderer of the backend.
type Renderer;
@ -21,7 +21,7 @@ pub trait Compositor: Sized + MaybeSend {
fn new<W: Window + Clone>(
settings: Settings,
compatible_window: W,
) -> impl Future<Output = Result<Self, Error>> + MaybeSend {
) -> impl Future<Output = Result<Self, Error>> {
Self::with_backend(settings, compatible_window, None)
}
@ -33,7 +33,7 @@ pub trait Compositor: Sized + MaybeSend {
_settings: Settings,
_compatible_window: W,
_backend: Option<&str>,
) -> impl Future<Output = Result<Self, Error>> + MaybeSend;
) -> impl Future<Output = Result<Self, Error>>;
/// Creates a [`Self::Renderer`] for the [`Compositor`].
fn create_renderer(&self) -> Self::Renderer;