drm: do not ignore events for inactive devices

This commit is contained in:
Victor Brekenfeld 2020-05-03 17:23:12 +02:00
parent 49215f6a3d
commit 1a5cc59983
2 changed files with 26 additions and 38 deletions

View File

@ -389,29 +389,21 @@ impl<A: AsRawFd + 'static> Device for AtomicDrmDevice<A> {
for event in events { for event in events {
if let Event::PageFlip(event) = event { if let Event::PageFlip(event) = event {
trace!(self.logger, "Got a page-flip event for crtc ({:?})", event.crtc); trace!(self.logger, "Got a page-flip event for crtc ({:?})", event.crtc);
if self.active.load(Ordering::SeqCst) { if self
if self .backends
.backends .borrow()
.borrow() .get(&event.crtc)
.get(&event.crtc) .iter()
.iter() .flat_map(|x| x.upgrade())
.flat_map(|x| x.upgrade()) .next()
.next() .is_some()
.is_some() {
{ trace!(self.logger, "Handling event for backend {:?}", event.crtc);
trace!(self.logger, "Handling event for backend {:?}", event.crtc); if let Some(handler) = self.handler.as_ref() {
if let Some(handler) = self.handler.as_ref() { handler.borrow_mut().vblank(event.crtc);
handler.borrow_mut().vblank(event.crtc);
}
} else {
self.backends.borrow_mut().remove(&event.crtc);
} }
} else { } else {
debug!( self.backends.borrow_mut().remove(&event.crtc);
self.logger,
"Device ({:?}) not active. Ignoring PageFlip",
self.dev_path()
);
} }
} else { } else {
trace!( trace!(

View File

@ -306,25 +306,21 @@ impl<A: AsRawFd + 'static> Device for LegacyDrmDevice<A> {
Ok(events) => { Ok(events) => {
for event in events { for event in events {
if let Event::PageFlip(event) = event { if let Event::PageFlip(event) = event {
if self.active.load(Ordering::SeqCst) { if self
if self .backends
.backends .borrow()
.borrow() .get(&event.crtc)
.get(&event.crtc) .iter()
.iter() .flat_map(|x| x.upgrade())
.flat_map(|x| x.upgrade()) .next()
.next() .is_some()
.is_some() {
{ trace!(self.logger, "Handling event for backend {:?}", event.crtc);
trace!(self.logger, "Handling event for backend {:?}", event.crtc); if let Some(handler) = self.handler.as_ref() {
if let Some(handler) = self.handler.as_ref() { handler.borrow_mut().vblank(event.crtc);
handler.borrow_mut().vblank(event.crtc);
}
} else {
self.backends.borrow_mut().remove(&event.crtc);
} }
} else { } else {
debug!(self.logger, "Device not active. Ignoring PageFlip"); self.backends.borrow_mut().remove(&event.crtc);
} }
} else { } else {
trace!(self.logger, "Unrelated event"); trace!(self.logger, "Unrelated event");