Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/no-redirection-bitmap-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tauri-apps/api': 'minor:feat'
---

Added `noRedirectionBitmap` option to the `Window` and `WebviewWindow` constructors on Windows.
6 changes: 6 additions & 0 deletions .changes/no-redirection-bitmap-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'tauri': 'minor:feat'
'tauri-utils': 'minor:feat'
---

Added `app > windows > noRedirectionBitmap` config option to disable the window redirection bitmap on Windows.
7 changes: 7 additions & 0 deletions .changes/no-redirection-bitmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'tauri': 'minor:feat'
'tauri-runtime': 'minor:feat'
'tauri-runtime-wry': 'minor:feat'
---

Added `WindowBuilder/WebviewWindowBuilder::no_redirection_bitmap` method to disable the window redirection bitmap on Windows.
7 changes: 6 additions & 1 deletion crates/tauri-cli/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
"type": "boolean"
},
"transparent": {
"description": "Whether the window is transparent or not.\n\n Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri > macOSPrivateApi`.\n WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.",
"description": "Whether the window is transparent or not.\n\n Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri > macOSPrivateApi`.\n WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.\n\n On Windows, using `noRedirectionBitmap` can help avoid a white flash when creating a transparent window.",
"default": false,
"type": "boolean"
},
Expand Down Expand Up @@ -425,6 +425,11 @@
"null"
]
},
"noRedirectionBitmap": {
"description": "This sets `WS_EX_NOREDIRECTIONBITMAP`.\n\n This can avoid the white flash that may appear before the webview content is rendered\n when using a transparent window. **Windows only**.",
"default": false,
"type": "boolean"
},
"theme": {
"description": "The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.",
"anyOf": [
Expand Down
9 changes: 9 additions & 0 deletions crates/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ impl WindowBuilder for WindowBuilderWrapper {
.content_protected(config.content_protected)
.skip_taskbar(config.skip_taskbar)
.theme(config.theme)
.no_redirection_bitmap(config.no_redirection_bitmap)
.closable(config.closable)
.maximizable(config.maximizable)
.minimizable(config.minimizable)
Expand Down Expand Up @@ -1301,6 +1302,14 @@ impl WindowBuilder for WindowBuilderWrapper {
self
}

fn no_redirection_bitmap(#[allow(unused_mut)] mut self, _enable: bool) -> Self {
#[cfg(windows)]
{
self.inner = self.inner.with_no_redirection_bitmap(_enable);
}
self
}

#[cfg(target_os = "android")]
fn activity_name<S: Into<String>>(mut self, class_name: S) -> Self {
self.inner = self.inner.with_activity_name(class_name.into());
Expand Down
10 changes: 10 additions & 0 deletions crates/tauri-runtime/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ pub trait WindowBuilder: WindowBuilderBase {

/// Whether the window should be transparent. If this is true, writing colors
/// with alpha values different than `1.0` will produce a transparent window.
///
/// On Windows, using `no_redirection_bitmap` can help avoid a white flash when
/// creating a transparent window.
#[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))]
#[cfg_attr(
docsrs,
Expand Down Expand Up @@ -498,6 +501,13 @@ pub trait WindowBuilder: WindowBuilderBase {
#[must_use]
fn window_classname<S: Into<String>>(self, window_classname: S) -> Self;

/// This sets `WS_EX_NOREDIRECTIONBITMAP`.
///
/// This can avoid the white flash that may appear before the webview content is rendered
/// when using a transparent window. **Windows only**.
#[must_use]
fn no_redirection_bitmap(self, enable: bool) -> Self;

/// The name of the activity to create for this webview window.
#[cfg(target_os = "android")]
fn activity_name<S: Into<String>>(self, class_name: S) -> Self;
Expand Down
7 changes: 6 additions & 1 deletion crates/tauri-schema-generator/schemas/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
"type": "boolean"
},
"transparent": {
"description": "Whether the window is transparent or not.\n\n Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri > macOSPrivateApi`.\n WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.",
"description": "Whether the window is transparent or not.\n\n Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri > macOSPrivateApi`.\n WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.\n\n On Windows, using `noRedirectionBitmap` can help avoid a white flash when creating a transparent window.",
"default": false,
"type": "boolean"
},
Expand Down Expand Up @@ -425,6 +425,11 @@
"null"
]
},
"noRedirectionBitmap": {
"description": "This sets `WS_EX_NOREDIRECTIONBITMAP`.\n\n This can avoid the white flash that may appear before the webview content is rendered\n when using a transparent window. **Windows only**.",
"default": false,
"type": "boolean"
},
"theme": {
"description": "The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.",
"anyOf": [
Expand Down
11 changes: 11 additions & 0 deletions crates/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,8 @@ pub struct WindowConfig {
///
/// Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri > macOSPrivateApi`.
/// WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.
///
/// On Windows, using `noRedirectionBitmap` can help avoid a white flash when creating a transparent window.
#[serde(default)]
pub transparent: bool,
/// Whether the window is maximized or not.
Expand Down Expand Up @@ -2053,6 +2055,12 @@ pub struct WindowConfig {
pub skip_taskbar: bool,
/// The name of the window class created on Windows to create the window. **Windows only**.
pub window_classname: Option<String>,
/// This sets `WS_EX_NOREDIRECTIONBITMAP`.
///
/// This can avoid the white flash that may appear before the webview content is rendered
/// when using a transparent window. **Windows only**.
#[serde(default, alias = "no-redirection-bitmap")]
pub no_redirection_bitmap: bool,
/// The initial window theme. Defaults to the system theme. Only implemented on Windows and macOS 10.14+.
pub theme: Option<crate::Theme>,
/// The style of the macOS title bar.
Expand Down Expand Up @@ -2327,6 +2335,7 @@ impl Default for WindowConfig {
content_protected: false,
skip_taskbar: false,
window_classname: None,
no_redirection_bitmap: false,
theme: None,
title_bar_style: Default::default(),
traffic_light_position: None,
Expand Down Expand Up @@ -3873,6 +3882,7 @@ mod build {
let content_protected = self.content_protected;
let skip_taskbar = self.skip_taskbar;
let window_classname = opt_str_lit(self.window_classname.as_ref());
let no_redirection_bitmap = self.no_redirection_bitmap;
let theme = opt_lit(self.theme.as_ref());
let title_bar_style = &self.title_bar_style;
let traffic_light_position = opt_lit(self.traffic_light_position.as_ref());
Expand Down Expand Up @@ -3938,6 +3948,7 @@ mod build {
content_protected,
skip_taskbar,
window_classname,
no_redirection_bitmap,
theme,
title_bar_style,
traffic_light_position,
Expand Down
4 changes: 4 additions & 0 deletions crates/tauri/src/test/mock_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ impl WindowBuilder for MockWindowBuilder {
self
}

fn no_redirection_bitmap(self, enable: bool) -> Self {
self
}

fn shadow(self, enable: bool) -> Self {
self
}
Expand Down
13 changes: 13 additions & 0 deletions crates/tauri/src/webview/webview_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,16 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
self
}

/// This sets `WS_EX_NOREDIRECTIONBITMAP`.
///
/// This can avoid the white flash that may appear before the webview content is rendered
/// when using a transparent window. **Windows only**.
#[must_use]
pub fn no_redirection_bitmap(mut self, enable: bool) -> Self {
self.window_builder = self.window_builder.no_redirection_bitmap(enable);
self
}

/// Sets whether or not the window has shadow.
///
/// ## Platform-specific
Expand Down Expand Up @@ -1072,6 +1082,9 @@ impl<R: Runtime, M: Manager<R>> WebviewWindowBuilder<'_, R, M> {

/// Whether the window should be transparent. If this is true, writing colors
/// with alpha values different than `1.0` will produce a transparent window.
///
/// On Windows, using `no_redirection_bitmap` can help avoid a white flash when
/// creating a transparent window.
#[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))]
#[cfg_attr(
docsrs,
Expand Down
13 changes: 13 additions & 0 deletions crates/tauri/src/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,16 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
self
}

/// This sets `WS_EX_NOREDIRECTIONBITMAP`.
///
/// This can avoid the white flash that may appear before the webview content is rendered
/// when using a transparent window. **Windows only**.
#[must_use]
pub fn no_redirection_bitmap(mut self, enable: bool) -> Self {
self.window_builder = self.window_builder.no_redirection_bitmap(enable);
self
}

/// Sets whether or not the window has shadow.
///
/// ## Platform-specific
Expand Down Expand Up @@ -906,6 +916,9 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {

/// Whether the window should be transparent. If this is true, writing colors
/// with alpha values different than `1.0` will produce a transparent window.
///
/// On Windows, using `no_redirection_bitmap` can help avoid a white flash when
/// creating a transparent window.
#[cfg(any(not(target_os = "macos"), feature = "macos-private-api"))]
#[cfg_attr(
docsrs,
Expand Down
9 changes: 9 additions & 0 deletions packages/api/src/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2362,6 +2362,8 @@ interface WindowOptions {
* Whether the window is transparent or not.
* Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > app > macOSPrivateApi`.
* WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.
*
* On Windows, using `noRedirectionBitmap` can help avoid a white flash when creating a transparent window.
*/
transparent?: boolean
/** Whether the window should be maximized upon creation or not. */
Expand All @@ -2378,6 +2380,13 @@ interface WindowOptions {
contentProtected?: boolean
/** Whether or not the window icon should be added to the taskbar. */
skipTaskbar?: boolean
/**
* This sets `WS_EX_NOREDIRECTIONBITMAP`.
*
* This can avoid the white flash that may appear before the webview content is rendered
* when using a transparent window. **Windows only**.
*/
noRedirectionBitmap?: boolean
/**
* Whether or not the window has shadow.
*
Expand Down
Loading