deps: Update smithay

This commit is contained in:
Victoria Brekenfeld 2022-12-27 18:27:29 +01:00
parent f9d50e77a5
commit bce88d2514
9 changed files with 126 additions and 170 deletions

View file

@ -16,7 +16,9 @@ use anyhow::{Context, Result};
use smithay::{
backend::{
allocator::{dmabuf::Dmabuf, gbm::GbmDevice, Format},
drm::{DrmDevice, DrmEvent, DrmEventTime, DrmNode, GbmBufferedSurface, NodeType},
drm::{
DrmDevice, DrmDeviceFd, DrmEvent, DrmEventTime, DrmNode, GbmBufferedSurface, NodeType,
},
egl::{EGLContext, EGLDevice, EGLDisplay},
input::InputEvent,
libinput::{LibinputInputBackend, LibinputSessionInterface},
@ -45,7 +47,7 @@ use smithay::{
},
utils::{
signaling::{Linkable, SignalToken, Signaler},
Size, Transform,
DeviceFd, Size, Transform,
},
wayland::dmabuf::DmabufGlobal,
};
@ -53,16 +55,13 @@ use smithay::{
use std::{
cell::RefCell,
collections::{HashMap, HashSet},
os::unix::io::{FromRawFd, OwnedFd},
os::unix::io::FromRawFd,
path::PathBuf,
rc::Rc,
time::Duration,
};
mod drm_helpers;
mod session_fd;
mod socket;
use session_fd::*;
use socket::*;
use super::render::{CursorMode, GlMultiRenderer};
@ -82,8 +81,8 @@ pub struct KmsState {
pub struct Device {
render_node: DrmNode,
surfaces: HashMap<crtc::Handle, Surface>,
allocator: Rc<RefCell<GbmDevice<SessionFd>>>,
drm: Dispatcher<'static, DrmDevice<SessionFd>, Data>,
allocator: GbmDevice<DrmDeviceFd>,
drm: Dispatcher<'static, DrmDevice, Data>,
formats: HashSet<Format>,
supports_atomic: bool,
event_token: Option<RegistrationToken>,
@ -91,13 +90,7 @@ pub struct Device {
}
pub struct Surface {
surface: Option<
GbmBufferedSurface<
Rc<RefCell<GbmDevice<SessionFd>>>,
SessionFd,
Option<OutputPresentationFeedback>,
>,
>,
surface: Option<GbmBufferedSurface<GbmDevice<DrmDeviceFd>, Option<OutputPresentationFeedback>>>,
damage_tracker: DamageTrackedRenderer,
connector: connector::Handle,
output: Output,
@ -324,23 +317,26 @@ impl State {
return Ok(());
}
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 fd = DrmDeviceFd::new(
unsafe {
DeviceFd::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()
)
})?,
)
},
None,
);
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)?;
@ -348,11 +344,9 @@ impl State {
let gbm = GbmDevice::new(fd)
.with_context(|| format!("Failed to initialize GBM device for {}", path.display()))?;
let egl_display = unsafe {
EGLDisplay::new(&gbm, None).with_context(|| {
format!("Failed to create EGLDisplay for device: {}", path.display())
})?
};
let egl_display = EGLDisplay::new(gbm.clone(), 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())
})?;
@ -488,7 +482,7 @@ impl State {
let mut device = Device {
render_node,
surfaces: HashMap::new(),
allocator: Rc::new(RefCell::new(gbm)),
allocator: gbm,
drm: dispatcher,
formats,
supports_atomic,

View file

@ -1,38 +0,0 @@
// SPDX-License-Identifier: GPL-3.0-only
use std::{
fmt,
os::unix::io::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd},
sync::Arc,
};
#[derive(Clone)]
pub struct SessionFd(Arc<OwnedFd>);
impl SessionFd {
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.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.as_raw_fd()
}
}

View file

