Skip to content

Commit be76cd1

Browse files
authored
Check if saved window size is at least the minimum allowed (#993)
1 parent 884424c commit be76cd1

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

gui/src-tauri/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fn main() -> Result<()> {
191191
)
192192
.title("SlimeVR")
193193
.inner_size(1289.0, 709.0)
194-
.min_inner_size(393.0, 667.0)
194+
.min_inner_size(util::MIN_WINDOW_SIZE_WIDTH, util::MIN_WINDOW_SIZE_HEIGHT)
195195
.resizable(true)
196196
.visible(true)
197197
.decorations(false)

gui/src-tauri/src/state.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use color_eyre::Result;
44
use serde::{Deserialize, Serialize};
55
use tauri::{LogicalSize, Monitor, PhysicalPosition, PhysicalSize, Window};
66

7+
use crate::util;
8+
79
static STATE_FILENAME: &str = ".window-state.json";
810

911
#[derive(Serialize, Deserialize, Debug, Default)]
@@ -73,7 +75,11 @@ impl WindowState {
7375
window.unmaximize()?;
7476
}
7577

76-
window.set_size(LogicalSize::new(self.width, self.height))?;
78+
if self.width > util::MIN_WINDOW_SIZE_WIDTH
79+
&& self.height > util::MIN_WINDOW_SIZE_HEIGHT
80+
{
81+
window.set_size(LogicalSize::new(self.width, self.height))?;
82+
}
7783

7884
let pos = PhysicalPosition::new(self.x, self.y);
7985
for monitor in window.available_monitors()? {

gui/src-tauri/src/util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ pub static POSSIBLE_TITLES: &[&str] = &[
2828
"never gonna let you down",
2929
"uwu sowwy",
3030
];
31+
pub const MIN_WINDOW_SIZE_WIDTH: f64 = 393.0;
32+
pub const MIN_WINDOW_SIZE_HEIGHT: f64 = 667.0;
3133

3234
shadow!(build);
3335
// Tauri has a way to return the package.json version, but it's not a constant...

0 commit comments

Comments
 (0)