mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-26 22:53:15 -04:00
Add methods to get the position of a window's client area, relative to the desktop (#430)
* Add get_inner_position for windows, prototypes for other platforms * Fix linux builds * Implement get_inner_position for osx * Add get_inner_pos implementations for other platforms * Fixed get_inner_position on macOS * Corrected set_position on macOS * Added CHANGELOG entry
This commit is contained in:
committed by
Francesca Frangipane
parent
10688915eb
commit
8fd49a4dbe
@@ -162,6 +162,14 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_inner_position(&self) -> Option<(i32, i32)> {
|
||||
match self {
|
||||
&Window::X(ref m) => m.get_inner_position(),
|
||||
&Window::Wayland(ref m) => m.get_inner_position(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_position(&self, x: i32, y: i32) {
|
||||
match self {
|
||||
|
||||
@@ -113,6 +113,12 @@ impl Window {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_inner_position(&self) -> Option<(i32, i32)> {
|
||||
// Not possible with wayland
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_position(&self, _x: i32, _y: i32) {
|
||||
// Not possible with wayland
|
||||
|
||||
@@ -919,6 +919,11 @@ impl Window2 {
|
||||
self.get_geometry().map(|geo| geo.get_position())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_inner_position(&self) -> Option<(i32, i32)> {
|
||||
self.get_geometry().map(|geo| geo.get_inner_position())
|
||||
}
|
||||
|
||||
pub fn set_position(&self, mut x: i32, mut y: i32) {
|
||||
if let Some(ref wm_name) = self.wm_name {
|
||||
// There are a few WMs that set client area position rather than window position, so
|
||||
|
||||
Reference in New Issue
Block a user