Fix tablet cursor for screenshot-window with pointer
Browse files at this commit539a5a80302ace9bce520aaefc22dbf61ff63b98Parent: 53b74771 changed file +25 -14
- src/niri.rs +25 -14
src/niri.rsmodified+25 -14
| @@ -5684,7 +5684,30 @@ impl Niri { | |||
| 5684 | 5684 | ||
| 5685 | // Add pointer if requested and it's over this window. | 5685 | // Add pointer if requested and it's over this window. |
| 5686 | if show_pointer { | 5686 | if show_pointer { |
| 5687 | - if let Some((w, HitType::Input { win_pos })) = &self.pointer_contents.window { | 5687 | + let mut render = |win_pos: Point<f64, Logical>| { |
| 5688 | + // Pointer elements are at output-local physical coords. | ||
| 5689 | + // Relocate by -win_pos to make them window-relative. | ||
| 5690 | + let pos = win_pos.to_physical_precise_round(scale).upscale(-1); | ||
| 5691 | + self.render_pointer(renderer, output, &mut |elem| { | ||
| 5692 | + let elem = RelocateRenderElement::from_element(elem, pos, Relocate::Relative); | ||
| 5693 | + elements.push(elem.into()); | ||
| 5694 | + }); | ||
| 5695 | + }; | ||
| 5696 | + | ||
| 5697 | + // Tablet cursor. | ||
| 5698 | + if let Some(tablet_pos) = self.tablet_cursor_location { | ||
| 5699 | + let contents = self.contents_under(tablet_pos); | ||
| 5700 | + if let Some((w, HitType::Input { win_pos })) = contents.window { | ||
| 5701 | + if w == mapped.window { | ||
| 5702 | + // Tablet tools don't currently expose current focus, and don't currently | ||
| 5703 | + // have grabs. When those are implemented, this branch should be adjusted | ||
| 5704 | + // to look more similar to the branch below. | ||
| 5705 | + render(win_pos); | ||
| 5706 | + } | ||
| 5707 | + } | ||
| 5708 | + } | ||
| 5709 | + // Regular cursor. | ||
| 5710 | + else if let Some((w, HitType::Input { win_pos })) = &self.pointer_contents.window { | ||
| 5688 | if w == &mapped.window { | 5711 | if w == &mapped.window { |
| 5689 | // Grabs can modify the pointer focus, making it different from | 5712 | // Grabs can modify the pointer focus, making it different from |
| 5690 | // pointer_contents. Notably, gestures like Mod+MMB will remove the pointer | 5713 | // pointer_contents. Notably, gestures like Mod+MMB will remove the pointer |
| @@ -5709,25 +5732,13 @@ impl Niri { | |||
| 5709 | .map(|focused| self.find_root_shell_surface(&focused)) | 5732 | .map(|focused| self.find_root_shell_surface(&focused)) |
| 5710 | .is_some_and(|focused| mapped.is_wl_surface(&focused)); | 5733 | .is_some_and(|focused| mapped.is_wl_surface(&focused)); |
| 5711 | if current_focus_matches { | 5734 | if current_focus_matches { |
| 5712 | - // win_pos is the window buffer position in output-local logical coords. | ||
| 5713 | - let win_pos = win_pos.to_physical_precise_round(scale); | ||
| 5714 | - | ||
| 5715 | // We don't check for pointer visibility because it can only be Visible or | 5735 | // We don't check for pointer visibility because it can only be Visible or |
| 5716 | // Hidden, and never Disabled (then it wouldn't have focus). Even when the | 5736 | // Hidden, and never Disabled (then it wouldn't have focus). Even when the |
| 5717 | // pointer is Hidden, we want to render it, since the user explicitly | 5737 | // pointer is Hidden, we want to render it, since the user explicitly |
| 5718 | // requested show_pointer = true, and otherwise there's no easy way to | 5738 | // requested show_pointer = true, and otherwise there's no easy way to |
| 5719 | // screenshot a window with pointer with hide-when-typing because pressing | 5739 | // screenshot a window with pointer with hide-when-typing because pressing |
| 5720 | // the screenshot bind will hide the pointer. | 5740 | // the screenshot bind will hide the pointer. |
| 5721 | - self.render_pointer(renderer, output, &mut |elem| { | 5741 | + render(*win_pos); |
| 5722 | - // Pointer elements are at output-local physical coords. | ||
| 5723 | - // Relocate by -win_pos to make them window-relative. | ||
| 5724 | - let elem = RelocateRenderElement::from_element( | ||
| 5725 | - elem, | ||
| 5726 | - win_pos.upscale(-1), | ||
| 5727 | - Relocate::Relative, | ||
| 5728 | - ); | ||
| 5729 | - elements.push(elem.into()); | ||
| 5730 | - }); | ||
| 5731 | } | 5742 | } |
| 5732 | } | 5743 | } |
| 5733 | } | 5744 | } |