Skip to content

Commit cd43831

Browse files
authored
feat(core): add no_redirection_bitmap API on Windows
1 parent 499df79 commit cd43831

10 files changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'tauri': 'minor:feat'
3+
'tauri-utils': 'minor:feat'
4+
---
5+
6+
Added `app > windows > noRedirectionBitmap` config option to disable the window redirection bitmap on Windows.

.changes/no-redirection-bitmap.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 `WindowBuilder/WebviewWindowBuilder::no_redirection_bitmap` method to disable the window redirection bitmap on Windows.

crates/tauri-cli/config.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@
425425
"null"
426426
]
427427
},
428+
"noRedirectionBitmap": {
429+
"description": "Disables the window redirection bitmap. **Windows only**.",
430+
"default": false,
431+
"type": "boolean"
432+
},
428433
"theme": {
429434
"description": "The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.",
430435
"anyOf": [

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,8 @@ impl WindowBuilder for WindowBuilderWrapper {
978978
window = window.window_classname(window_classname);
979979
}
980980

981+
window = window.no_redirection_bitmap(config.no_redirection_bitmap);
982+
981983
if let Some(prevent_overflow) = &config.prevent_overflow {
982984
window = match prevent_overflow {
983985
PreventOverflowConfig::Enable(true) => window.prevent_overflow(),
@@ -1301,6 +1303,16 @@ impl WindowBuilder for WindowBuilderWrapper {
13011303
self
13021304
}
13031305

1306+
#[cfg(windows)]
1307+
fn no_redirection_bitmap(mut self, enable: bool) -> Self {
1308+
self.inner = self.inner.with_no_redirection_bitmap(enable);
1309+
self
1310+
}
1311+
#[cfg(not(windows))]
1312+
fn no_redirection_bitmap(self, _enable: bool) -> Self {
1313+
self
1314+
}
1315+
13041316
#[cfg(target_os = "android")]
13051317
fn activity_name<S: Into<String>>(mut self, class_name: S) -> Self {
13061318
self.inner = self.inner.with_activity_name(class_name.into());

crates/tauri-runtime/src/window.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,11 @@ pub trait WindowBuilder: WindowBuilderBase {
498498
#[must_use]
499499
fn window_classname<S: Into<String>>(self, window_classname: S) -> Self;
500500

501+
/// Disables the window redirection bitmap. This can avoid the white flash that may appear
502+
/// before the webview content is rendered when using a transparent window. **Windows only**.
503+
#[must_use]
504+
fn no_redirection_bitmap(self, enable: bool) -> Self;
505+
501506
/// The name of the activity to create for this webview window.
502507
#[cfg(target_os = "android")]
503508
fn activity_name<S: Into<String>>(self, class_name: S) -> Self;

crates/tauri-schema-generator/schemas/config.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@
425425
"null"
426426
]
427427
},
428+
"noRedirectionBitmap": {
429+
"description": "Disables the window redirection bitmap. **Windows only**.",
430+
"default": false,
431+
"type": "boolean"
432+
},
428433
"theme": {
429434
"description": "The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.",
430435
"anyOf": [

crates/tauri-utils/src/config.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,10 @@ pub struct WindowConfig {
20532053
pub skip_taskbar: bool,
20542054
/// The name of the window class created on Windows to create the window. **Windows only**.
20552055
pub window_classname: Option<String>,
2056+
/// Disables the window redirection bitmap. This can avoid the white flash that may appear
2057+
/// before the webview content is rendered when using a transparent window. **Windows only**.
2058+
#[serde(default, alias = "no-redirection-bitmap")]
2059+
pub no_redirection_bitmap: bool,
20562060
/// The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.
20572061
pub theme: Option<crate::Theme>,
20582062
/// The style of the macOS title bar.
@@ -2327,6 +2331,7 @@ impl Default for WindowConfig {
23272331
content_protected: false,
23282332
skip_taskbar: false,
23292333
window_classname: None,
2334+
no_redirection_bitmap: false,
23302335
theme: None,
23312336
title_bar_style: Default::default(),
23322337
traffic_light_position: None,
@@ -3873,6 +3878,7 @@ mod build {
38733878
let content_protected = self.content_protected;
38743879
let skip_taskbar = self.skip_taskbar;
38753880
let window_classname = opt_str_lit(self.window_classname.as_ref());
3881+
let no_redirection_bitmap = self.no_redirection_bitmap;
38763882
let theme = opt_lit(self.theme.as_ref());
38773883
let title_bar_style = &self.title_bar_style;
38783884
let traffic_light_position = opt_lit(self.traffic_light_position.as_ref());
@@ -3938,6 +3944,7 @@ mod build {
39383944
content_protected,
39393945
skip_taskbar,
39403946
window_classname,
3947+
no_redirection_bitmap,
39413948
theme,
39423949
title_bar_style,
39433950
traffic_light_position,

crates/tauri/src/test/mock_runtime.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ impl WindowBuilder for MockWindowBuilder {
464464
self
465465
}
466466

467+
fn no_redirection_bitmap(self, enable: bool) -> Self {
468+
self
469+
}
470+
467471
fn shadow(self, enable: bool) -> Self {
468472
self
469473
}

crates/tauri/src/webview/webview_window.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,14 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
599599
self
600600
}
601601

602+
/// Disables the window redirection bitmap. This can avoid the white flash that may appear
603+
/// before the webview content is rendered when using a transparent window. **Windows only**.
604+
#[must_use]
605+
pub fn no_redirection_bitmap(mut self, enable: bool) -> Self {
606+
self.window_builder = self.window_builder.no_redirection_bitmap(enable);
607+
self
608+
}
609+
602610
/// Sets whether or not the window has shadow.
603611
///
604612
/// ## Platform-specific

crates/tauri/src/window/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,14 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
611611
self
612612
}
613613

614+
/// Disables the window redirection bitmap. This can avoid the white flash that may appear
615+
/// before the webview content is rendered when using a transparent window. **Windows only**.
616+
#[must_use]
617+
pub fn no_redirection_bitmap(mut self, enable: bool) -> Self {
618+
self.window_builder = self.window_builder.no_redirection_bitmap(enable);
619+
self
620+
}
621+
614622
/// Sets whether or not the window has shadow.
615623
///
616624
/// ## Platform-specific

0 commit comments

Comments
 (0)