Honor pointer visibility in screencasts
Browse files at this commitfd2916eb726b152ad8994d7d6e1c3c20217f8d31Parent: e9d888c1 changed file +40 -28
- src/niri.rs +40 -28
src/niri.rsmodified+40 -28
| @@ -2086,22 +2086,27 @@ impl State { | ||
| 2086 | 2086 | |
| 2087 | 2087 | let mut pointer_elements = Vec::new(); |
| 2088 | 2088 | let mut pointer_location = Point::default(); |
| 2089 | - if let Some((pointer_pos, win_pos)) = self.niri.pointer_pos_for_window_cast(mapped) | |
| 2090 | - { | |
| 2091 | - // Pointer location must be relative to the screencast buffer. | |
| 2092 | - // - win_pos is the position of the main window surface in output-local | |
| 2093 | - // coordinates | |
| 2094 | - // - bbox.loc moves us relative to the screencast buffer | |
| 2095 | - let buf_pos = win_pos + bbox.loc.to_f64().to_logical(scale); | |
| 2096 | - let output_pos = self.niri.global_space.output_geometry(output).unwrap().loc; | |
| 2097 | - pointer_location = pointer_pos - output_pos.to_f64() - buf_pos; | |
| 2098 | 2089 | |
| 2099 | - let pos = buf_pos.to_physical_precise_round(scale).upscale(-1); | |
| 2100 | - self.niri.render_pointer(renderer, output, &mut |elem| { | |
| 2101 | - let elem = | |
| 2102 | - RelocateRenderElement::from_element(elem, pos, Relocate::Relative); | |
| 2103 | - pointer_elements.push(CastRenderElement::from(elem)); | |
| 2104 | - }); | |
| 2090 | + if self.niri.pointer_visibility.is_visible() { | |
| 2091 | + if let Some((pointer_pos, win_pos)) = | |
| 2092 | + self.niri.pointer_pos_for_window_cast(mapped) | |
| 2093 | + { | |
| 2094 | + // Pointer location must be relative to the screencast buffer. | |
| 2095 | + // - win_pos is the position of the main window surface in output-local | |
| 2096 | + // coordinates | |
| 2097 | + // - bbox.loc moves us relative to the screencast buffer | |
| 2098 | + let buf_pos = win_pos + bbox.loc.to_f64().to_logical(scale); | |
| 2099 | + let output_pos = | |
| 2100 | + self.niri.global_space.output_geometry(output).unwrap().loc; | |
| 2101 | + pointer_location = pointer_pos - output_pos.to_f64() - buf_pos; | |
| 2102 | + | |
| 2103 | + let pos = buf_pos.to_physical_precise_round(scale).upscale(-1); | |
| 2104 | + self.niri.render_pointer(renderer, output, &mut |elem| { | |
| 2105 | + let elem = | |
| 2106 | + RelocateRenderElement::from_element(elem, pos, Relocate::Relative); | |
| 2107 | + pointer_elements.push(CastRenderElement::from(elem)); | |
| 2108 | + }); | |
| 2109 | + } | |
| 2105 | 2110 | } |
| 2106 | 2111 | let cursor_data = CursorData::compute(&pointer_elements, pointer_location, scale); |
| 2107 | 2112 | |
| @@ -5331,7 +5336,9 @@ impl Niri { | ||
| 5331 | 5336 | &mut |elem| elements.push(elem.into()), |
| 5332 | 5337 | ); |
| 5333 | 5338 | |
| 5334 | - self.render_pointer(renderer, output, &mut |elem| pointer.push(elem.into())); | |
| 5339 | + if self.pointer_visibility.is_visible() { | |
| 5340 | + self.render_pointer(renderer, output, &mut |elem| pointer.push(elem.into())); | |
| 5341 | + } | |
| 5335 | 5342 | |
| 5336 | 5343 | let output_pos = self.global_space.output_geometry(output).unwrap().loc; |
| 5337 | 5344 | let pointer_pos = self |
| @@ -5407,19 +5414,24 @@ impl Niri { | ||
| 5407 | 5414 | |
| 5408 | 5415 | let mut pointer_elements = Vec::new(); |
| 5409 | 5416 | let mut pointer_location = Point::default(); |
| 5410 | - if let Some((pointer_pos, win_pos)) = self.pointer_pos_for_window_cast(mapped) { | |
| 5411 | - // Pointer location must be relative to the screencast buffer. | |
| 5412 | - // - win_pos is the position of the main window surface in output-local coordinates | |
| 5413 | - // - bbox.loc moves us relative to the screencast buffer | |
| 5414 | - let buf_pos = win_pos + bbox.loc.to_f64().to_logical(scale); | |
| 5415 | - let output_pos = self.global_space.output_geometry(output).unwrap().loc; | |
| 5416 | - pointer_location = pointer_pos - output_pos.to_f64() - buf_pos; | |
| 5417 | 5417 | |
| 5418 | - let pos = buf_pos.to_physical_precise_round(scale).upscale(-1); | |
| 5419 | - self.render_pointer(renderer, output, &mut |elem| { | |
| 5420 | - let elem = RelocateRenderElement::from_element(elem, pos, Relocate::Relative); | |
| 5421 | - pointer_elements.push(CastRenderElement::from(elem)); | |
| 5422 | - }); | |
| 5418 | + if self.pointer_visibility.is_visible() { | |
| 5419 | + if let Some((pointer_pos, win_pos)) = self.pointer_pos_for_window_cast(mapped) { | |
| 5420 | + // Pointer location must be relative to the screencast buffer. | |
| 5421 | + // - win_pos is the position of the main window surface in output-local | |
| 5422 | + // coordinates | |
| 5423 | + // - bbox.loc moves us relative to the screencast buffer | |
| 5424 | + let buf_pos = win_pos + bbox.loc.to_f64().to_logical(scale); | |
| 5425 | + let output_pos = self.global_space.output_geometry(output).unwrap().loc; | |
| 5426 | + pointer_location = pointer_pos - output_pos.to_f64() - buf_pos; | |
| 5427 | + | |
| 5428 | + let pos = buf_pos.to_physical_precise_round(scale).upscale(-1); | |
| 5429 | + self.render_pointer(renderer, output, &mut |elem| { | |
| 5430 | + let elem = | |
| 5431 | + RelocateRenderElement::from_element(elem, pos, Relocate::Relative); | |
| 5432 | + pointer_elements.push(CastRenderElement::from(elem)); | |
| 5433 | + }); | |
| 5434 | + } | |
| 5423 | 5435 | } |
| 5424 | 5436 | let cursor_data = CursorData::compute(&pointer_elements, pointer_location, scale); |
| 5425 | 5437 |