From 1727869742f413fc87caf4829d77228910f96697 Mon Sep 17 00:00:00 2001
From: Lucas Nogueira <lucas@tauri.studio>
Date: Mon, 16 Oct 2023 08:59:29 -0300
Subject: [PATCH] fix(linux): crash on set size APIs

---
 .changes/fix-set-size-linux.md    |  5 +++++
 src/platform_impl/linux/window.rs | 16 ++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)
 create mode 100644 .changes/fix-set-size-linux.md

diff --git a/.changes/fix-set-size-linux.md b/.changes/fix-set-size-linux.md
new file mode 100644
index 000000000..29060722c
--- /dev/null
+++ b/.changes/fix-set-size-linux.md
@@ -0,0 +1,5 @@
+---
+"tao": patch:bug
+---
+
+Fixes set size APIs crashing on Linux.
diff --git a/src/platform_impl/linux/window.rs b/src/platform_impl/linux/window.rs
index e55d6038c..249d07c2f 100644
--- a/src/platform_impl/linux/window.rs
+++ b/src/platform_impl/linux/window.rs
@@ -385,11 +385,11 @@ impl Window {
     .to_physical(self.scale_factor.load(Ordering::Acquire) as f64)
   }
 
-  fn set_size_constraints(&self) {
-    if let Err(e) = self.window_requests_tx.send((
-      self.window_id,
-      WindowRequest::SizeConstraints(*self.inner_size_constraints.borrow()),
-    )) {
+  fn set_size_constraints(&self, constraints: WindowSizeConstraints) {
+    if let Err(e) = self
+      .window_requests_tx
+      .send((self.window_id, WindowRequest::SizeConstraints(constraints)))
+    {
       log::warn!("Fail to send size constraint request: {}", e);
     }
   }
@@ -398,19 +398,19 @@ impl Window {
     let mut size_constraints = self.inner_size_constraints.borrow_mut();
     size_constraints.min_width = size.map(|s| s.width());
     size_constraints.min_height = size.map(|s| s.height());
-    self.set_size_constraints()
+    self.set_size_constraints(*size_constraints)
   }
 
   pub fn set_max_inner_size(&self, size: Option<Size>) {
     let mut size_constraints = self.inner_size_constraints.borrow_mut();
     size_constraints.max_width = size.map(|s| s.width());
     size_constraints.max_height = size.map(|s| s.height());
-    self.set_size_constraints()
+    self.set_size_constraints(*size_constraints)
   }
 
   pub fn set_inner_size_constraints(&self, constraints: WindowSizeConstraints) {
     *self.inner_size_constraints.borrow_mut() = constraints;
-    self.set_size_constraints()
+    self.set_size_constraints(constraints)
   }
 
   pub fn set_title(&self, title: &str) {