Skip to content

Commit 54090e1

Browse files
committed
feat(tauri): keep track of window state and position
1 parent 0e0791c commit 54090e1

9 files changed

Lines changed: 72 additions & 28 deletions

File tree

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
},
88
"[json]": {
99
"editor.defaultFormatter": "esbenp.prettier-vscode"
10+
},
11+
"[rust]": {
12+
"editor.defaultFormatter": "rust-lang.rust-analyzer"
1013
}
1114
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,4 @@
126126
"vite-plugin-top-level-await": "^1.6.0",
127127
"wrangler": "^4.70.0"
128128
}
129-
}
129+
}

src-tauri/Cargo.lock

Lines changed: 38 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
2-
name = "app"
2+
name = "sable"
33
version = "0.1.0"
4-
description = "A Tauri App"
4+
description = "Yet another matrix client but better"
55
authors = ["you"]
66
license = ""
77
repository = ""
@@ -45,3 +45,6 @@ windows = { version = "0.61", features = [
4545

4646
[target.'cfg(any(target_os = "macos", windows, target_os = "linux"))'.dependencies]
4747
tauri-plugin-single-instance = { version = "2.4.0", features = ["deep-link"] }
48+
49+
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
50+
tauri-plugin-window-state = "2.4.1"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"identifier": "desktop-capability",
3+
"platforms": [
4+
"macOS",
5+
"windows",
6+
"linux"
7+
],
8+
"windows": [
9+
"main"
10+
],
11+
"permissions": [
12+
"window-state:default"
13+
]
14+
}

src-tauri/src/desktop_tray.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub fn show_or_create_main_window<R: tauri::Runtime>(app: &AppHandle<R>) -> taur
149149
}
150150

151151
let window = WebviewWindowBuilder::new(app, MAIN_WINDOW_LABEL, WebviewUrl::default())
152-
.title("sable")
152+
.title(app.package_info().name.clone())
153153
.build()?;
154154
configure_main_window(&window);
155155

src-tauri/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::sync::Arc;
66
#[cfg(debug_assertions)]
77
use specta_typescript::Typescript;
88
use tauri::Manager;
9+
use tauri_plugin_window_state::StateFlags;
910
use tauri_specta::{collect_commands, Builder};
1011

1112
#[cfg_attr(mobile, tauri::mobile_entry_point)]
@@ -30,6 +31,13 @@ pub fn run() {
3031
let invoke_handler = specta_builder.invoke_handler();
3132

3233
tauri::Builder::default()
34+
.plugin(
35+
tauri_plugin_window_state::Builder::default()
36+
.with_state_flags(
37+
StateFlags::all() & !StateFlags::VISIBLE & !StateFlags::DECORATIONS,
38+
)
39+
.build(),
40+
)
3341
.manage(desktop_tray::DesktopSettingsState::new(true))
3442
.manage(Arc::new(windows::window_tracking::TrackingState::new()))
3543
.plugin(tauri_plugin_single_instance::init(|app, _argv, _cwd| {

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
33
"productName": "sable",
44
"version": "0.1.0",
5-
"identifier": "com.tauri.dev",
5+
"identifier": "moe.sable.app",
66
"build": {
77
"frontendDist": "../dist",
88
"devUrl": "http://localhost:8080",

0 commit comments

Comments
 (0)