Skip to content

Commit

Permalink
src: avoid unnecessary frames
Browse files Browse the repository at this point in the history
We only draw once, upon surface creation, so this seems work fine on my machine using Sway or Hyprland
  • Loading branch information
marcelohdez committed Mar 3, 2024
1 parent 3c2541c commit 1c48629
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/dim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,13 @@ impl DimView {
}
}

fn draw(&mut self, qh: &QueueHandle<DimData>) {
fn draw(&mut self, _qh: &QueueHandle<DimData>) {
debug!("Requesting draw");
if !self.first_configure {
// we only need to draw once as it is a static color
return;
}

self.layer
.wl_surface()
.damage_buffer(0, 0, self.width as i32, self.height as i32);
self.layer
.wl_surface()
.frame(qh, self.layer.wl_surface().clone());
self.layer.wl_surface().attach(Some(&self.buffer), 0, 0);
self.layer.commit();

Expand Down Expand Up @@ -240,13 +235,10 @@ impl CompositorHandler for DimData {
fn frame(
&mut self,
_conn: &smithay_client_toolkit::reexports::client::Connection,
qh: &QueueHandle<Self>,
_qh: &QueueHandle<Self>,
_surface: &smithay_client_toolkit::reexports::client::protocol::wl_surface::WlSurface,
_time: u32,
) {
for view in &mut self.views {
view.draw(qh);
}
}
}

Expand Down Expand Up @@ -440,7 +432,10 @@ impl PointerHandler for DimData {
for e in events {
match e.kind {
PointerEventKind::Enter { .. } | PointerEventKind::Leave { .. } => (),
_ => self.exit = true,
_ => {
debug!("Mouse event");
self.exit = true;
}
}
}
}
Expand Down

0 comments on commit 1c48629

Please sign in to comment.