render/cursor: Correctly convert hotspot coordinates
This commit is contained in:
parent
244c174da4
commit
e6a3f5373c
1 changed files with 13 additions and 11 deletions
|
|
@ -20,7 +20,8 @@ use smithay::{
|
||||||
reexports::wayland_server::protocol::wl_surface,
|
reexports::wayland_server::protocol::wl_surface,
|
||||||
render_elements,
|
render_elements,
|
||||||
utils::{
|
utils::{
|
||||||
Buffer as BufferCoords, IsAlive, Logical, Monotonic, Point, Scale, Size, Time, Transform,
|
Buffer as BufferCoords, IsAlive, Logical, Monotonic, Physical, Point, Scale, Size, Time,
|
||||||
|
Transform,
|
||||||
},
|
},
|
||||||
wayland::compositor::{get_role, with_states},
|
wayland::compositor::{get_role, with_states},
|
||||||
};
|
};
|
||||||
|
|
@ -128,7 +129,7 @@ pub fn draw_surface_cursor<R>(
|
||||||
surface: &wl_surface::WlSurface,
|
surface: &wl_surface::WlSurface,
|
||||||
location: impl Into<Point<i32, Logical>>,
|
location: impl Into<Point<i32, Logical>>,
|
||||||
scale: impl Into<Scale<f64>>,
|
scale: impl Into<Scale<f64>>,
|
||||||
) -> Vec<(CursorRenderElement<R>, Point<i32, BufferCoords>)>
|
) -> Vec<(CursorRenderElement<R>, Point<i32, Physical>)>
|
||||||
where
|
where
|
||||||
R: Renderer + ImportAll,
|
R: Renderer + ImportAll,
|
||||||
R::TextureId: Clone + 'static,
|
R::TextureId: Clone + 'static,
|
||||||
|
|
@ -143,11 +144,7 @@ where
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.hotspot
|
.hotspot
|
||||||
.to_buffer(
|
.to_physical_precise_round(scale)
|
||||||
1,
|
|
||||||
Transform::Normal,
|
|
||||||
&Size::from((1, 1)), /* Size doesn't matter for Transform::Normal */
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
render_elements_from_surface_tree(
|
render_elements_from_surface_tree(
|
||||||
|
|
@ -259,7 +256,7 @@ pub fn draw_cursor<R>(
|
||||||
buffer_scale: f64,
|
buffer_scale: f64,
|
||||||
time: Time<Monotonic>,
|
time: Time<Monotonic>,
|
||||||
draw_default: bool,
|
draw_default: bool,
|
||||||
) -> Vec<(CursorRenderElement<R>, Point<i32, BufferCoords>)>
|
) -> Vec<(CursorRenderElement<R>, Point<i32, Physical>)>
|
||||||
where
|
where
|
||||||
R: Renderer + ImportMem + ImportAll,
|
R: Renderer + ImportMem + ImportAll,
|
||||||
R::TextureId: Send + Clone + 'static,
|
R::TextureId: Send + Clone + 'static,
|
||||||
|
|
@ -320,7 +317,12 @@ where
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let hotspot = Point::<i32, BufferCoords>::from((frame.xhot as i32, frame.yhot as i32));
|
let hotspot = Point::<i32, BufferCoords>::from((frame.xhot as i32, frame.yhot as i32))
|
||||||
|
.to_logical(
|
||||||
|
actual_scale as i32,
|
||||||
|
Transform::Normal,
|
||||||
|
&Size::from((frame.width as i32, frame.height as i32)),
|
||||||
|
);
|
||||||
state.current_image = Some(frame);
|
state.current_image = Some(frame);
|
||||||
|
|
||||||
return vec![(
|
return vec![(
|
||||||
|
|
@ -336,10 +338,10 @@ where
|
||||||
)
|
)
|
||||||
.expect("Failed to import cursor bitmap"),
|
.expect("Failed to import cursor bitmap"),
|
||||||
),
|
),
|
||||||
hotspot,
|
hotspot.to_physical_precise_round(scale),
|
||||||
)];
|
)];
|
||||||
} else if let CursorImageStatus::Surface(ref wl_surface) = cursor_status {
|
} else if let CursorImageStatus::Surface(ref wl_surface) = cursor_status {
|
||||||
return draw_surface_cursor(renderer, wl_surface, location.to_i32_round(), scale);
|
return draw_surface_cursor(renderer, wl_surface, location, scale);
|
||||||
} else {
|
} else {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue