From 8de397ee6aab76fd746addf59b570b2d47b99506 Mon Sep 17 00:00:00 2001 From: Kirill Dakhniuk Date: Sat, 29 Nov 2025 12:38:50 +0200 Subject: [PATCH 1/2] Add trafficLightsHidden method to hide traffic lights --- src/Windows/Window.php | 15 +++++++++++++++ tests/Windows/WindowTest.php | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Windows/Window.php b/src/Windows/Window.php index cfea951..d2ded80 100644 --- a/src/Windows/Window.php +++ b/src/Windows/Window.php @@ -60,6 +60,8 @@ class Window protected array $trafficLightPosition = []; + protected bool $windowButtonVisibility = true; + protected string $title = ''; protected string $id = 'main'; @@ -150,6 +152,18 @@ public function trafficLightPosition(int $x, int $y): self return $this; } + public function trafficLightsHidden(): self + { + return $this->windowButtonVisibility(false); + } + + public function windowButtonVisibility($visible = true): self + { + $this->windowButtonVisibility = $visible; + + return $this; + } + public function rememberState(): self { $this->rememberState = true; @@ -392,6 +406,7 @@ public function toArray() 'frame' => $this->frame, 'titleBarStyle' => $this->titleBarStyle, 'trafficLightPosition' => $this->trafficLightPosition, + 'windowButtonVisibility' => $this->windowButtonVisibility, 'showDevTools' => $this->showDevTools, 'vibrancy' => $this->vibrancy, 'transparency' => $this->transparent, diff --git a/tests/Windows/WindowTest.php b/tests/Windows/WindowTest.php index 5339af3..3ad5561 100644 --- a/tests/Windows/WindowTest.php +++ b/tests/Windows/WindowTest.php @@ -29,7 +29,8 @@ ->closable() ->fullscreen() ->kiosk() - ->hideMenu(); + ->hideMenu() + ->trafficLightsHidden(); $windowArray = $window->toArray(); @@ -52,6 +53,7 @@ expect($windowArray['fullscreen'])->toBeTrue(); expect($windowArray['kiosk'])->toBeTrue(); expect($windowArray['autoHideMenuBar'])->toBeTrue(); + expect($windowArray['windowButtonVisibility'])->toBeFalse(); }); it('test title bar for window', function () { From afabe7c22bb1879fe3ad1d25977dcfe7f84e5a8d Mon Sep 17 00:00:00 2001 From: Kirill Dakhniuk Date: Mon, 1 Dec 2025 13:03:58 +0200 Subject: [PATCH 2/2] Add setWindowButtonVisibility option to hide traffic lights --- .../electron-plugin/dist/server/api/window.js | 11 ++++++++++- .../electron-plugin/src/server/api/window.ts | 13 +++++++++++++ resources/electron/electron-plugin/tests/setup.ts | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/resources/electron/electron-plugin/dist/server/api/window.js b/resources/electron/electron-plugin/dist/server/api/window.js index 4a3e399..1754f77 100644 --- a/resources/electron/electron-plugin/dist/server/api/window.js +++ b/resources/electron/electron-plugin/dist/server/api/window.js @@ -41,6 +41,12 @@ router.post('/closable', (req, res) => { (_a = state.windows[id]) === null || _a === void 0 ? void 0 : _a.setClosable(closable); res.sendStatus(200); }); +router.post('/window-button-visibility', (req, res) => { + var _a; + const { id, windowButtonVisibility } = req.body; + (_a = state.windows[id]) === null || _a === void 0 ? void 0 : _a.setWindowButtonVisibility(windowButtonVisibility); + res.sendStatus(200); +}); router.post('/show-dev-tools', (req, res) => { var _a; const { id } = req.body; @@ -145,7 +151,7 @@ function getWindowData(id) { }; } router.post('/open', (req, res) => { - let { id, x, y, frame, width, height, minWidth, minHeight, maxWidth, maxHeight, focusable, skipTaskbar, hiddenInMissionControl, hasShadow, url, resizable, movable, minimizable, maximizable, closable, title, alwaysOnTop, titleBarStyle, trafficLightPosition, vibrancy, backgroundColor, transparency, showDevTools, fullscreen, fullscreenable, kiosk, autoHideMenuBar, webPreferences, zoomFactor, preventLeaveDomain, preventLeavePage, suppressNewWindows, } = req.body; + let { id, x, y, frame, width, height, minWidth, minHeight, maxWidth, maxHeight, focusable, skipTaskbar, hiddenInMissionControl, hasShadow, url, resizable, movable, minimizable, maximizable, closable, title, alwaysOnTop, titleBarStyle, trafficLightPosition, windowButtonVisibility, vibrancy, backgroundColor, transparency, showDevTools, fullscreen, fullscreenable, kiosk, autoHideMenuBar, webPreferences, zoomFactor, preventLeaveDomain, preventLeavePage, suppressNewWindows, } = req.body; if (state.windows[id]) { state.windows[id].show(); state.windows[id].focus(); @@ -193,6 +199,9 @@ router.post('/open', (req, res) => { return { action: "deny" }; }); } + if (process.platform === 'darwin') { + window.setWindowButtonVisibility(windowButtonVisibility); + } window.on('blur', () => { notifyLaravel('events', { event: 'Native\\Desktop\\Events\\Windows\\WindowBlurred', diff --git a/resources/electron/electron-plugin/src/server/api/window.ts b/resources/electron/electron-plugin/src/server/api/window.ts index b168bb6..8b5dcbe 100644 --- a/resources/electron/electron-plugin/src/server/api/window.ts +++ b/resources/electron/electron-plugin/src/server/api/window.ts @@ -58,6 +58,14 @@ router.post('/closable', (req, res) => { res.sendStatus(200); }); +router.post('/window-button-visibility', (req, res) => { + const {id, windowButtonVisibility} = req.body; + + state.windows[id]?.setWindowButtonVisibility(windowButtonVisibility); + + res.sendStatus(200); +}); + router.post('/show-dev-tools', (req, res) => { const {id} = req.body; @@ -225,6 +233,7 @@ router.post('/open', (req, res) => { alwaysOnTop, titleBarStyle, trafficLightPosition, + windowButtonVisibility, vibrancy, backgroundColor, transparency, @@ -313,6 +322,10 @@ router.post('/open', (req, res) => { }); } + if (process.platform === 'darwin') { + window.setWindowButtonVisibility(windowButtonVisibility); + } + window.on('blur', () => { notifyLaravel('events', { event: 'Native\\Desktop\\Events\\Windows\\WindowBlurred', diff --git a/resources/electron/electron-plugin/tests/setup.ts b/resources/electron/electron-plugin/tests/setup.ts index 198961d..79b95f7 100644 --- a/resources/electron/electron-plugin/tests/setup.ts +++ b/resources/electron/electron-plugin/tests/setup.ts @@ -37,6 +37,7 @@ mockForNodeRequire('electron', () => ({ on: vi.fn(), setMenu: vi.fn(), setMenuBarVisibility: vi.fn(), + setWindowButtonVisibility: vi.fn(), webContents: { on: vi.fn(), send: vi.fn(),