kms: Add kms backend module

This commit is contained in:
Victoria Brekenfeld 2022-01-20 19:51:46 +01:00
parent 2f53d25edd
commit ca32139131
5 changed files with 102 additions and 7 deletions

11
src/backend/kms/mod.rs Normal file
View file

@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::state::State;
use anyhow::Result;
use smithay::reexports::calloop::EventLoop;
pub struct KmsState {}
pub fn init_backend(event_loop: &mut EventLoop<State>, state: &mut State) -> Result<()> {
unimplemented!()
}

View file

@ -4,16 +4,17 @@ use crate::state::State;
use anyhow::Result;
use smithay::reexports::calloop::EventLoop;
pub mod kms;
pub mod winit;
pub mod x11;
// TODO
// pub mod wayland; // tbd in smithay
// pub mod udev;
pub fn init_backend_auto(event_loop: &mut EventLoop<State>, 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(_) => unimplemented!("There is no backend with this identifier"),
Err(_) => {
if std::env::var_os("DISPLAY").is_some()
@ -28,7 +29,7 @@ pub fn init_backend_auto(event_loop: &mut EventLoop<State>, state: &mut State) -
}
}
} else {
unimplemented!("Currently this runs only nested")
kms::init_backend(event_loop, state)
}
}
}

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::{
backend::{winit::WinitState, x11::X11State},
backend::{kms::KmsState, winit::WinitState, x11::X11State},
shell::{init_shell, workspaces::Workspaces, ShellStates},
};
use smithay::{
@ -60,13 +60,20 @@ pub struct Fps {
pub enum BackendData {
X11(X11State),
Winit(WinitState),
Kms(KmsState),
// TODO
// Wayland(WaylandState),
// Udev(UdevState),
Unset,
}
impl BackendData {
pub fn kms(&mut self) -> &mut KmsState {
match self {
BackendData::Kms(ref mut kms_state) => kms_state,
_ => unreachable!("Called kms in non kms backend"),
}
}
pub fn x11(&mut self) -> &mut X11State {
match self {
BackendData::X11(ref mut x11_state) => x11_state,