fix: center and focus not being allowed in config (#2199)

This commit is contained in:
FabianLars 2021-07-12 16:59:32 +02:00 committed by GitHub
parent d0f34a3784
commit bc2c331dec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,7 @@
---
"cli.rs": patch
"tauri-runtime-wry": patch
---
Fixes `center` and `focus` not being allowed in `tauri.conf.json > tauri > windows` and ignored in `WindowBuilderWrapper`.

View File

@ -442,6 +442,10 @@ impl WindowBuilder for WindowBuilderWrapper {
window = window.position(x, y); window = window.position(x, y);
} }
if config.center {
window = window.center();
}
if config.focus { if config.focus {
window = window.focus(); window = window.focus();
} }

View File

@ -268,6 +268,9 @@ pub struct WindowConfig {
/// Disabling it is required to use drag and drop on the frontend on Windows. /// Disabling it is required to use drag and drop on the frontend on Windows.
#[serde(default = "default_file_drop_enabled")] #[serde(default = "default_file_drop_enabled")]
pub file_drop_enabled: bool, pub file_drop_enabled: bool,
/// Whether or not the window starts centered or not.
#[serde(default)]
pub center: bool,
/// The horizontal position of the window's top left corner /// The horizontal position of the window's top left corner
pub x: Option<f64>, pub x: Option<f64>,
/// The vertical position of the window's top left corner /// The vertical position of the window's top left corner
@ -292,6 +295,9 @@ pub struct WindowConfig {
/// Whether the window starts as fullscreen or not. /// Whether the window starts as fullscreen or not.
#[serde(default)] #[serde(default)]
pub fullscreen: bool, pub fullscreen: bool,
/// Whether the window will be initially hidden or focused.
#[serde(default = "default_focus")]
pub focus: bool,
/// Whether the window is transparent or not. /// Whether the window is transparent or not.
#[serde(default)] #[serde(default)]
pub transparent: bool, pub transparent: bool,
@ -312,6 +318,10 @@ pub struct WindowConfig {
pub skip_taskbar: bool, pub skip_taskbar: bool,
} }
fn default_focus() -> bool {
true
}
fn default_visible() -> bool { fn default_visible() -> bool {
true true
} }

View File

@ -1099,6 +1099,11 @@
"default": false, "default": false,
"type": "boolean" "type": "boolean"
}, },
"center": {
"description": "Whether or not the window starts centered or not.",
"default": false,
"type": "boolean"
},
"decorations": { "decorations": {
"description": "Whether the window should have borders and bars.", "description": "Whether the window should have borders and bars.",
"default": true, "default": true,
@ -1109,6 +1114,11 @@
"default": true, "default": true,
"type": "boolean" "type": "boolean"
}, },
"focus": {
"description": "Whether the window will be initially hidden or focused.",
"default": true,
"type": "boolean"
},
"fullscreen": { "fullscreen": {
"description": "Whether the window starts as fullscreen or not.", "description": "Whether the window starts as fullscreen or not.",
"default": false, "default": false,