mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-25 09:59:21 +01:00
Remove state.pointer_location
This commit is contained in:
parent
d9116da20d
commit
2a25ab2319
5 changed files with 50 additions and 52 deletions
11
src/api.rs
11
src/api.rs
|
@ -1518,7 +1518,11 @@ impl window_service_server::WindowService for WindowService {
|
|||
.ok_or_else(|| Status::invalid_argument("no button specified"))?;
|
||||
|
||||
run_unary_no_response(&self.sender, move |state| {
|
||||
let Some((pointer_focus, _)) = state.pointer_focus_target_under(state.pointer_location)
|
||||
let Some(pointer_location) = state.seat.get_pointer().map(|ptr| ptr.current_location())
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Some((pointer_focus, _)) = state.pointer_focus_target_under(pointer_location)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
@ -1553,7 +1557,10 @@ impl window_service_server::WindowService for WindowService {
|
|||
.ok_or_else(|| Status::invalid_argument("no button specified"))?;
|
||||
|
||||
run_unary_no_response(&self.sender, move |state| {
|
||||
let pointer_loc = state.pointer_location;
|
||||
let Some(pointer_loc) = state.seat.get_pointer().map(|ptr| ptr.current_location())
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Some((pointer_focus, window_loc)) = state.pointer_focus_target_under(pointer_loc)
|
||||
else {
|
||||
return;
|
||||
|
|
|
@ -1237,6 +1237,12 @@ impl State {
|
|||
|
||||
let windows = self.space.elements().cloned().collect::<Vec<_>>();
|
||||
|
||||
let pointer_location = self
|
||||
.seat
|
||||
.get_pointer()
|
||||
.map(|ptr| ptr.current_location())
|
||||
.unwrap_or((0.0, 0.0).into());
|
||||
|
||||
let result = render_surface(
|
||||
surface,
|
||||
&mut renderer,
|
||||
|
@ -1247,7 +1253,7 @@ impl State {
|
|||
&mut self.cursor_status,
|
||||
&pointer_image,
|
||||
&mut udev.pointer_element,
|
||||
self.pointer_location,
|
||||
pointer_location,
|
||||
&self.clock,
|
||||
);
|
||||
|
||||
|
|
|
@ -265,12 +265,18 @@ impl State {
|
|||
// of every event loop cycle
|
||||
let windows = self.space.elements().cloned().collect::<Vec<_>>();
|
||||
|
||||
let pointer_location = self
|
||||
.seat
|
||||
.get_pointer()
|
||||
.map(|ptr| ptr.current_location())
|
||||
.unwrap_or((0.0, 0.0).into());
|
||||
|
||||
let output_render_elements = crate::render::generate_render_elements(
|
||||
output,
|
||||
winit.backend.renderer(),
|
||||
&self.space,
|
||||
&windows,
|
||||
self.pointer_location,
|
||||
pointer_location,
|
||||
&mut self.cursor_status,
|
||||
self.dnd_icon.as_ref(),
|
||||
// self.seat.input_method(),
|
||||
|
|
71
src/input.rs
71
src/input.rs
|
@ -494,37 +494,29 @@ impl State {
|
|||
nearest_point.map(|point| point.into()).unwrap_or(pos)
|
||||
}
|
||||
|
||||
/// Handle an absolute pointer motion event.
|
||||
///
|
||||
/// This *should* only be generated on the winit backend.
|
||||
/// Unless there's a case where it's generated on udev that I'm unaware of.
|
||||
fn pointer_motion_absolute<I: InputBackend>(&mut self, event: I::PointerMotionAbsoluteEvent) {
|
||||
let Some(pointer) = self.seat.get_pointer() else {
|
||||
tracing::error!("Pointer motion absolute received with no pointer on seat");
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(output) = self.space.outputs().next() else {
|
||||
return;
|
||||
};
|
||||
|
||||
let output_geo = self
|
||||
.space
|
||||
.output_geometry(output)
|
||||
.expect("Output geometry doesn't exist");
|
||||
let Some(output_geo) = self.space.output_geometry(output) else {
|
||||
unreachable!("output should have a geometry as it was mapped");
|
||||
};
|
||||
|
||||
let pointer_loc = event.position_transformed(output_geo.size) + output_geo.loc.to_f64();
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
let pointer = self.seat.get_pointer().expect("Seat has no pointer"); // FIXME: handle err
|
||||
|
||||
self.pointer_location = pointer_loc;
|
||||
|
||||
match self.output_focus_stack.current_focus() {
|
||||
Some(_) => {
|
||||
if let Some(output) = self
|
||||
.space
|
||||
.output_under(self.pointer_location)
|
||||
.next()
|
||||
.cloned()
|
||||
{
|
||||
self.output_focus_stack.set_focus(output);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if let Some(output) = self.space.outputs().next().cloned() {
|
||||
self.output_focus_stack.set_focus(output);
|
||||
}
|
||||
}
|
||||
if let Some(output) = self.space.output_under(pointer_loc).next().cloned() {
|
||||
self.output_focus_stack.set_focus(output);
|
||||
}
|
||||
|
||||
pointer.motion(
|
||||
|
@ -541,40 +533,29 @@ impl State {
|
|||
}
|
||||
|
||||
fn pointer_motion<I: InputBackend>(&mut self, event: I::PointerMotionEvent) {
|
||||
let serial = SERIAL_COUNTER.next_serial();
|
||||
self.pointer_location += event.delta();
|
||||
let Some(pointer) = self.seat.get_pointer() else {
|
||||
tracing::error!("Pointer motion received with no pointer on seat");
|
||||
return;
|
||||
};
|
||||
let mut pointer_loc = pointer.current_location();
|
||||
|
||||
// clamp to screen limits
|
||||
// this event is never generated by winit
|
||||
self.pointer_location = self.clamp_coords(self.pointer_location);
|
||||
pointer_loc = self.clamp_coords(pointer_loc);
|
||||
|
||||
match self.output_focus_stack.current_focus() {
|
||||
Some(_) => {
|
||||
if let Some(output) = self
|
||||
.space
|
||||
.output_under(self.pointer_location)
|
||||
.next()
|
||||
.cloned()
|
||||
{
|
||||
self.output_focus_stack.set_focus(output);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if let Some(output) = self.space.outputs().next().cloned() {
|
||||
self.output_focus_stack.set_focus(output);
|
||||
}
|
||||
}
|
||||
if let Some(output) = self.space.output_under(pointer_loc).next().cloned() {
|
||||
self.output_focus_stack.set_focus(output);
|
||||
}
|
||||
|
||||
let surface_under = self.pointer_focus_target_under(self.pointer_location);
|
||||
let surface_under = self.pointer_focus_target_under(pointer_loc);
|
||||
|
||||
if let Some(pointer) = self.seat.get_pointer() {
|
||||
pointer.motion(
|
||||
self,
|
||||
surface_under.clone(),
|
||||
&MotionEvent {
|
||||
location: self.pointer_location,
|
||||
serial,
|
||||
location: pointer_loc,
|
||||
serial: SERIAL_COUNTER.next_serial(),
|
||||
time: event.time_msec(),
|
||||
},
|
||||
);
|
||||
|
|
|
@ -17,7 +17,7 @@ use smithay::{
|
|||
Display, DisplayHandle,
|
||||
},
|
||||
},
|
||||
utils::{Clock, Logical, Monotonic, Point, Size},
|
||||
utils::{Clock, Monotonic, Point, Size},
|
||||
wayland::{
|
||||
compositor::{self, CompositorClientState, CompositorState},
|
||||
dmabuf::DmabufFeedback,
|
||||
|
@ -78,7 +78,6 @@ pub struct State {
|
|||
pub popup_manager: PopupManager,
|
||||
|
||||
pub cursor_status: CursorImageStatus,
|
||||
pub pointer_location: Point<f64, Logical>,
|
||||
pub dnd_icon: Option<WlSurface>,
|
||||
|
||||
/// The main window vec
|
||||
|
@ -236,7 +235,6 @@ impl State {
|
|||
compositor_state: CompositorState::new::<Self>(&display_handle),
|
||||
data_device_state: DataDeviceState::new::<Self>(&display_handle),
|
||||
seat_state,
|
||||
pointer_location: (0.0, 0.0).into(),
|
||||
shm_state: ShmState::new::<Self>(&display_handle, vec![]),
|
||||
space: Space::<WindowElement>::default(),
|
||||
cursor_status: CursorImageStatus::default_named(),
|
||||
|
|
Loading…
Reference in a new issue