Skip to content

Commit bc2c331

Browse files
authored
fix: center and focus not being allowed in config (#2199)
1 parent d0f34a3 commit bc2c331

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
---
3+
"cli.rs": patch
4+
"tauri-runtime-wry": patch
5+
---
6+
7+
Fixes `center` and `focus` not being allowed in `tauri.conf.json > tauri > windows` and ignored in `WindowBuilderWrapper`.

core/tauri-runtime-wry/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ impl WindowBuilder for WindowBuilderWrapper {
442442
window = window.position(x, y);
443443
}
444444

445+
if config.center {
446+
window = window.center();
447+
}
448+
445449
if config.focus {
446450
window = window.focus();
447451
}

tooling/cli.rs/config_definition.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ pub struct WindowConfig {
268268
/// Disabling it is required to use drag and drop on the frontend on Windows.
269269
#[serde(default = "default_file_drop_enabled")]
270270
pub file_drop_enabled: bool,
271+
/// Whether or not the window starts centered or not.
272+
#[serde(default)]
273+
pub center: bool,
271274
/// The horizontal position of the window's top left corner
272275
pub x: Option<f64>,
273276
/// The vertical position of the window's top left corner
@@ -292,6 +295,9 @@ pub struct WindowConfig {
292295
/// Whether the window starts as fullscreen or not.
293296
#[serde(default)]
294297
pub fullscreen: bool,
298+
/// Whether the window will be initially hidden or focused.
299+
#[serde(default = "default_focus")]
300+
pub focus: bool,
295301
/// Whether the window is transparent or not.
296302
#[serde(default)]
297303
pub transparent: bool,
@@ -312,6 +318,10 @@ pub struct WindowConfig {
312318
pub skip_taskbar: bool,
313319
}
314320

321+
fn default_focus() -> bool {
322+
true
323+
}
324+
315325
fn default_visible() -> bool {
316326
true
317327
}

tooling/cli.rs/schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,11 @@
10991099
"default": false,
11001100
"type": "boolean"
11011101
},
1102+
"center": {
1103+
"description": "Whether or not the window starts centered or not.",
1104+
"default": false,
1105+
"type": "boolean"
1106+
},
11021107
"decorations": {
11031108
"description": "Whether the window should have borders and bars.",
11041109
"default": true,
@@ -1109,6 +1114,11 @@
11091114
"default": true,
11101115
"type": "boolean"
11111116
},
1117+
"focus": {
1118+
"description": "Whether the window will be initially hidden or focused.",
1119+
"default": true,
1120+
"type": "boolean"
1121+
},
11121122
"fullscreen": {
11131123
"description": "Whether the window starts as fullscreen or not.",
11141124
"default": false,

0 commit comments

Comments
 (0)