mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Move DmabufState to Niri
This commit is contained in:
+4
-14
@@ -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::presentation_time::server::wp_presentation_feedback;
|
||||
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::edid::EdidInfo;
|
||||
|
||||
@@ -70,7 +70,6 @@ struct OutputDevice {
|
||||
formats: HashSet<DrmFormat>,
|
||||
drm_scanner: DrmScanner,
|
||||
surfaces: HashMap<crtc::Handle, Surface>,
|
||||
dmabuf_state: DmabufState,
|
||||
dmabuf_global: DmabufGlobal,
|
||||
// SAFETY: drop after all the objects used with them are dropped.
|
||||
// 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 mut dmabuf_state = DmabufState::new();
|
||||
let default_feedback = DmabufFeedbackBuilder::new(device_id, gles.dmabuf_formats())
|
||||
.build()
|
||||
.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);
|
||||
|
||||
self.output_device = Some(OutputDevice {
|
||||
@@ -345,7 +344,6 @@ impl Tty {
|
||||
formats,
|
||||
drm_scanner: DrmScanner::new(),
|
||||
surfaces: HashMap::new(),
|
||||
dmabuf_state,
|
||||
dmabuf_global,
|
||||
});
|
||||
|
||||
@@ -401,8 +399,7 @@ impl Tty {
|
||||
}
|
||||
|
||||
let mut device = self.output_device.take().unwrap();
|
||||
device
|
||||
.dmabuf_state
|
||||
niri.dmabuf_state
|
||||
.destroy_global::<State>(&niri.display_handle, device.dmabuf_global);
|
||||
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>>> {
|
||||
self.connectors.clone()
|
||||
}
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ delegate_presentation!(State);
|
||||
|
||||
impl DmabufHandler for State {
|
||||
fn dmabuf_state(&mut self) -> &mut DmabufState {
|
||||
self.backend.tty().dmabuf_state()
|
||||
&mut self.niri.dmabuf_state
|
||||
}
|
||||
|
||||
fn dmabuf_imported(
|
||||
|
||||
+4
-1
@@ -58,7 +58,7 @@ use smithay::wayland::compositor::{
|
||||
CompositorState, SurfaceData, TraversalAction,
|
||||
};
|
||||
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::output::OutputManagerState;
|
||||
use smithay::wayland::pointer_constraints::{with_pointer_constraint, PointerConstraintsState};
|
||||
@@ -138,6 +138,7 @@ pub struct Niri {
|
||||
pub session_lock_state: SessionLockManagerState,
|
||||
pub shm_state: ShmState,
|
||||
pub output_manager_state: OutputManagerState,
|
||||
pub dmabuf_state: DmabufState,
|
||||
pub seat_state: SeatState<State>,
|
||||
pub tablet_state: TabletManagerState,
|
||||
pub text_input_state: TextInputManagerState,
|
||||
@@ -647,6 +648,7 @@ impl Niri {
|
||||
let shm_state = ShmState::new::<State>(&display_handle, vec![]);
|
||||
let output_manager_state =
|
||||
OutputManagerState::new_with_xdg_output::<State>(&display_handle);
|
||||
let dmabuf_state = DmabufState::new();
|
||||
let mut seat_state = SeatState::new();
|
||||
let tablet_state = TabletManagerState::new::<State>(&display_handle);
|
||||
let pointer_gestures_state = PointerGesturesState::new::<State>(&display_handle);
|
||||
@@ -760,6 +762,7 @@ impl Niri {
|
||||
virtual_keyboard_state,
|
||||
shm_state,
|
||||
output_manager_state,
|
||||
dmabuf_state,
|
||||
seat_state,
|
||||
tablet_state,
|
||||
pointer_gestures_state,
|
||||
|
||||
Reference in New Issue
Block a user