Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
fix: preserve native Windows video fullscreen
youxi798f671ded1a4fa
diff --git a/AGENTS.md b/AGENTS.mdindex b2db51bd..baecad30 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -117,6 +117,7 @@ Proactive latent-bug sweeps use `.agents/skills/bugs/SKILL.md`. Pick one row and- Per-app optional fields in `default_app_list.json` currently take their defaults in Actions expressions in `release.yml` (`matrix.config.x || false` and the numeric ones), which works because every field so far is default-false or numeric. The first default-true field cannot use that path and must move its default into the jq read step: GitHub expressions cast both `null` and `false` to `0`, so `matrix.config.x != false` cannot express "default true" and would silently flip every app missing the field.- Windows taskbar icons can register blank when an autostarted app launches before Explorer's icon cache is ready (#1323). Every hidden-to-visible `window.show()` path (main or secondary: tray show/click, activation shortcut, single-instance activation, startup/page-load reveal, multi-window Cmd+N reveal) must call `reapply_window_icon` from `src-tauri/src/app/window.rs` (or go through `reveal_built_window` / `reveal_startup_window`, which already do). The helper reasserts both the small window icon and the large taskbar icon; a new show path without it regresses the bug.- Multi-window home clones (`open_additional_window_safe`, labels `pake-N`) are built hidden and revealed via `reveal_built_window` on the first real page load (or a 3s fallback), matching the main-window blank-shell guard. OAuth/pop-up windows from `--new-window` stay immediately visible by design. Tray Hide/Show, tray left-click, and the activation shortcut must act on **every** webview via `hide_all_app_windows` / `show_all_app_windows` / `toggle_all_app_windows` (not only label `"pake"`). Two Windows-specific constraints hold that toggle together (#1343): the tray click handler must match `button_state == MouseButtonState::Up`, because Windows emits `TrayIconEvent::Click` twice per physical click and reacting to both runs the toggle twice; and `any_app_window_visible` must exclude minimized windows, because `hide_on_close` minimizes before hiding and Windows keeps `IsWindowVisible` true while a window is iconic. Locked by `tests/unit/tray-toggle-visibility.test.ts`.+- Windows uses WebView2 native DOM fullscreen; Tauri already synchronizes its `ContainsFullScreenElementChanged` event with the native window. Do not inject `fullscreen.js` on Windows: its media extraction separates video from player controls (#1373). F11 must exit an active DOM fullscreen session through `document.exitFullscreen()` before toggling the native window. Verify the platform gate and `node --test tests/browser/fullscreen.mjs`; macOS/Linux retain the existing polyfill.- Injected Linux/Windows shortcuts (Ctrl+R / [ / ]) call the `webview_navigate` IPC so reload and history use the platform webview API on blank error pages; do not route those shortcuts only through page `history` / `location`.- Download and toast paths must not hardcode `get_webview_window("pake")` when the action originates from a secondary window: IPC commands take the calling `WebviewWindow`, and `on_download` resolves toast by the event webview's label. Authenticated downloads should attach webview session cookies when available. Link-download heuristics prefer real file extensions, the `download` attribute, and `?download` / `?attachment` query hints; Cmd/Ctrl+click is navigation, not "save as"; do not re-add broad SPA roots such as `/assets/`, `/dist/`, `/files/`, or `/releases/` (see #1337, #1339).- macOS menu navigation must keep working on blank error pages: Reload uses native `WebviewWindow::reload`, Go Home uses `navigate` + `resolve_home_url`, Back/Forward use the platform WKWebView history API rather than page `eval`. Copy URL reads `window.url()` so it does not depend on a live JS document.diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rsindex 8a07ddc4..b5ee832e 100644--- a/src-tauri/src/app/window.rs+++ b/src-tauri/src/app/window.rs@@ -525,9 +525,8 @@ fn build_window(}// Add initialization scripts. Order matters: pakeConfig must land before- // any script that reads it (e.g. fullscreen polyfill checks for an opt-out- // flag), and toast must register `window.pakeToast` before Rust code- // calls show_toast().+ // any script that reads it, and toast must register `window.pakeToast`+ // before Rust code calls show_toast().window_builder = window_builder.initialization_script_for_all_frames(&config_script).initialization_script_for_all_frames(include_str!("../inject/link_policy.js"))@@ -544,9 +543,17 @@ fn build_window(window_builder = window_builder.initialization_script(include_str!("../inject/find.js"));}+ window_builder = window_builder.initialization_script(include_str!("../inject/toast.js"));++ // WebView2's native Fullscreen API already drives Tauri's window fullscreen.+ // Keep its top-layer layout and player controls instead of overriding the API.+ #[cfg(not(target_os = "windows"))]+ {+ window_builder =+ window_builder.initialization_script(include_str!("../inject/fullscreen.js"));+ }+window_builder = window_builder- .initialization_script(include_str!("../inject/toast.js"))- .initialization_script(include_str!("../inject/fullscreen.js")).initialization_script(include_str!("../inject/event.js")).initialization_script(include_str!("../inject/style.js")).initialization_script(include_str!("../inject/theme_refresh.js"))diff --git a/src-tauri/src/inject/event.js b/src-tauri/src/inject/event.jsindex 71d571dd..ae7646b8 100644--- a/src-tauri/src/inject/event.js+++ b/src-tauri/src/inject/event.js@@ -101,7 +101,12 @@ function handleWebShortcut(event) {function toggleNativeFullscreen(appWindow) {appWindow.isFullscreen()- .then((fullscreen) => appWindow.setFullscreen(!fullscreen))+ .then((fullscreen) => {+ if (document.fullscreenElement && document.exitFullscreen) {+ return document.exitFullscreen();+ }+ return appWindow.setFullscreen(!fullscreen);+ }).catch((error) => {console.warn("[Pake] Failed to toggle native fullscreen:", error);});diff --git a/tests/browser/fullscreen.mjs b/tests/browser/fullscreen.mjsnew file mode 100644index 00000000..0343f96c--- /dev/null+++ b/tests/browser/fullscreen.mjs@@ -0,0 +1,93 @@+// Native DOM fullscreen must retain player controls and exit through F11.+import assert from "node:assert/strict";+import fs from "node:fs/promises";+import { pathToFileURL } from "node:url";+import { test } from "node:test";+const { chromium } = await import(+ process.env.PAKE_PLAYWRIGHT_MODULE+ ? pathToFileURL(process.env.PAKE_PLAYWRIGHT_MODULE).href+ : "playwright"+);+const source = await Promise.all(+ ["link_policy.js", "auth.js", "event.js"].map((name) =>+ fs.readFile(+ `${process.env.PAKE_INJECT_ROOT || "src-tauri/src/inject"}/${name}`,+ "utf8",+ ),+ ),+);+test("native fullscreen preserves the player subtree and F11 exits its top layer", async () => {+ const browser = await chromium.launch({+ headless: true,+ ...(process.env.PAKE_BROWSER_EXECUTABLE+ ? { executablePath: process.env.PAKE_BROWSER_EXECUTABLE }+ : {}),+ });+ try {+ const context = await browser.newContext();+ await context.addInitScript(+ ({ source }) => {+ Object.defineProperty(navigator, "platform", { value: "Win32" });+ Object.defineProperty(navigator, "userAgentData", {+ value: { platform: "Windows" },+ });+ window.pakeConfig = { url: "https://video.example.com/" };+ window.__TAURI__ = {+ core: { invoke: () => Promise.resolve() },+ window: {+ getCurrentWindow: () => ({+ isFullscreen: async () => !!document.fullscreenElement,+ setFullscreen: async () => {},+ }),+ },+ };+ for (const script of source) (0, eval)(script);+ },+ { source },+ );+ await context.route("**/*", (route) =>+ route.fulfill({+ contentType: "text/html",+ body: `+ <style>#player{width:320px;height:180px}#player:fullscreen{background:black}+ #controls{position:absolute;bottom:20px;left:20px}</style>+ <section id="player"><video></video><button id="controls">Pause</button></section>+ <button id="enter" onclick="document.querySelector('#player').requestFullscreen()">Fullscreen</button>`,+ }),+ );+ const page = await context.newPage();+ await page.goto("https://video.example.com/");+ await page.locator("#enter").click();+ await page.waitForFunction(+ () => document.fullscreenElement?.id === "player",+ );+ assert.equal(+ await page.evaluate(() => {+ const player = document.querySelector("#player");+ const controls = document.querySelector("#controls");+ const rect = controls.getBoundingClientRect();+ return (+ player.matches(":fullscreen") &&+ player.contains(controls) &&+ player.contains(document.querySelector("video")) &&+ document.elementFromPoint(+ rect.x + rect.width / 2,+ rect.y + rect.height / 2,+ ) === controls+ );+ }),+ true,+ );+ await page.keyboard.press("F11");+ await page.waitForFunction(+ () => document.fullscreenElement === null,+ null,+ {+ timeout: 3000,+ },+ );+ assert.equal(await page.locator("#player > video").count(), 1);+ } finally {+ await browser.close();+ }+});diff --git a/tests/unit/event-fullscreen-shortcuts.test.js b/tests/unit/event-fullscreen-shortcuts.test.jsindex 274ff532..59a6c20a 100644--- a/tests/unit/event-fullscreen-shortcuts.test.js+++ b/tests/unit/event-fullscreen-shortcuts.test.js@@ -192,6 +192,16 @@ function createKeyEvent(key, overrides = {}) {}describe("event fullscreen shortcuts", () => {+ it("preserves WebView2 native fullscreen and keeps the other platform polyfill", () => {+ const source = fs.readFileSync("src-tauri/src/app/window.rs", "utf8");+ const injection =+ /#\[cfg\(not\(target_os = "windows"\)\)\]\s*\{\s*window_builder =\s*window_builder\.initialization_script\(include_str!\("\.\.\/inject\/fullscreen\.js"\)\);\s*\}/;+ expect(source).toMatch(injection);+ expect(+ source.match(/include_str!\("\.\.\/inject\/fullscreen\.js"\)/g),+ ).toHaveLength(1);+ });+it("leaves macOS reload shortcuts to the native menu", () => {const context = loadEventHelpers({userAgent:@@ -255,6 +265,17 @@ describe("event fullscreen shortcuts", () => {expect(context.fullscreenCalls).toEqual([false]);});+ it("exits DOM fullscreen before leaving a fullscreen video on F11", async () => {+ const context = loadEventHelpers({ initialFullscreen: true });+ context.document.fullscreenElement = context.document.body;+ context.document.exitFullscreen = vi.fn().mockResolvedValue(undefined);+ getFullscreenShortcutHandler(context)(createKeyEvent("F11"));+ await Promise.resolve();+ await Promise.resolve();+ expect(context.document.exitFullscreen).toHaveBeenCalledOnce();+ expect(context.fullscreenCalls).toEqual([]);+ });+it("toggles native fullscreen on F11 for Linux", async () => {const context = loadEventHelpers({userAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36",