Skip to content
Merged
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
15 changes: 15 additions & 0 deletions resources/electron/electron-plugin/src/server/api/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ router.post('/maximize', (req, res) => {
res.sendStatus(200);
});

router.post('/unmaximize', (req, res) => {
const { id } = req.body;

state.windows[id]?.unmaximize();

res.sendStatus(200);
});

router.post('/minimize', (req, res) => {
const { id } = req.body;

Expand Down Expand Up @@ -348,6 +356,13 @@ router.post('/open', (req, res) => {
});
});

window.on('unmaximize', () => {
notifyLaravel('events', {
event: 'Native\\Desktop\\Events\\Windows\\WindowUnmaximized',
payload: [id],
});
});

window.on('show', () => {
notifyLaravel('events', {
event: 'Native\\Desktop\\Events\\Windows\\WindowShown',
Expand Down
26 changes: 26 additions & 0 deletions src/Events/Windows/WindowUnmaximized.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Native\Desktop\Events\Windows;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class WindowUnmaximized implements ShouldBroadcastNow
{
use Dispatchable, InteractsWithSockets, SerializesModels;

public function __construct(public string $id)
{
//
}

public function broadcastOn()
{
return [
new Channel('nativephp'),
];
}
}
1 change: 1 addition & 0 deletions src/Facades/Window.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @method static void alwaysOnTop($alwaysOnTop = true, $id = null)
* @method static void reload($id = null)
* @method static void maximize($id = null)
* @method static void unmaximize($id = null)
* @method static void minimize($id = null)
* @method static void zoomFactor(float $zoomFactor = 1.0)
* @method static void preventLeaveDomain(bool $preventLeaveDomain = true)
Expand Down
7 changes: 7 additions & 0 deletions src/Windows/WindowManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ public function maximize($id = null): void
]);
}

public function unmaximize($id = null): void
{
$this->client->post('window/unmaximize', [
'id' => $id ?? $this->detectId(),
]);
}

public function minimize($id = null): void
{
$this->client->post('window/minimize', [
Expand Down
Loading