Skip to content

Commit

Permalink
Merge pull request #108 from mahkoh/jorth/fix-zwlr-screencopy
Browse files Browse the repository at this point in the history
render: fix wlr-screencopy with scaled outputs
  • Loading branch information
mahkoh authored Feb 24, 2024
2 parents b078329 + 5f14f56 commit 69d63b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/ifs/zwlr_screencopy_frame_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ impl ZwlrScreencopyFrameV1 {
}

pub fn send_damage(&self) {
let pos = self.output.pos.get();
self.client.event(Damage {
self_id: self.id,
x: 0,
y: 0,
width: self.rect.width() as _,
height: self.rect.height() as _,
width: pos.width() as _,
height: pos.height() as _,
});
}

Expand Down
9 changes: 8 additions & 1 deletion src/ifs/zwlr_screencopy_manager_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ impl ZwlrScreencopyManagerV1 {
region: Option<Rect>,
) -> Result<(), ZwlrScreencopyManagerV1Error> {
let output = self.client.lookup(output)?;
let mut rect = output.global.position().at_point(0, 0);
let mode = output.global.mode.get();
let mut rect = Rect::new_sized(0, 0, mode.width, mode.height).unwrap();
if let Some(region) = region {
let scale = output.global.preferred_scale.get().to_f64();
let x1 = (region.x1() as f64 * scale).round() as i32;
let y1 = (region.y1() as f64 * scale).round() as i32;
let x2 = (region.x2() as f64 * scale).round() as i32;
let y2 = (region.y2() as f64 * scale).round() as i32;
let region = Rect::new(x1, y1, x2, y2).unwrap();
rect = rect.intersect(region);
}
let frame = Rc::new(ZwlrScreencopyFrameV1 {
Expand Down

0 comments on commit 69d63b7

Please sign in to comment.