On Wayland, fix coordinates in touch events when scale factor isn't 1 (#1439)
* On Wayland, fix coordinates in touch events when scale factor isn't 1 * Explicitly state that Wayland is using LogicalPosition internally * Fix CHANGELOG
This commit is contained in:
parent
28f0eb598d
commit
4eddd1e5bc
3 changed files with 46 additions and 18 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::dpi::LogicalPosition;
|
||||
use crate::event::{
|
||||
DeviceEvent, ElementState, ModifiersState, MouseButton, MouseScrollDelta, TouchPhase,
|
||||
WindowEvent,
|
||||
|
|
@ -76,13 +77,16 @@ pub fn implement_pointer(
|
|||
},
|
||||
wid,
|
||||
);
|
||||
|
||||
let position = LogicalPosition::new(surface_x, surface_y)
|
||||
.to_physical(scale_factor);
|
||||
|
||||
sink.send_window_event(
|
||||
WindowEvent::CursorMoved {
|
||||
device_id: crate::event::DeviceId(
|
||||
crate::platform_impl::DeviceId::Wayland(DeviceId),
|
||||
),
|
||||
position: (surface_x * scale_factor, surface_y * scale_factor)
|
||||
.into(),
|
||||
position,
|
||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||
},
|
||||
wid,
|
||||
|
|
@ -109,15 +113,18 @@ pub fn implement_pointer(
|
|||
..
|
||||
} => {
|
||||
if let Some(surface) = mouse_focus.as_ref() {
|
||||
let scale_factor = surface::get_dpi_factor(&surface) as f64;
|
||||
let wid = make_wid(surface);
|
||||
|
||||
let scale_factor = surface::get_dpi_factor(&surface) as f64;
|
||||
let position = LogicalPosition::new(surface_x, surface_y)
|
||||
.to_physical(scale_factor);
|
||||
|
||||
sink.send_window_event(
|
||||
WindowEvent::CursorMoved {
|
||||
device_id: crate::event::DeviceId(
|
||||
crate::platform_impl::DeviceId::Wayland(DeviceId),
|
||||
),
|
||||
position: (surface_x * scale_factor, surface_y * scale_factor)
|
||||
.into(),
|
||||
position,
|
||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||
},
|
||||
wid,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue