Skip to content

Commit c1ec0f1

Browse files
aelewlucasfernog
andauthored
feat(core): expose always_on_bottom, closes #7847 (#7933)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent c085add commit c1ec0f1

File tree

17 files changed

+154
-41
lines changed

17 files changed

+154
-41
lines changed

.changes/always-on-bottom-api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tauri-apps/api": patch:feat
3+
---
4+
5+
Added `setAlwaysOnBottom` function on `Window` and the `alwaysOnBottom` option when creating a window.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri-utils': 'minor:feat'
3+
---
4+
5+
Added the `always_on_bottom` option to the window configuration.

.changes/always-on-bottom.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'tauri': 'minor:feat'
3+
'tauri-runtime': 'minor:feat'
4+
'tauri-runtime-wry': 'minor:feat'
5+
---
6+
7+
Added `Window::set_always_on_bottom` and the `always_on_bottom` option when creating a window.

core/tauri-config-schema/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,11 @@
440440
"default": true,
441441
"type": "boolean"
442442
},
443+
"alwaysOnBottom": {
444+
"description": "Whether the window should always be below other windows.",
445+
"default": false,
446+
"type": "boolean"
447+
},
443448
"alwaysOnTop": {
444449
"description": "Whether the window should always be on top of other windows.",
445450
"default": false,

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ impl WindowBuilder for WindowBuilderWrapper {
627627
.fullscreen(config.fullscreen)
628628
.decorations(config.decorations)
629629
.maximized(config.maximized)
630+
.always_on_bottom(config.always_on_bottom)
630631
.always_on_top(config.always_on_top)
631632
.visible_on_all_workspaces(config.visible_on_all_workspaces)
632633
.content_protected(config.content_protected)
@@ -745,6 +746,11 @@ impl WindowBuilder for WindowBuilderWrapper {
745746
self
746747
}
747748

749+
fn always_on_bottom(mut self, always_on_bottom: bool) -> Self {
750+
self.inner = self.inner.with_always_on_bottom(always_on_bottom);
751+
self
752+
}
753+
748754
fn always_on_top(mut self, always_on_top: bool) -> Self {
749755
self.inner = self.inner.with_always_on_top(always_on_top);
750756
self
@@ -1022,6 +1028,7 @@ pub enum WindowMessage {
10221028
Close,
10231029
SetDecorations(bool),
10241030
SetShadow(bool),
1031+
SetAlwaysOnBottom(bool),
10251032
SetAlwaysOnTop(bool),
10261033
SetVisibleOnAllWorkspaces(bool),
10271034
SetContentProtected(bool),
@@ -1413,6 +1420,16 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
14131420
)
14141421
}
14151422

1423+
fn set_always_on_bottom(&self, always_on_bottom: bool) -> Result<()> {
1424+
send_user_message(
1425+
&self.context,
1426+
Message::Window(
1427+
self.window_id,
1428+
WindowMessage::SetAlwaysOnBottom(always_on_bottom),
1429+
),
1430+
)
1431+
}
1432+
14161433
fn set_always_on_top(&self, always_on_top: bool) -> Result<()> {
14171434
send_user_message(
14181435
&self.context,
@@ -2289,6 +2306,9 @@ fn handle_user_message<T: UserEvent>(
22892306
#[cfg(target_os = "macos")]
22902307
window.set_has_shadow(_enable);
22912308
}
2309+
WindowMessage::SetAlwaysOnBottom(always_on_bottom) => {
2310+
window.set_always_on_bottom(always_on_bottom)
2311+
}
22922312
WindowMessage::SetAlwaysOnTop(always_on_top) => window.set_always_on_top(always_on_top),
22932313
WindowMessage::SetVisibleOnAllWorkspaces(visible_on_all_workspaces) => {
22942314
window.set_visible_on_all_workspaces(visible_on_all_workspaces)

core/tauri-runtime/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,9 @@ pub trait Dispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'static
531531
/// Updates the shadow flag.
532532
fn set_shadow(&self, enable: bool) -> Result<()>;
533533

534+
/// Updates the window alwaysOnBottom flag.
535+
fn set_always_on_bottom(&self, always_on_bottom: bool) -> Result<()>;
536+
534537
/// Updates the window alwaysOnTop flag.
535538
fn set_always_on_top(&self, always_on_top: bool) -> Result<()>;
536539

core/tauri-runtime/src/webview.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ pub trait WindowBuilder: WindowBuilderBase {
240240
#[must_use]
241241
fn decorations(self, decorations: bool) -> Self;
242242

243+
/// Whether the window should always be below other windows.
244+
#[must_use]
245+
fn always_on_bottom(self, always_on_bottom: bool) -> Self;
246+
243247
/// Whether the window should always be on top of other windows.
244248
#[must_use]
245249
fn always_on_top(self, always_on_top: bool) -> Self;

core/tauri-utils/src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,9 @@ pub struct WindowConfig {
965965
/// Whether the window should have borders and bars.
966966
#[serde(default = "default_true")]
967967
pub decorations: bool,
968+
/// Whether the window should always be below other windows.
969+
#[serde(default, alias = "always-on-bottom")]
970+
pub always_on_bottom: bool,
968971
/// Whether the window should always be on top of other windows.
969972
#[serde(default, alias = "always-on-top")]
970973
pub always_on_top: bool,
@@ -1057,6 +1060,7 @@ impl Default for WindowConfig {
10571060
maximized: false,
10581061
visible: true,
10591062
decorations: true,
1063+
always_on_bottom: false,
10601064
always_on_top: false,
10611065
visible_on_all_workspaces: false,
10621066
content_protected: false,
@@ -2249,6 +2253,7 @@ mod build {
22492253
let maximized = self.maximized;
22502254
let visible = self.visible;
22512255
let decorations = self.decorations;
2256+
let always_on_bottom = self.always_on_bottom;
22522257
let always_on_top = self.always_on_top;
22532258
let visible_on_all_workspaces = self.visible_on_all_workspaces;
22542259
let content_protected = self.content_protected;
@@ -2290,6 +2295,7 @@ mod build {
22902295
maximized,
22912296
visible,
22922297
decorations,
2298+
always_on_bottom,
22932299
always_on_top,
22942300
visible_on_all_workspaces,
22952301
content_protected,

core/tauri/scripts/bundle.global.js

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

core/tauri/src/test/mock_runtime.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ impl WindowBuilder for MockWindowBuilder {
283283
self
284284
}
285285

286+
fn always_on_bottom(self, always_on_bottom: bool) -> Self {
287+
self
288+
}
289+
286290
fn always_on_top(self, always_on_top: bool) -> Self {
287291
self
288292
}
@@ -600,6 +604,10 @@ impl<T: UserEvent> Dispatch<T> for MockDispatcher {
600604
Ok(())
601605
}
602606

607+
fn set_always_on_bottom(&self, always_on_bottom: bool) -> Result<()> {
608+
Ok(())
609+
}
610+
603611
fn set_always_on_top(&self, always_on_top: bool) -> Result<()> {
604612
Ok(())
605613
}

0 commit comments

Comments
 (0)