@ -6,7 +6,7 @@ use smithay::{
glow::{GlowFrame, GlowRenderer},
Frame, ImportAll, Renderer,
},
utils::{Physical, Point, Rectangle, Scale},
utils::{Buffer as BufferCoords, Physical, Point, Rectangle, Scale},
};
#[cfg(feature = "debug")]
@ -124,18 +124,18 @@ impl RenderElement<GlowRenderer> for CosmicElement<GlowRenderer> {
fn draw<'frame>(
&self,
frame: &mut <GlowRenderer as Renderer>::Frame<'frame>,
location: Point<i32, Physical>,
scale: Scale<f64>,
src: Rectangle<f64, BufferCoords>,
dst: Rectangle<i32, Physical>,
damage: &[Rectangle<i32, Physical>],
log: &slog::Logger,
) -> Result<(), <GlowRenderer as Renderer>::Error> {
match self {
CosmicElement::Workspace(elem) => elem.draw(frame, location, scale, damage, log),
CosmicElement::Cursor(elem) => elem.draw(frame, location, scale, damage, log),
CosmicElement::MoveGrab(elem) => elem.draw(frame, location, scale, damage, log),
CosmicElement::Workspace(elem) => elem.draw(frame, src, dst, damage, log),
CosmicElement::Cursor(elem) => elem.draw(frame, src, dst, damage, log),
CosmicElement::MoveGrab(elem) => elem.draw(frame, src, dst, damage, log),
#[cfg(feature = "debug")]
CosmicElement::Egui(elem) => {
RenderElement::<GlowRenderer>::draw(elem, frame, location, scale, damage, log)
RenderElement::<GlowRenderer>::draw(elem, frame, src, dst, damage, log)
}
}
}
@ -158,23 +158,21 @@ impl<'a> RenderElement<GlMultiRenderer<'a>> for CosmicElement<GlMultiRenderer<'a
fn draw<'frame>(
&self,
frame: &mut GlMultiFrame<'a, 'frame>,
location: Point<i32, Physical>,
scale: Scale<f64>,
src: Rectangle<f64, BufferCoords>,
dst: Rectangle<i32, Physical>,
damage: &[Rectangle<i32, Physical>],
log: &slog::Logger,
) -> Result<(), <GlMultiRenderer<'_> as Renderer>::Error> {
match self {
CosmicElement::Workspace(elem) => elem.draw(frame, location, scale, damage, log),
CosmicElement::Cursor(elem) => elem.draw(frame, location, scale, damage, log),
CosmicElement::MoveGrab(elem) => elem.draw(frame, location, scale, damage, log),
CosmicElement::Workspace(elem) => elem.draw(frame, src, dst, damage, log),
CosmicElement::Cursor(elem) => elem.draw(frame, src, dst, damage, log),
CosmicElement::MoveGrab(elem) => elem.draw(frame, src, dst, damage, log),
#[cfg(feature = "debug")]
CosmicElement::Egui(elem) => {
let elem = {
let glow_frame = frame.glow_frame_mut();
RenderElement::<GlowRenderer>::draw(
elem, glow_frame, location, scale, damage, log,
)
.map_err(|err| MultiError::Render(err))
RenderElement::<GlowRenderer>::draw(elem, glow_frame, src, dst, damage, log)
.map_err(|err| MultiError::Render(err))
};
elem
}

View file

@ -12,6 +12,7 @@ use anyhow::{Context, Result};
use smithay::{
backend::{
allocator::dmabuf::Dmabuf,
drm::DrmDeviceFd,
egl::{EGLContext, EGLDisplay},
input::{Event, InputEvent},
renderer::{
@ -24,22 +25,19 @@ use smithay::{
output::{Mode, Output, PhysicalProperties, Scale, Subpixel},
reexports::{
calloop::{ping, EventLoop, LoopHandle},
gbm::{Device as GbmDevice, FdWrapper},
gbm::Device as GbmDevice,
wayland_protocols::wp::presentation_time::server::wp_presentation_feedback,
wayland_server::DisplayHandle,
},
utils::Transform,
};
use std::{
cell::RefCell,
sync::{Arc, Mutex},
utils::{DeviceFd, Transform},
};
use std::cell::RefCell;
#[cfg(feature = "debug")]
use crate::state::Fps;
pub struct X11State {
allocator: Arc<Mutex<GbmDevice<FdWrapper>>>,
allocator: GbmDevice<DrmDeviceFd>,
_egl: EGLDisplay,
pub renderer: GlowRenderer,
surfaces: Vec<Surface>,
@ -267,11 +265,11 @@ pub fn init_backend(
.with_context(|| "Could not get DRM node used by X server")?;
// Create the gbm device for buffer allocation.
let device =
unsafe { GbmDevice::new_from_fd(fd) }.with_context(|| "Failed to create GBM device")?;
let device = GbmDevice::new(DrmDeviceFd::new(DeviceFd::from(fd), None))
.with_context(|| "Failed to create GBM device")?;
// Initialize EGL using the GBM device.
let egl =
unsafe { EGLDisplay::new(&device, None).with_context(|| "Failed to create EGL display")? };
EGLDisplay::new(device.clone(), 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
@ -282,7 +280,7 @@ pub fn init_backend(
state.backend = BackendData::X11(X11State {
handle,
allocator: Arc::new(Mutex::new(device)),
allocator: device,
_egl: egl,
renderer,
surfaces: Vec::new(),

View file

@ -25,7 +25,9 @@ use smithay::{
wayland_server::{backend::ObjectId, protocol::wl_surface::WlSurface},
},
space_elements,
utils::{IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial, Size},
utils::{
Buffer as BufferCoords, IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial, Size,
},
wayland::{
compositor::{with_states, with_surface_tree_downward, TraversalAction},
seat::WaylandFocus,
@ -850,18 +852,14 @@ impl RenderElement<GlowRenderer> for CosmicMappedRenderElement<GlowRenderer> {
fn draw<'frame>(
&self,
frame: &mut <GlowRenderer as Renderer>::Frame<'frame>,
location: Point<i32, Physical>,
scale: Scale<f64>,
src: Rectangle<f64, BufferCoords>,
dst: Rectangle<i32, Physical>,
damage: &[Rectangle<i32, Physical>],
log: &slog::Logger,
) -> Result<(), <GlowRenderer as Renderer>::Error> {
match self {
CosmicMappedRenderElement::Stack(elem) => {
elem.draw(frame, location, scale, damage, log)
}
CosmicMappedRenderElement::Window(elem) => {
elem.draw(frame, location, scale, damage, log)
}
CosmicMappedRenderElement::Stack(elem) => elem.draw(frame, src, dst, damage, log),
CosmicMappedRenderElement::Window(elem) => elem.draw(frame, src, dst, damage, log),
#[cfg(feature = "debug")]
CosmicMappedRenderElement::Egui(elem) => {
RenderElement::<GlowRenderer>::draw(elem, frame, location, scale, damage, log)
@ -886,18 +884,14 @@ impl<'a> RenderElement<GlMultiRenderer<'a>> for CosmicMappedRenderElement<GlMult
fn draw<'frame>(
&self,
frame: &mut GlMultiFrame<'a, 'frame>,
location: Point<i32, Physical>,
scale: Scale<f64>,
src: Rectangle<f64, BufferCoords>,
dst: Rectangle<i32, Physical>,
damage: &[Rectangle<i32, Physical>],
log: &slog::Logger,
) -> Result<(), <GlMultiRenderer<'_> as Renderer>::Error> {
match self {
CosmicMappedRenderElement::Stack(elem) => {
elem.draw(frame, location, scale, damage, log)
}
CosmicMappedRenderElement::Window(elem) => {
elem.draw(frame, location, scale, damage, log)
}
CosmicMappedRenderElement::Stack(elem) => elem.draw(frame, src, dst, damage, log),
CosmicMappedRenderElement::Window(elem) => elem.draw(frame, src, dst, damage, log),
#[cfg(feature = "debug")]
CosmicMappedRenderElement::Egui(elem) => {
let glow_frame = frame.glow_frame_mut();

View file

@ -28,7 +28,7 @@ use smithay::{
wayland_protocols::xdg::shell::server::xdg_toplevel::{self, ResizeEdge},
wayland_server::protocol::wl_surface::WlSurface,
},
utils::{IsAlive, Logical, Point, Rectangle, Scale, Serial},
utils::{Buffer as BufferCoords, IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial},
wayland::shell::wlr_layer::Layer,
};
use std::collections::HashMap;
@ -630,14 +630,14 @@ where
fn draw<'frame>(
&self,
frame: &mut <R as Renderer>::Frame<'frame>,
location: Point<i32, smithay::utils::Physical>,
scale: Scale<f64>,
src: Rectangle<f64, BufferCoords>,
dst: Rectangle<i32, Physical>,
damage: &[Rectangle<i32, smithay::utils::Physical>],
log: &slog::Logger,
) -> Result<(), <R as Renderer>::Error> {
match self {
WorkspaceRenderElement::Wayland(elem) => elem.draw(frame, location, scale, damage, log),
WorkspaceRenderElement::Window(elem) => elem.draw(frame, location, scale, damage, log),
WorkspaceRenderElement::Wayland(elem) => elem.draw(frame, src, dst, damage, log),
WorkspaceRenderElement::Window(elem) => elem.draw(frame, src, dst, damage, log),
}
}

View file

@ -351,7 +351,7 @@ impl Common {
states,
render_element_states,
default_primary_scanout_output_compare,
)
);
});
window.send_frame(output, time, throttle, surface_primary_scanout_output);
}
@ -380,7 +380,7 @@ impl Common {
states,
render_element_states,
default_primary_scanout_output_compare,
)
);
});
layer_surface.send_frame(output, time, throttle, surface_primary_scanout_output);
}