forge
Explore
Log in

Don't you dare go Hollow

Move DmabufState to Niri

Browse files at this commit

0dd9a42087fed36e999c569aea02fc1d4e1db856Ivan MolodetskikhParent: 658941f
src/backend/tty.rsmodified+4 -14
@@ -33,7 +33,7 @@ use smithay::reexports::rustix::fs::OFlags;
33 use smithay::reexports::wayland_protocols::wp::linux_dmabuf::zv1::server::zwp_linux_dmabuf_feedback_v1::TrancheFlags;33 use smithay::reexports::wayland_protocols::wp::linux_dmabuf::zv1::server::zwp_linux_dmabuf_feedback_v1::TrancheFlags;
34 use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;34 use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
35 use smithay::utils::DeviceFd;35 use smithay::utils::DeviceFd;
36-use smithay::wayland::dmabuf::{DmabufFeedbackBuilder, DmabufGlobal, DmabufState, DmabufFeedback};36+use smithay::wayland::dmabuf::{DmabufFeedbackBuilder, DmabufGlobal, DmabufFeedback};
37 use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};37 use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
38 use smithay_drm_extras::edid::EdidInfo;38 use smithay_drm_extras::edid::EdidInfo;
39 39
@@ -70,7 +70,6 @@ struct OutputDevice {
70 formats: HashSet<DrmFormat>,70 formats: HashSet<DrmFormat>,
71 drm_scanner: DrmScanner,71 drm_scanner: DrmScanner,
72 surfaces: HashMap<crtc::Handle, Surface>,72 surfaces: HashMap<crtc::Handle, Surface>,
73- dmabuf_state: DmabufState,
74 dmabuf_global: DmabufGlobal,73 dmabuf_global: DmabufGlobal,
75 // SAFETY: drop after all the objects used with them are dropped.74 // SAFETY: drop after all the objects used with them are dropped.
76 // See https://github.com/Smithay/smithay/issues/1102.75 // See https://github.com/Smithay/smithay/issues/1102.
@@ -329,11 +328,11 @@ impl Tty {
329 328
330 let formats = Bind::<Dmabuf>::supported_formats(&gles).unwrap_or_default();329 let formats = Bind::<Dmabuf>::supported_formats(&gles).unwrap_or_default();
331 330
332- let mut dmabuf_state = DmabufState::new();
333 let default_feedback = DmabufFeedbackBuilder::new(device_id, gles.dmabuf_formats())331 let default_feedback = DmabufFeedbackBuilder::new(device_id, gles.dmabuf_formats())
334 .build()332 .build()
335 .context("error building default dmabuf feedback")?;333 .context("error building default dmabuf feedback")?;
336- let dmabuf_global = dmabuf_state334+ let dmabuf_global = niri
335+ .dmabuf_state
337 .create_global_with_default_feedback::<State>(&niri.display_handle, &default_feedback);336 .create_global_with_default_feedback::<State>(&niri.display_handle, &default_feedback);
338 337
339 self.output_device = Some(OutputDevice {338 self.output_device = Some(OutputDevice {
@@ -345,7 +344,6 @@ impl Tty {
345 formats,344 formats,
346 drm_scanner: DrmScanner::new(),345 drm_scanner: DrmScanner::new(),
347 surfaces: HashMap::new(),346 surfaces: HashMap::new(),
348- dmabuf_state,
349 dmabuf_global,347 dmabuf_global,
350 });348 });
351 349
@@ -401,8 +399,7 @@ impl Tty {
401 }399 }
402 400
403 let mut device = self.output_device.take().unwrap();401 let mut device = self.output_device.take().unwrap();
404- device402+ niri.dmabuf_state
405- .dmabuf_state
406 .destroy_global::<State>(&niri.display_handle, device.dmabuf_global);403 .destroy_global::<State>(&niri.display_handle, device.dmabuf_global);
407 device.gles.unbind_wl_display();404 device.gles.unbind_wl_display();
408 405
@@ -952,13 +949,6 @@ impl Tty {
952 }949 }
953 }950 }
954 951
955- pub fn dmabuf_state(&mut self) -> &mut DmabufState {
956- let device = self.output_device.as_mut().expect(
957- "the dmabuf global must be created and destroyed together with the output device",
958- );
959- &mut device.dmabuf_state
960- }
961-
962 pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {952 pub fn connectors(&self) -> Arc<Mutex<HashMap<String, Output>>> {
963 self.connectors.clone()953 self.connectors.clone()
964 }954 }
src/handlers/mod.rsmodified+1 -1
@@ -193,7 +193,7 @@ delegate_presentation!(State);
193 193
194 impl DmabufHandler for State {194 impl DmabufHandler for State {
195 fn dmabuf_state(&mut self) -> &mut DmabufState {195 fn dmabuf_state(&mut self) -> &mut DmabufState {
196- self.backend.tty().dmabuf_state()196+ &mut self.niri.dmabuf_state
197 }197 }
198 198
199 fn dmabuf_imported(199 fn dmabuf_imported(
src/niri.rsmodified+4 -1
@@ -58,7 +58,7 @@ use smithay::wayland::compositor::{
58 CompositorState, SurfaceData, TraversalAction,58 CompositorState, SurfaceData, TraversalAction,
59 };59 };
60 use smithay::wayland::cursor_shape::CursorShapeManagerState;60 use smithay::wayland::cursor_shape::CursorShapeManagerState;
61-use smithay::wayland::dmabuf::DmabufFeedback;61+use smithay::wayland::dmabuf::{DmabufFeedback, DmabufState};
62 use smithay::wayland::input_method::InputMethodManagerState;62 use smithay::wayland::input_method::InputMethodManagerState;
63 use smithay::wayland::output::OutputManagerState;63 use smithay::wayland::output::OutputManagerState;
64 use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraintsState};64 use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraintsState};
@@ -138,6 +138,7 @@ pub struct Niri {
138 pub session_lock_state: SessionLockManagerState,138 pub session_lock_state: SessionLockManagerState,
139 pub shm_state: ShmState,139 pub shm_state: ShmState,
140 pub output_manager_state: OutputManagerState,140 pub output_manager_state: OutputManagerState,
141+ pub dmabuf_state: DmabufState,
141 pub seat_state: SeatState<State>,142 pub seat_state: SeatState<State>,
142 pub tablet_state: TabletManagerState,143 pub tablet_state: TabletManagerState,
143 pub text_input_state: TextInputManagerState,144 pub text_input_state: TextInputManagerState,
@@ -647,6 +648,7 @@ impl Niri {
647 let shm_state = ShmState::new::<State>(&display_handle, vec![]);648 let shm_state = ShmState::new::<State>(&display_handle, vec![]);
648 let output_manager_state =649 let output_manager_state =
649 OutputManagerState::new_with_xdg_output::<State>(&display_handle);650 OutputManagerState::new_with_xdg_output::<State>(&display_handle);
651+ let dmabuf_state = DmabufState::new();
650 let mut seat_state = SeatState::new();652 let mut seat_state = SeatState::new();
651 let tablet_state = TabletManagerState::new::<State>(&display_handle);653 let tablet_state = TabletManagerState::new::<State>(&display_handle);
652 let pointer_gestures_state = PointerGesturesState::new::<State>(&display_handle);654 let pointer_gestures_state = PointerGesturesState::new::<State>(&display_handle);
@@ -760,6 +762,7 @@ impl Niri {
760 virtual_keyboard_state,762 virtual_keyboard_state,
761 shm_state,763 shm_state,
762 output_manager_state,764 output_manager_state,
765+ dmabuf_state,
763 seat_state,766 seat_state,
764 tablet_state,767 tablet_state,
765 pointer_gestures_state,768 pointer_gestures_state,