Skip to content

Commit

Permalink
feat: add transparent window example and support (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
FliPPeDround authored Nov 13, 2024
1 parent 291225e commit 3fd2e3f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/transparent.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Application } from "../index.js";

const app = new Application();
const window = app.createBrowserWindow({
transparent: true,
decorations: false,
});

const webview = window.createWebview({
html: /* html */ `
<html>
<body style="background-color:rgba(87,87,87,0.5);">
<h1>Hello, transparent!</h1>
</body>
</html>`,
transparent: true,
enableDevtools: true,
});

app.run();
9 changes: 9 additions & 0 deletions src/browser_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ impl BrowserWindow {
window = window.with_focused(focused);
}

if let Some(transparent) = options.transparent {
window = window.with_transparent(transparent);
#[cfg(target_os = "windows")]
{
use tao::platform::windows::WindowBuilderExtWindows;
window = window.with_undecorated_shadow(false);
}
}

if let Some(fullscreen) = options.fullscreen {
let fs = match fullscreen {
// Some(FullscreenType::Exclusive) => Some(Fullscreen::Exclusive()),
Expand Down

0 comments on commit 3fd2e3f

Please sign in to comment.