From 4bf2357204a61fa5109b53b5e72e76780d9c01da Mon Sep 17 00:00:00 2001 From: amrbashir Date: Wed, 30 Oct 2024 14:42:33 +0300 Subject: [PATCH] fix(linux): include border and titlebars in `Window::outer_position` closes tauri-apps/tauri#11510 --- .changes/outer-position-linux.md | 5 +++++ src/platform_impl/linux/window.rs | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changes/outer-position-linux.md diff --git a/.changes/outer-position-linux.md b/.changes/outer-position-linux.md new file mode 100644 index 000000000..732320200 --- /dev/null +++ b/.changes/outer-position-linux.md @@ -0,0 +1,5 @@ +--- +"tao": "patch" +--- + +On Linux, fix position returned in `Window::outer_position` to include border and titlebar. diff --git a/src/platform_impl/linux/window.rs b/src/platform_impl/linux/window.rs index aeba25e18..2ba0501e1 100644 --- a/src/platform_impl/linux/window.rs +++ b/src/platform_impl/linux/window.rs @@ -255,8 +255,12 @@ impl Window { let size: Rc<(AtomicI32, AtomicI32)> = Rc::new((w_size.0.into(), w_size.1.into())); let size_clone = size.clone(); - window.connect_configure_event(move |_, event| { - let (x, y) = event.position(); + window.connect_configure_event(move |window, event| { + let (x, y) = window + .window() + .map(|w| w.root_origin()) + .unwrap_or_else(|| event.position()); + position_clone.0.store(x, Ordering::Release); position_clone.1.store(y, Ordering::Release);