Skip to content

Commit 968f943

Browse files
emoonclaude
andcommitted
wayland: fix mouse coordinate scaling for scaled windows
Fix get_mouse_pos to properly convert window coordinates to buffer coordinates using the scale factor. This resolves buffer bounds errors in examples like mouse.rs when using Scale::X2, where mouse coordinates were being reported as window coordinates instead of buffer coordinates. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent f3fa21a commit 968f943

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/os/posix/wayland.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,12 @@ impl Window {
852852
self.mouse_buttons[index]
853853
}
854854

855-
pub fn get_mouse_pos(&self, _mode: MouseMode) -> Option<(f32, f32)> {
856-
Some((self.mouse_x, self.mouse_y))
855+
pub fn get_mouse_pos(&self, mode: MouseMode) -> Option<(f32, f32)> {
856+
let s = self.scale_factor as f32;
857+
let w = self.width as f32;
858+
let h = self.height as f32;
859+
860+
mode.get_pos(self.mouse_x, self.mouse_y, s, w, h)
857861
}
858862

859863
pub fn get_scroll_wheel(&self) -> Option<(f32, f32)> {

0 commit comments

Comments
 (0)