diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-10 09:58:26 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-10 14:50:51 +0400 |
| commit | 9b073b2350d00dfdb32a4983a102c4bde843c92c (patch) | |
| tree | 4144883e824f80f4ffa1aa1509128a6371ffab4e /src/tty.rs | |
| parent | ed6132645a4cb5eefafe39333bc7d8d8abd2acf6 (diff) | |
| download | niri-9b073b2350d00dfdb32a4983a102c4bde843c92c.tar.gz niri-9b073b2350d00dfdb32a4983a102c4bde843c92c.tar.bz2 niri-9b073b2350d00dfdb32a4983a102c4bde843c92c.zip | |
Redraw on demand rather than continuously
Diffstat (limited to 'src/tty.rs')
| -rw-r--r-- | src/tty.rs | 28 |
1 files changed, 6 insertions, 22 deletions
@@ -1,6 +1,5 @@ use std::os::fd::FromRawFd; use std::path::PathBuf; -use std::time::Duration; use anyhow::anyhow; use smithay::backend::allocator::dmabuf::Dmabuf; @@ -17,7 +16,6 @@ use smithay::backend::session::libseat::LibSeatSession; use smithay::backend::session::{Event as SessionEvent, Session}; use smithay::backend::udev::{self, UdevBackend, UdevEvent}; use smithay::output::{Mode, Output, OutputModeSource, PhysicalProperties, Subpixel}; -use smithay::reexports::calloop::timer::{TimeoutAction, Timer}; use smithay::reexports::calloop::{LoopHandle, RegistrationToken}; use smithay::reexports::drm::control::connector::{ Interface as ConnectorInterface, State as ConnectorState, @@ -83,7 +81,7 @@ impl Backend for Tty { assert!(!res.needs_sync()); if res.damage.is_some() { match output_device.drm_compositor.queue_frame(()) { - Ok(()) => return, + Ok(()) => niri.waiting_for_vblank = true, Err(err) => { error!("error queueing frame: {err}"); } @@ -95,17 +93,6 @@ impl Backend for Tty { error!("error rendering frame: {err}"); } } - - // FIXME: render on demand instead of busy looping. - niri.event_loop - .insert_source( - Timer::from_duration(Duration::from_millis(6)), - |_, _, data| { - data.niri.redraw(data.tty.as_mut().unwrap()); - TimeoutAction::Drop - }, - ) - .unwrap(); } } @@ -157,7 +144,7 @@ impl Tty { output_device.drm_compositor.reset_buffers(); } - niri.redraw(tty); + niri.queue_redraw(); } } }) @@ -190,7 +177,7 @@ impl Tty { if let Err(err) = tty.device_added(device_id, path, niri) { warn!("error adding device: {err:?}"); } - niri.redraw(tty); + niri.queue_redraw(); } UdevEvent::Changed { device_id } => tty.device_changed(device_id, niri), UdevEvent::Removed { device_id } => tty.device_removed(device_id, niri), @@ -198,7 +185,7 @@ impl Tty { }) .unwrap(); - niri.redraw(self); + niri.queue_redraw(); } fn device_added( @@ -250,11 +237,8 @@ impl Tty { // .windows // .mark_presented(&output_device.last_render_states, metadata); - // Request redraw before the next VBlank. - // let frame_interval = catacomb.windows.output().frame_interval(); - // let duration = frame_interval - RENDER_TIME_OFFSET; - // catacomb.backend.schedule_redraw(duration); - data.niri.redraw(tty); + data.niri.waiting_for_vblank = false; + data.niri.queue_redraw(); } DrmEvent::Error(error) => error!("DRM error: {error}"), }; |
