Offset default pointer by hotspot

Fixes #252. Currently a temporary fix until I implement cursor shape
This commit is contained in:
Ottatop 2024-06-18 17:29:50 -05:00
parent fc4dd9d62e
commit 39fd958fae
6 changed files with 22 additions and 24 deletions

View file

@ -64,6 +64,9 @@ features = [
"x11rb_event_source", "x11rb_event_source",
] ]
[workspace.lints.clippy]
too_many_arguments = "allow"
########################################################################yo😎########### ########################################################################yo😎###########
[package] [package]
@ -140,3 +143,6 @@ testing = [
"smithay/renderer_test", "smithay/renderer_test",
] ]
wlcs = ["testing"] wlcs = ["testing"]
[lints]
workspace = true

View file

@ -65,8 +65,6 @@ impl window_service_server::WindowService for WindowService {
) -> Result<Response<()>, Status> { ) -> Result<Response<()>, Status> {
let request = request.into_inner(); let request = request.into_inner();
tracing::info!(request = ?request);
let window_id = WindowId( let window_id = WindowId(
request request
.window_id .window_id

View file

@ -51,7 +51,7 @@ use smithay::{
vulkan::{self, version::Version, PhysicalDevice}, vulkan::{self, version::Version, PhysicalDevice},
SwapBuffersError, SwapBuffersError,
}, },
desktop::utils::{send_frames_surface_tree, OutputPresentationFeedback}, desktop::utils::OutputPresentationFeedback,
input::pointer::CursorImageStatus, input::pointer::CursorImageStatus,
output::{Output, PhysicalProperties, Subpixel}, output::{Output, PhysicalProperties, Subpixel},
reexports::{ reexports::{
@ -1414,17 +1414,15 @@ impl Udev {
let _ = renderer.downscale_filter(self.downscale_filter); let _ = renderer.downscale_filter(self.downscale_filter);
let pointer_images = &mut self.pointer_images; let pointer_images = &mut self.pointer_images;
let pointer_image = pointer_images let (pointer_image, hotspot) = pointer_images
.iter() .iter()
.find_map( .find_map(|(image, texture)| {
|(image, texture)| {
if image == &frame { if image == &frame {
Some(texture.clone()) Some((texture.clone(), (frame.xhot as i32, frame.yhot as i32)))
} else { } else {
None None
} }
}, })
)
.unwrap_or_else(|| { .unwrap_or_else(|| {
let texture = TextureBuffer::from_memory( let texture = TextureBuffer::from_memory(
&mut renderer, &mut renderer,
@ -1437,8 +1435,9 @@ impl Udev {
None, None,
) )
.expect("Failed to import cursor bitmap"); .expect("Failed to import cursor bitmap");
let hotspot = (frame.xhot as i32, frame.yhot as i32);
pointer_images.push((frame, texture.clone())); pointer_images.push((frame, texture.clone()));
texture (texture, hotspot)
}); });
let pointer_location = pinnacle let pointer_location = pinnacle
@ -1455,14 +1454,6 @@ impl Udev {
if let CursorImageStatus::Surface(surface) = &pinnacle.cursor_status { if let CursorImageStatus::Surface(surface) = &pinnacle.cursor_status {
if !surface.alive() { if !surface.alive() {
pinnacle.cursor_status = CursorImageStatus::default_named(); pinnacle.cursor_status = CursorImageStatus::default_named();
} else {
send_frames_surface_tree(
surface,
output,
pinnacle.clock.now(),
Some(Duration::ZERO),
|_, _| None,
);
} }
} }
@ -1499,6 +1490,7 @@ impl Udev {
pointer_location, pointer_location,
&mut pinnacle.cursor_status, &mut pinnacle.cursor_status,
pinnacle.dnd_icon.as_ref(), pinnacle.dnd_icon.as_ref(),
hotspot.into(),
&self.pointer_element, &self.pointer_element,
); );
self.pointer_element.set_element_kind(element::Kind::Cursor); self.pointer_element.set_element_kind(element::Kind::Cursor);
@ -1513,6 +1505,7 @@ impl Udev {
pointer_location, pointer_location,
&mut pinnacle.cursor_status, &mut pinnacle.cursor_status,
pinnacle.dnd_icon.as_ref(), pinnacle.dnd_icon.as_ref(),
hotspot.into(),
&self.pointer_element, &self.pointer_element,
); );
output_render_elements.extend(pointer_render_elements); output_render_elements.extend(pointer_render_elements);

View file

@ -21,7 +21,6 @@ impl Udev {
} }
None => PendingGammaChange::Restore, None => PendingGammaChange::Restore,
}; };
tracing::info!("SET PENDING GAMMA WOO");
return Ok(()); return Ok(());
} }

View file

@ -304,6 +304,7 @@ impl Winit {
pointer_location, pointer_location,
&mut pinnacle.cursor_status, &mut pinnacle.cursor_status,
pinnacle.dnd_icon.as_ref(), pinnacle.dnd_icon.as_ref(),
(0, 0).into(), // Nonsurface cursors are hidden
&pointer_element, &pointer_element,
); );
output_render_elements.extend(pointer_render_elements); output_render_elements.extend(pointer_render_elements);

View file

@ -275,6 +275,7 @@ pub fn pointer_render_elements<R: PRenderer>(
pointer_location: Point<f64, Logical>, pointer_location: Point<f64, Logical>,
cursor_status: &mut CursorImageStatus, cursor_status: &mut CursorImageStatus,
dnd_icon: Option<&WlSurface>, dnd_icon: Option<&WlSurface>,
fallback_hotspot: Point<i32, Logical>,
pointer_element: &PointerElement<<R as Renderer>::TextureId>, pointer_element: &PointerElement<<R as Renderer>::TextureId>,
) -> Vec<OutputRenderElement<R>> { ) -> Vec<OutputRenderElement<R>> {
let mut output_render_elements = Vec::new(); let mut output_render_elements = Vec::new();
@ -296,7 +297,7 @@ pub fn pointer_render_elements<R: PRenderer>(
.hotspot .hotspot
}) })
} else { } else {
(0, 0).into() fallback_hotspot
}; };
let cursor_pos = pointer_location - output_geometry.loc.to_f64() - cursor_hotspot.to_f64(); let cursor_pos = pointer_location - output_geometry.loc.to_f64() - cursor_hotspot.to_f64();