diff --git a/js-bindings.d.ts b/js-bindings.d.ts index 64e2c89..79c75e0 100644 --- a/js-bindings.d.ts +++ b/js-bindings.d.ts @@ -49,6 +49,8 @@ export declare class BrowserWindow { setMinimizable(minimizable: boolean): void setResizable(resizable: boolean): void /** Sets the window inner size (width and height). */ + setSize(width: number, height: number, logical?: boolean | undefined |null): void + /** Sets the min window inner size (width and height). */ setMinSize(width: number, height: number, logical?: boolean | undefined | null): void /** Gets the window inner size. */ getInnerSize(logical?: boolean | undefined | null): Dimensions diff --git a/src/browser_window.rs b/src/browser_window.rs index e82b1eb..499ffc8 100644 --- a/src/browser_window.rs +++ b/src/browser_window.rs @@ -512,6 +512,20 @@ impl BrowserWindow { #[napi] /// Sets the window inner size (width and height). + pub fn set_size(&self, width: u32, height: u32, logical: Option) { + if let Some(logical) = logical { + if logical { + self.window.request_inner_size(LogicalSize::new(width as f64, height as f64)); + } else { + self.window.request_inner_size(PhysicalSize::new(width, height)); + } + } else { + self.window.request_inner_size(PhysicalSize::new(width, height)); + } + } + + #[napi] + /// Sets the min window inner size (width and height). pub fn set_min_size(&self, width: u32, height: u32, logical: Option) { if width == 0 && height == 0 { self.window.set_min_inner_size(None::);