1
0
Fork 0
forked from wry/wry

autocommit 2022-04-14 16:06:11 CEST

This commit is contained in:
Julian Orth 2022-04-14 16:06:11 +02:00
parent de199a740b
commit 35ddfbcbe3
14 changed files with 203 additions and 35 deletions

View file

@ -8,11 +8,7 @@ use {
pub struct DummyBackend {}
impl Backend for DummyBackend {
fn switch_to(&self, vtnr: u32) {
let _ = vtnr;
}
}
impl Backend for DummyBackend {}
pub struct DummyOutput {
pub id: ConnectorId,

View file

@ -4,7 +4,7 @@ mod video;
use {
crate::{
async_engine::{AsyncError, AsyncFd},
async_engine::{AsyncError, AsyncFd, Phase},
backend::{
Backend, InputDevice, InputDeviceAccelProfile, InputDeviceCapability, InputDeviceId,
InputEvent, KeyState,
@ -25,6 +25,7 @@ use {
logind::{LogindError, Session},
render::RenderError,
state::State,
tasks::idle,
udev::{Udev, UdevError, UdevMonitor},
utils::{
clonecell::{CloneCell, UnsafeCellCloneSafe},
@ -34,7 +35,10 @@ use {
smallmap::SmallMap,
syncqueue::SyncQueue,
},
video::{drm::DrmError, gbm::GbmError},
video::{
drm::{DrmError, DRM_MODE_ATOMIC_ALLOW_MODESET},
gbm::GbmError,
},
},
std::{
cell::{Cell, RefCell},
@ -128,6 +132,34 @@ impl Backend for MetalBackend {
}
})
}
fn set_idle(&self, idle: bool) {
let devices = self.device_holder.drm_devices.lock();
for device in devices.values() {
let mut change = device.dev.master.change();
for connector in device.connectors.values() {
if let Some(crtc) = connector.crtc.get() {
if idle == crtc.active.value.get() {
crtc.active.value.set(!idle);
change.change_object(crtc.id, |c| {
c.change(crtc.active.id, (!idle) as _);
});
}
}
}
if let Err(e) = change.commit(DRM_MODE_ATOMIC_ALLOW_MODESET, 0) {
log::error!("Could not set monitors idle/not idle: {}", ErrorFmt(e));
return;
}
}
if !idle {
for device in devices.values() {
for connector in device.connectors.values() {
self.present(connector);
}
}
}
}
}
async fn run_(state: Rc<State>) -> Result<(), MetalError> {
@ -193,6 +225,9 @@ async fn run_(state: Rc<State>) -> Result<(), MetalError> {
return Err(MetalError::Enumerate(Box::new(e)));
}
state.backend.set(Some(metal.clone()));
let _idle = state
.eng
.spawn2(Phase::PostLayout, idle(state.clone(), metal.clone()));
pending().await
}

View file

@ -1002,7 +1002,14 @@ impl MetalBackend {
self.present(connector);
}
fn present(&self, connector: &Rc<MetalConnector>) {
pub fn present(&self, connector: &Rc<MetalConnector>) {
let crtc = match connector.crtc.get() {
Some(crtc) => crtc,
_ => return,
};
if !crtc.active.value.get() {
return;
}
let buffers = match connector.buffers.get() {
None => return,
Some(b) => b,

View file

@ -113,11 +113,7 @@ pub struct XBackend {
_grab: SpawnedFuture<()>,
}
impl Backend for XBackend {
fn switch_to(&self, _vtnr: u32) {
log::error!("X backend cannot switch vts");
}
}
impl Backend for XBackend {}
struct XBackendData {
state: Rc<State>,