Skip to content

Add setMinSize() and setMaxSize() methods#39

Closed
zhuxiaojt wants to merge 2 commits into
webviewjs:mainfrom
zhuxiaojt:main
Closed

Add setMinSize() and setMaxSize() methods#39
zhuxiaojt wants to merge 2 commits into
webviewjs:mainfrom
zhuxiaojt:main

Conversation

@zhuxiaojt

Copy link
Copy Markdown
Contributor

@twlite

Adds setMinSize and setMaxSize APIs to control window size constraints, aligned with the logical parameter pattern from #38. Pass (0, 0) to clear the constraint.

@twlite

twlite commented Jun 19, 2026

Copy link
Copy Markdown
Member

@zhuxiaojt could you fix the merge conflict?

@Lawtro37 Lawtro37 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change

dpi::{LogicalPosition, LogicalSize, PhysicalSize, Size},

to

dpi::{LogicalPosition, PhysicalPosition, LogicalSize, PhysicalSize, Size},

that should fix the merge conflict.

@zhuxiaojt

Copy link
Copy Markdown
Contributor Author

I noticed that these features have already been implemented in commit cf8cc47. Should I close this PR, or is there any further work needed on my side?

Commit diff snippet for cf8cc47:

+  /// Set minimum inner size.  Pass `null` / `undefined` for both to remove the
+  /// constraint.
+  #[napi]
+  pub fn set_min_size(&self, width: Option<f64>, height: Option<f64>) {
+    let size: Option<winit::dpi::Size> = match (width, height) {
+      (Some(w), Some(h)) => Some(LogicalSize::new(w, h).into()),
+      _ => None,
+    };
+    self.window.set_min_inner_size(size);
+  }
+
+  /// Set maximum inner size.  Pass `null` / `undefined` for both to remove the
+  /// constraint.
+  #[napi]
+  pub fn set_max_size(&self, width: Option<f64>, height: Option<f64>) {
+    let size: Option<winit::dpi::Size> = match (width, height) {
+      (Some(w), Some(h)) => Some(LogicalSize::new(w, h).into()),
+      _ => None,
+    };
+    self.window.set_max_inner_size(size);
+  }

@twlite

twlite commented Jun 20, 2026

Copy link
Copy Markdown
Member

I think this can be closed

@twlite twlite closed this Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants