Move DmabufState to Niri

This commit is contained in:
Ivan Molodetskikh
2023-12-31 12:02:39 +04:00
parent 658941f2c3
commit 0dd9a42087
3 changed files with 9 additions and 16 deletions
+4 -14
View File
@@ -33,7 +33,7 @@ use smithay::reexports::rustix::fs::OFlags;
use smithay::reexports::wayland_protocols::wp::linux_dmabuf::zv1::server::zwp_linux_dmabuf_feedback_v1::TrancheFlags; use smithay::reexports::wayland_protocols::wp::linux_dmabuf::zv1::server::zwp_linux_dmabuf_feedback_v1::TrancheFlags;
use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback; use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
use smithay::utils::DeviceFd; use smithay::utils::DeviceFd;
use smithay::wayland::dmabuf::{DmabufFeedbackBuilder, DmabufGlobal, DmabufState, DmabufFeedback}; use smithay::wayland::dmabuf::{DmabufFeedbackBuilder, DmabufGlobal, DmabufFeedback};
use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner}; use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
use smithay_drm_extras::edid::EdidInfo; use smithay_drm_extras::edid::EdidInfo;
@@ -70,7 +70,6 @@ struct OutputDevice {
formats: HashSet<DrmFormat>, formats: HashSet<DrmFormat>,
drm_scanner: DrmScanner, drm_scanner: DrmScanner,
surfaces: HashMap<crtc::Handle, Surface>, surfaces: HashMap<crtc::Handle, Surface>,
dmabuf_state: DmabufState,
dmabuf_global: DmabufGlobal, dmabuf_global: DmabufGlobal,
// SAFETY: drop after all the objects used with them are dropped. // SAFETY: drop after all the objects used with them are dropped.
// See https://github.com/Smithay/smithay/issues/1102. // See https://github.com/Smithay/smithay/issues/1102.
@@ -329,11 +328,11 @@ impl Tty {
let formats = Bind::<Dmabuf>::supported_formats(&gles).unwrap_or_default(); let formats = Bind::<Dmabuf>::supported_formats(&gles).unwrap_or_default();
let mut dmabuf_state = DmabufState::new();
let default_feedback = DmabufFeedbackBuilder::new(device_id, gles.dmabuf_formats()) let default_feedback = DmabufFeedbackBuilder::new(device_id, gles.dmabuf_formats())
.build() .build()
.context("error building default dmabuf feedback")?; .context("error building default dmabuf feedback")?;
let dmabuf_global = dmabuf_state let dmabuf_global = niri
.dmabuf_state
.create_global_with_default_feedback::<State>(&niri.display_handle, &default_feedback); .create_global_with_default_feedback::<State>(&niri.display_handle, &default_feedback);
self.output_device = Some(OutputDevice { self.output_device = Some(OutputDevice {
@@ -345,7 +344,6 @@ impl Tty {
formats, formats,
drm_scanner: DrmScanner::new(), drm_scanner: DrmScanner::new(),
surfaces: HashMap::new(), surfaces: HashMap::new(),
dmabuf_state,
dmabuf_global, dmabuf_global,
}); });
@@ -401,8 +399,7 @@ impl Tty {
} }
let mut device = self.output_device.take().unwrap(); let mut device = self.output_device.take().unwrap();
device niri.dmabuf_state
.dmabuf_state
.destroy_global::<State>(&niri.display_handle, device.dmabuf_global); .destroy_global::<State>(&niri.display_handle, device.dmabuf_global);
device.gles.unbind_wl_display(); device.gles.unbind_wl_display();
@@ -952,13 +949,6 @@ impl Tty {
} }
} }
pub fn dmabuf_state(&mut self) -> &mut DmabufState {
let device = self.output_device.as_mut().expect(
"the dmabuf global must be created and destroyed together with the output device",
);
&mut device.dmabuf_state
}
pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> { pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {
self.connectors.clone() self.connectors.clone()
} }
+1 -1
View File
@@ -193,7 +193,7 @@ delegate_presentation!(State);
impl DmabufHandler for State { impl DmabufHandler for State {
fn dmabuf_state(&mut self) -> &mut DmabufState { fn dmabuf_state(&mut self) -> &mut DmabufState {
self.backend.tty().dmabuf_state() &mut self.niri.dmabuf_state
} }
fn dmabuf_imported( fn dmabuf_imported(
+4 -1
View File
@@ -58,7 +58,7 @@ use smithay::wayland::compositor::{
CompositorState, SurfaceData, TraversalAction, CompositorState, SurfaceData, TraversalAction,
}; };
use smithay::wayland::cursor_shape::CursorShapeManagerState; use smithay::wayland::cursor_shape::CursorShapeManagerState;
use smithay::wayland::dmabuf::DmabufFeedback; use smithay::wayland::dmabuf::{DmabufFeedback, DmabufState};
use smithay::wayland::input_method::InputMethodManagerState; use smithay::wayland::input_method::InputMethodManagerState;
use smithay::wayland::output::OutputManagerState; use smithay::wayland::output::OutputManagerState;
use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraintsState}; use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraintsState};
@@ -138,6 +138,7 @@ pub struct Niri {
pub session_lock_state: SessionLockManagerState, pub session_lock_state: SessionLockManagerState,
pub shm_state: ShmState, pub shm_state: ShmState,
pub output_manager_state: OutputManagerState, pub output_manager_state: OutputManagerState,
pub dmabuf_state: DmabufState,
pub seat_state: SeatState<State>, pub seat_state: SeatState<State>,
pub tablet_state: TabletManagerState, pub tablet_state: TabletManagerState,
pub text_input_state: TextInputManagerState, pub text_input_state: TextInputManagerState,
@@ -647,6 +648,7 @@ impl Niri {
let shm_state = ShmState::new::<State>(&display_handle, vec![]); let shm_state = ShmState::new::<State>(&display_handle, vec![]);
let output_manager_state = let output_manager_state =
OutputManagerState::new_with_xdg_output::<State>(&display_handle); OutputManagerState::new_with_xdg_output::<State>(&display_handle);
let dmabuf_state = DmabufState::new();
let mut seat_state = SeatState::new(); let mut seat_state = SeatState::new();
let tablet_state = TabletManagerState::new::<State>(&display_handle); let tablet_state = TabletManagerState::new::<State>(&display_handle);
let pointer_gestures_state = PointerGesturesState::new::<State>(&display_handle); let pointer_gestures_state = PointerGesturesState::new::<State>(&display_handle);
@@ -760,6 +762,7 @@ impl Niri {
virtual_keyboard_state, virtual_keyboard_state,
shm_state, shm_state,
output_manager_state, output_manager_state,
dmabuf_state,
seat_state, seat_state,
tablet_state, tablet_state,
pointer_gestures_state, pointer_gestures_state,