deps: Update smithay

This commit is contained in:
Victoria Brekenfeld 2022-09-28 15:18:04 +02:00
parent 98f34e5279
commit 8e6537de39
7 changed files with 210 additions and 199 deletions

View file

@ -48,6 +48,7 @@ use smithay::{
use std::{
cell::RefCell,
collections::{HashMap, HashSet},
os::unix::io::{FromRawFd, OwnedFd},
path::PathBuf,
rc::Rc,
time::{Duration, Instant},
@ -308,21 +309,23 @@ impl State {
return Ok(());
}
let fd = SessionFd::new(
self.backend
.kms()
.session
.open(
&path,
OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_NOCTTY | OFlag::O_NONBLOCK,
)
.with_context(|| {
format!(
"Failed to optain file descriptor for drm device: {}",
path.display()
let fd = SessionFd::new(unsafe {
OwnedFd::from_raw_fd(
self.backend
.kms()
.session
.open(
&path,
OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_NOCTTY | OFlag::O_NONBLOCK,
)
})?,
);
.with_context(|| {
format!(
"Failed to optain file descriptor for drm device: {}",
path.display()
)
})?,
)
});
let mut drm = DrmDevice::new(fd.clone(), false, None)
.with_context(|| format!("Failed to initialize drm device for: {}", path.display()))?;
let drm_node = DrmNode::from_dev_id(dev)?;
@ -330,9 +333,11 @@ impl State {
let gbm = GbmDevice::new(fd)
.with_context(|| format!("Failed to initialize GBM device for {}", path.display()))?;
let egl_display = EGLDisplay::new(&gbm, None).with_context(|| {
format!("Failed to create EGLDisplay for device: {}", path.display())
})?;
let egl_display = unsafe {
EGLDisplay::new(&gbm, None).with_context(|| {
format!("Failed to create EGLDisplay for device: {}", path.display())
})?
};
let egl_device = EGLDevice::device_for_display(&egl_display).with_context(|| {
format!("Unable to find matching egl device for {}", path.display())
})?;

View file

@ -1,39 +1,38 @@
// SPDX-License-Identifier: GPL-3.0-only
use smithay::reexports::nix::unistd::close;
use std::{
fmt,
os::unix::io::{AsRawFd, RawFd},
os::unix::io::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd},
sync::Arc,
};
#[derive(Clone)]
pub struct SessionFd(Arc<DropFd>);
struct DropFd(RawFd);
pub struct SessionFd(Arc<OwnedFd>);
impl SessionFd {
pub fn new(fd: RawFd) -> SessionFd {
SessionFd(Arc::new(DropFd(fd)))
pub fn new(fd: OwnedFd) -> SessionFd {
SessionFd(Arc::new(fd))
}
}
impl fmt::Debug for SessionFd {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Session-provided File Descriptor [{}]", self.0 .0)
write!(
f,
"Session-provided File Descriptor [{}]",
self.0.as_raw_fd()
)
}
}
impl AsFd for SessionFd {
fn as_fd(&self) -> BorrowedFd<'_> {
self.0.as_fd()
}
}
impl AsRawFd for SessionFd {
fn as_raw_fd(&self) -> RawFd {
self.0 .0
}
}
impl Drop for DropFd {
fn drop(&mut self) {
if let Err(err) = close(self.0) {
slog_scope::warn!("Failed to close file descriptor {}: {}", self.0, err);
}
self.0.as_raw_fd()
}
}

View file

@ -242,7 +242,8 @@ pub fn init_backend(
let device =
unsafe { GbmDevice::new_from_fd(fd) }.with_context(|| "Failed to create GBM device")?;
// Initialize EGL using the GBM device.
let egl = EGLDisplay::new(&device, None).with_context(|| "Failed to create EGL display")?;
let egl =
unsafe { EGLDisplay::new(&device, None).with_context(|| "Failed to create EGL display")? };
// Create the OpenGL context
let context = EGLContext::new(&egl, None).with_context(|| "Failed to create EGL context")?;
// Create a renderer