screencasting: Only render pointer when it's within output
Browse files at this commitd9e755d575a4ba8599bd9abdf4afd87f312c1ba9Parent: 87e2dd01 changed file +13 -7
- src/screencasting/mod.rs +13 -7
src/screencasting/mod.rsmodified+13 -7
| @@ -584,16 +584,22 @@ impl Niri { | |||
| 584 | &mut |elem| elements.push(elem.into()), | 584 | &mut |elem| elements.push(elem.into()), |
| 585 | ); | 585 | ); |
| 586 | 586 | ||
| 587 | + let mut pointer_pos = Point::default(); | ||
| 587 | if self.pointer_visibility.is_visible() { | 588 | if self.pointer_visibility.is_visible() { |
| 588 | - self.render_pointer(renderer, output, &mut |elem| pointer.push(elem.into())); | 589 | + let output_geo = self.global_space.output_geometry(output).unwrap().to_f64(); |
| 590 | + let pointer_loc = self | ||
| 591 | + .tablet_cursor_location | ||
| 592 | + .unwrap_or_else(|| self.seat.get_pointer().unwrap().current_location()); | ||
| 593 | + // Only render when the pointer is within the output. Otherwise, it will | ||
| 594 | + // happily appear anywhere outside the output video source in OBS. | ||
| 595 | + if output_geo.contains(pointer_loc) { | ||
| 596 | + pointer_pos = pointer_loc - output_geo.loc; | ||
| 597 | + self.render_pointer(renderer, output, &mut |elem| { | ||
| 598 | + pointer.push(elem.into()) | ||
| 599 | + }); | ||
| 600 | + } | ||
| 589 | } | 601 | } |
| 590 | 602 | ||
| 591 | - let output_pos = self.global_space.output_geometry(output).unwrap().loc; | ||
| 592 | - let pointer_pos = self | ||
| 593 | - .tablet_cursor_location | ||
| 594 | - .unwrap_or_else(|| self.seat.get_pointer().unwrap().current_location()); | ||
| 595 | - let pointer_pos = pointer_pos - output_pos.to_f64(); | ||
| 596 | - | ||
| 597 | cursor_data = Some(CursorData::compute(&pointer, pointer_pos, scale)); | 603 | cursor_data = Some(CursorData::compute(&pointer, pointer_pos, scale)); |
| 598 | } | 604 | } |
| 599 | let cursor_data = cursor_data.as_ref().unwrap(); | 605 | let cursor_data = cursor_data.as_ref().unwrap(); |