Skip to content

Commit

Permalink
Clarify platform-specific details for Viewport positioning (#5715)
Browse files Browse the repository at this point in the history
On Wayland (and android apparently) it is not possible for applications
to position their windows or request the window position (for some
reason). This is not specified in the documentation.

proof: [`winit::set_outer_position`], [`winit::outer_position`],
[`winit::inner_position`] all specify that Android / Wayland are not
supported.

[`winit::set_outer_position`]:
https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_outer_position
[`winit::outer_position`]:
https://docs.rs/winit/latest/winit/window/struct.Window.html#method.outer_position
[`winit::inner_position`]:
https://docs.rs/winit/latest/winit/window/struct.Window.html#method.inner_position

* Maybe closes #4469
* the lack of support makes me sad. I believe this makes some items in
#3556 impossible on Wayland. Oh well!

---------

Co-authored-by: lucasmerlin <[email protected]>
  • Loading branch information
aspiringLich and lucasmerlin authored Feb 20, 2025
1 parent f5b058b commit 27e7303
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/egui/src/data/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,21 @@ pub struct ViewportInfo {
/// The inner rectangle of the native window, in monitor space and ui points scale.
///
/// This is the content rectangle of the viewport.
///
/// **`eframe` notes**:
///
/// On Android / Wayland, this will always be `None` since getting the
/// position of the window is not possible.
pub inner_rect: Option<Rect>,

/// The outer rectangle of the native window, in monitor space and ui points scale.
///
/// This is the content rectangle plus decoration chrome.
///
/// **`eframe` notes**:
///
/// On Android / Wayland, this will always be `None` since getting the
/// position of the window is not possible.
pub outer_rect: Option<Rect>,

/// Are we minimized?
Expand Down
9 changes: 9 additions & 0 deletions crates/egui/src/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,15 @@ impl ViewportBuilder {

/// The initial "outer" position of the window,
/// i.e. where the top-left corner of the frame/chrome should be.
///
/// **`eframe` notes**:
///
/// - **iOS:** Sets the top left coordinates of the window in the screen space coordinate system.
/// - **Web:** Sets the top-left coordinates relative to the viewport. Doesn't account for CSS
/// [`transform`].
/// - **Android / Wayland:** Unsupported.
///
/// [`transform`]: https://developer.mozilla.org/en-US/docs/Web/CSS/transform
#[inline]
pub fn with_position(mut self, pos: impl Into<Pos2>) -> Self {
self.position = Some(pos.into());
Expand Down

0 comments on commit 27e7303

Please sign in to comment.