Skip to content

Commit 462c9ab

Browse files
committed
Use the Window class
1 parent 7824b5c commit 462c9ab

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/Windows/Window.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class Window
4040

4141
protected bool $focusable = true;
4242

43+
protected bool $focused = false;
44+
4345
protected bool $hasShadow = true;
4446

4547
protected bool $frame = true;
@@ -282,4 +284,13 @@ public function afterOpen(callable $cb): static
282284

283285
return $this;
284286
}
287+
288+
public function fromRuntimeWindow(object $window): static
289+
{
290+
foreach ($window as $key => $value) {
291+
$this->{$key} = $value;
292+
}
293+
294+
return $this;
295+
}
285296
}

src/Windows/WindowManager.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,22 @@ public function hide($id = null)
3030
]);
3131
}
3232

33-
public function current()
33+
public function current(): Window
3434
{
35-
return (object) $this->client->get('window/current')->json();
35+
$window = (object) $this->client->get('window/current')->json();
36+
37+
return (new Window($window->id))
38+
->setClient($this->client)
39+
->fromRuntimeWindow($window);
40+
}
41+
42+
public function get(string $id): Window
43+
{
44+
$window = (object) $this->client->get("window/get/{$id}")->json();
45+
46+
return (new Window($window->id))
47+
->setClient($this->client)
48+
->fromRuntimeWindow($window);
3649
}
3750

3851
public function resize($width, $height, $id = null)

0 commit comments

Comments
 (0)