aboutsummaryrefslogtreecommitdiff
path: root/src/layout.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-09-03 15:15:55 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-09-03 15:15:55 +0400
commit95cbe2a636e89b4ccd24baa8420e02a519658efd (patch)
tree983d1b93844d378c6678cd89e99421331a15f8e4 /src/layout.rs
parentcc1c9d93254df120fc1041e121cb3b5edd00ffc9 (diff)
downloadniri-95cbe2a636e89b4ccd24baa8420e02a519658efd.tar.gz
niri-95cbe2a636e89b4ccd24baa8420e02a519658efd.tar.bz2
niri-95cbe2a636e89b4ccd24baa8420e02a519658efd.zip
Send scanout feedbacks to surfaces
Diffstat (limited to 'src/layout.rs')
-rw-r--r--src/layout.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/layout.rs b/src/layout.rs
index 24a51b42..06608466 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -46,6 +46,7 @@ use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
use smithay::utils::{Logical, Point, Rectangle, Scale, Size};
use smithay::wayland::compositor::{with_states, SurfaceData};
+use smithay::wayland::dmabuf::DmabufFeedback;
use smithay::wayland::shell::xdg::SurfaceCachedState;
use crate::animation::Animation;
@@ -79,6 +80,14 @@ pub trait LayoutElement: SpaceElement + PartialEq + Clone {
) where
T: Into<Duration>,
F: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy;
+ fn send_dmabuf_feedback<'a, P, F>(
+ &self,
+ output: &Output,
+ primary_scan_out_output: P,
+ select_dmabuf_feedback: F,
+ ) where
+ P: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy,
+ F: Fn(&WlSurface, &SurfaceData) -> &'a DmabufFeedback + Copy;
}
#[derive(Debug)]
@@ -220,6 +229,18 @@ impl LayoutElement for Window {
{
self.send_frame(output, time, throttle, primary_scan_out_output);
}
+
+ fn send_dmabuf_feedback<'a, P, F>(
+ &self,
+ output: &Output,
+ primary_scan_out_output: P,
+ select_dmabuf_feedback: F,
+ ) where
+ P: FnMut(&WlSurface, &SurfaceData) -> Option<Output> + Copy,
+ F: Fn(&WlSurface, &SurfaceData) -> &'a DmabufFeedback + Copy,
+ {
+ self.send_dmabuf_feedback(output, primary_scan_out_output, select_dmabuf_feedback);
+ }
}
impl ColumnWidth {
@@ -464,6 +485,16 @@ impl<W: LayoutElement> MonitorSet<W> {
}
}
+ pub fn send_dmabuf_feedback(&self, output: &Output, feedback: &DmabufFeedback) {
+ if let MonitorSet::Normal { monitors, .. } = self {
+ for mon in monitors {
+ if &mon.output == output {
+ mon.workspaces[mon.active_workspace_idx].send_dmabuf_feedback(feedback);
+ }
+ }
+ }
+ }
+
pub fn find_window_and_output(&mut self, wl_surface: &WlSurface) -> Option<(W, Output)> {
if let MonitorSet::Normal { monitors, .. } = self {
for mon in monitors {
@@ -1506,6 +1537,13 @@ impl<W: LayoutElement> Workspace<W> {
}
}
+ fn send_dmabuf_feedback(&self, feedback: &DmabufFeedback) {
+ let output = self.output.as_ref().unwrap();
+ for win in self.windows() {
+ win.send_dmabuf_feedback(output, |_, _| Some(output.clone()), |_, _| feedback);
+ }
+ }
+
fn view_pos(&self) -> i32 {
self.column_x(self.active_column_idx) + self.view_offset - PADDING
}