-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move WindowIdExt to its own file; eliminate force-paint hack - better…
… fix available
- Loading branch information
1 parent
942442a
commit 8911084
Showing
3 changed files
with
56 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use super::window_tracking::{ | ||
monitor_bounds, window_inner_screen_bounds, window_inner_screen_position, | ||
window_outer_screen_bounds, window_outer_screen_position, | ||
}; | ||
use floem_winit::window::WindowId; | ||
use peniko::kurbo::{Point, Rect}; | ||
|
||
/// Ensures `WindowIdExt` cannot be implemented on arbitrary types. | ||
trait WindowIdExtSealed {} | ||
impl WindowIdExtSealed for WindowId {} | ||
|
||
/// Extends WindowId to give instances methods to retrieve properties of the associated window, | ||
/// much as ViewId does. Methods may return None if the view is not realized on-screen, or | ||
/// if information needed to compute the result is not available on the current platform or | ||
/// available on the current platform but not from the calling thread. | ||
#[allow(private_bounds)] | ||
pub trait WindowIdExt: WindowIdExtSealed { | ||
/// Get the bounds of the content of this window, including | ||
/// titlebar and native window borders. | ||
fn bounds_on_screen_including_frame(&self) -> Option<Rect>; | ||
/// Get the bounds of the content of this window, excluding | ||
/// titlebar and native window borders. | ||
fn bounds_of_content_on_screen(&self) -> Option<Rect>; | ||
/// Get the location of the window including any OS titlebar. | ||
fn position_on_screen_including_frame(&self) -> Option<Point>; | ||
/// Get the location of the window **excluding** any OS titlebar. | ||
fn position_of_content_on_screen(&self) -> Option<Point>; | ||
/// Get the logical bounds of the monitor this window is on | ||
fn monitor_bounds(&self) -> Option<Rect>; | ||
} | ||
|
||
impl WindowIdExt for WindowId { | ||
fn bounds_on_screen_including_frame(&self) -> Option<Rect> { | ||
window_outer_screen_bounds(self) | ||
} | ||
|
||
fn bounds_of_content_on_screen(&self) -> Option<Rect> { | ||
window_inner_screen_bounds(self) | ||
} | ||
|
||
fn position_on_screen_including_frame(&self) -> Option<Point> { | ||
window_outer_screen_position(self) | ||
} | ||
|
||
fn position_of_content_on_screen(&self) -> Option<Point> { | ||
window_inner_screen_position(self) | ||
} | ||
|
||
fn monitor_bounds(&self) -> Option<Rect> { | ||
monitor_bounds(self) | ||
} | ||
} |