backend: Adopt to new wayland-display handling
This commit is contained in:
parent
b126dfaf77
commit
270f06182e
7 changed files with 351 additions and 379 deletions
|
|
@ -1,8 +1,11 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use crate::state::State;
|
||||
use crate::state::{Data, State};
|
||||
use anyhow::Result;
|
||||
use smithay::reexports::calloop::EventLoop;
|
||||
use smithay::reexports::{
|
||||
calloop::EventLoop,
|
||||
wayland_server::DisplayHandle,
|
||||
};
|
||||
|
||||
pub mod render;
|
||||
|
||||
|
|
@ -13,28 +16,29 @@ pub mod x11;
|
|||
// pub mod wayland; // tbd in smithay
|
||||
|
||||
pub fn init_backend_auto(
|
||||
event_loop: &mut EventLoop<'static, State>,
|
||||
dh: &DisplayHandle,
|
||||
event_loop: &mut EventLoop<'static, Data>,
|
||||
state: &mut State,
|
||||
) -> Result<()> {
|
||||
match std::env::var("COSMIC_BACKEND") {
|
||||
Ok(x) if x == "x11" => x11::init_backend(event_loop, state),
|
||||
Ok(x) if x == "winit" => winit::init_backend(event_loop, state),
|
||||
Ok(x) if x == "kms" => kms::init_backend(event_loop, state),
|
||||
Ok(x) if x == "x11" => x11::init_backend(dh, event_loop, state),
|
||||
Ok(x) if x == "winit" => winit::init_backend(dh, event_loop, state),
|
||||
Ok(x) if x == "kms" => kms::init_backend(dh, event_loop, state),
|
||||
Ok(_) => unimplemented!("There is no backend with this identifier"),
|
||||
Err(_) => {
|
||||
if std::env::var_os("DISPLAY").is_some()
|
||||
|| std::env::var_os("WAYLAND_DISPLAY").is_some()
|
||||
{
|
||||
match x11::init_backend(event_loop, state) {
|
||||
match x11::init_backend(dh, event_loop, state) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => {
|
||||
slog_scope::warn!("X11 Backend failed with error: {}", err);
|
||||
slog_scope::info!("Falling back to winit backend.");
|
||||
winit::init_backend(event_loop, state)
|
||||
winit::init_backend(dh, event_loop, state)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
kms::init_backend(event_loop, state)
|
||||
kms::init_backend(dh, event_loop, state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue