aboutsummaryrefslogtreecommitdiff
path: root/src/winit.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-08-16 10:59:34 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-08-16 10:59:34 +0400
commit6e36ccb1bd4ca6a5e4374e1fa50e519599d7a060 (patch)
tree59a772a946a7b50593075e73f2edccf7ebf4d8d0 /src/winit.rs
parentd4d2cefe50b13222a2eb45f59d4b80f8b8d4f634 (diff)
downloadniri-6e36ccb1bd4ca6a5e4374e1fa50e519599d7a060.tar.gz
niri-6e36ccb1bd4ca6a5e4374e1fa50e519599d7a060.tar.bz2
niri-6e36ccb1bd4ca6a5e4374e1fa50e519599d7a060.zip
Implement wp-presentation
Diffstat (limited to 'src/winit.rs')
-rw-r--r--src/winit.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/winit.rs b/src/winit.rs
index 69b92670..c8b29203 100644
--- a/src/winit.rs
+++ b/src/winit.rs
@@ -6,6 +6,7 @@ use smithay::backend::winit::{self, WinitError, WinitEvent, WinitEventLoop, Wini
use smithay::output::{Mode, Output, PhysicalProperties, Subpixel};
use smithay::reexports::calloop::timer::{TimeoutAction, Timer};
use smithay::reexports::calloop::LoopHandle;
+use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
use smithay::reexports::winit::dpi::LogicalSize;
use smithay::reexports::winit::window::WindowBuilder;
use smithay::utils::Transform;
@@ -13,6 +14,7 @@ use smithay::utils::Transform;
use crate::backend::Backend;
use crate::input::CompositorMod;
use crate::niri::OutputRenderElements;
+use crate::utils::get_monotonic_time;
use crate::{LoopData, Niri};
pub struct Winit {
@@ -33,20 +35,30 @@ impl Backend for Winit {
fn render(
&mut self,
- _niri: &mut Niri,
- _output: &Output,
+ niri: &mut Niri,
+ output: &Output,
elements: &[OutputRenderElements<GlesRenderer>],
) {
let _span = tracy_client::span!("Winit::render");
self.backend.bind().unwrap();
let age = self.backend.buffer_age().unwrap();
- let result = self
+ let res = self
.damage_tracker
.render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0])
.unwrap();
- if let Some(damage) = result.damage {
+ if let Some(damage) = res.damage {
self.backend.submit(Some(&damage)).unwrap();
+
+ let mut presentation_feedbacks = niri.take_presentation_feedbacks(output, &res.states);
+ let refresh = output.current_mode().unwrap().refresh as u32;
+ presentation_feedbacks.presented::<_, smithay::utils::Monotonic>(
+ get_monotonic_time(),
+ refresh,
+ 0,
+ wp_presentation_feedback::Kind::empty(),
+ );
+
self.backend.window().request_redraw();
}
}