diff --git a/CHANGELOG.md b/CHANGELOG.md index 415f989b..c91dd90b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ Unreleased` header. - On macOS, add services menu. - On macOS, remove spurious error logging when handling `Fn`. +- On X11, fix an issue where floating point data from the server is + misinterpreted during a drag and drop operation. # 0.29.4 diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index 26c9fe30..3e6cdc3f 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -1128,3 +1128,9 @@ impl Device { } } } + +/// Convert the raw X11 representation for a 32-bit floating point to a double. +#[inline] +fn xinput_fp1616_to_float(fp: xinput::Fp1616) -> f64 { + (fp as f64) / ((1 << 16) as f64) +} diff --git a/src/platform_impl/linux/x11/window.rs b/src/platform_impl/linux/x11/window.rs index b2e45bd9..5bcd38d7 100644 --- a/src/platform_impl/linux/x11/window.rs +++ b/src/platform_impl/linux/x11/window.rs @@ -25,7 +25,10 @@ use crate::{ event::{Event, InnerSizeWriter, WindowEvent}, event_loop::AsyncRequestSerial, platform_impl::{ - x11::{atoms::*, MonitorHandle as X11MonitorHandle, WakeSender, X11Error}, + x11::{ + atoms::*, xinput_fp1616_to_float, MonitorHandle as X11MonitorHandle, WakeSender, + X11Error, + }, Fullscreen, MonitorHandle as PlatformMonitorHandle, OsError, PlatformIcon, PlatformSpecificWindowBuilderAttributes, VideoMode as PlatformVideoMode, }, @@ -1739,8 +1742,8 @@ impl UnownedWindow { | xproto::EventMask::SUBSTRUCTURE_NOTIFY, ), [ - (window.x as u32 + pointer.win_x as u32), - (window.y as u32 + pointer.win_y as u32), + (window.x as u32 + xinput_fp1616_to_float(pointer.win_x) as u32), + (window.y as u32 + xinput_fp1616_to_float(pointer.win_y) as u32), action.try_into().unwrap(), 1, // Button 1 1,