This commit is contained in:
lif 2026-02-06 00:04:50 +08:00 committed by GitHub
commit 4605ce22a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,7 @@
---
'tauri': 'minor:feat'
'tauri-runtime': 'minor:feat'
'tauri-runtime-wry': 'minor:feat'
---
Add physical coordinate methods to WindowBuilder: `position_physical`, `inner_size_physical`, `min_inner_size_physical`, and `max_inner_size_physical` (fix #5228).

View File

@ -957,6 +957,11 @@ impl WindowBuilder for WindowBuilderWrapper {
self
}
fn position_physical(mut self, x: i32, y: i32) -> Self {
self.inner = self.inner.with_position(TaoPhysicalPosition::new(x, y));
self
}
fn inner_size(mut self, width: f64, height: f64) -> Self {
self.inner = self
.inner
@ -964,6 +969,13 @@ impl WindowBuilder for WindowBuilderWrapper {
self
}
fn inner_size_physical(mut self, width: u32, height: u32) -> Self {
self.inner = self
.inner
.with_inner_size(TaoPhysicalSize::new(width, height));
self
}
fn min_inner_size(mut self, min_width: f64, min_height: f64) -> Self {
self.inner = self
.inner
@ -971,6 +983,13 @@ impl WindowBuilder for WindowBuilderWrapper {
self
}
fn min_inner_size_physical(mut self, min_width: u32, min_height: u32) -> Self {
self.inner = self
.inner
.with_min_inner_size(TaoPhysicalSize::new(min_width, min_height));
self
}
fn max_inner_size(mut self, max_width: f64, max_height: f64) -> Self {
self.inner = self
.inner
@ -978,6 +997,13 @@ impl WindowBuilder for WindowBuilderWrapper {
self
}
fn max_inner_size_physical(mut self, max_width: u32, max_height: u32) -> Self {
self.inner = self
.inner
.with_max_inner_size(TaoPhysicalSize::new(max_width, max_height));
self
}
fn inner_size_constraints(mut self, constraints: WindowSizeConstraints) -> Self {
self.inner.window.inner_size_constraints = tao::window::WindowSizeConstraints {
min_width: constraints.min_width,

View File

@ -251,18 +251,34 @@ pub trait WindowBuilder: WindowBuilderBase {
#[must_use]
fn position(self, x: f64, y: f64) -> Self;
/// The initial position of the window in physical pixels.
#[must_use]
fn position_physical(self, x: i32, y: i32) -> Self;
/// Window size in logical pixels.
#[must_use]
fn inner_size(self, width: f64, height: f64) -> Self;
/// Window size in physical pixels.
#[must_use]
fn inner_size_physical(self, width: u32, height: u32) -> Self;
/// Window min inner size in logical pixels.
#[must_use]
fn min_inner_size(self, min_width: f64, min_height: f64) -> Self;
/// Window min inner size in physical pixels.
#[must_use]
fn min_inner_size_physical(self, min_width: u32, min_height: u32) -> Self;
/// Window max inner size in logical pixels.
#[must_use]
fn max_inner_size(self, max_width: f64, max_height: f64) -> Self;
/// Window max inner size in physical pixels.
#[must_use]
fn max_inner_size_physical(self, max_width: u32, max_height: u32) -> Self;
/// Window inner size constraints.
#[must_use]
fn inner_size_constraints(self, constraints: WindowSizeConstraints) -> Self;

View File

@ -450,6 +450,13 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
self
}
/// The initial position of the window in physical pixels.
#[must_use]
pub fn position_physical(mut self, x: i32, y: i32) -> Self {
self.window_builder = self.window_builder.position_physical(x, y);
self
}
/// Window size in logical pixels.
#[must_use]
pub fn inner_size(mut self, width: f64, height: f64) -> Self {
@ -457,6 +464,13 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
self
}
/// Window size in physical pixels.
#[must_use]
pub fn inner_size_physical(mut self, width: u32, height: u32) -> Self {
self.window_builder = self.window_builder.inner_size_physical(width, height);
self
}
/// Window min inner size in logical pixels.
#[must_use]
pub fn min_inner_size(mut self, min_width: f64, min_height: f64) -> Self {
@ -464,6 +478,13 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
self
}
/// Window min inner size in physical pixels.
#[must_use]
pub fn min_inner_size_physical(mut self, min_width: u32, min_height: u32) -> Self {
self.window_builder = self.window_builder.min_inner_size_physical(min_width, min_height);
self
}
/// Window max inner size in logical pixels.
#[must_use]
pub fn max_inner_size(mut self, max_width: f64, max_height: f64) -> Self {
@ -471,6 +492,13 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
self
}
/// Window max inner size in physical pixels.
#[must_use]
pub fn max_inner_size_physical(mut self, max_width: u32, max_height: u32) -> Self {
self.window_builder = self.window_builder.max_inner_size_physical(max_width, max_height);
self
}
/// Window inner size constraints.
#[must_use]
pub fn inner_size_constraints(