|
3 | 3 | namespace Native\Laravel; |
4 | 4 |
|
5 | 5 | use Native\Laravel\Client\Client; |
6 | | -use Illuminate\Support\Facades\Log; |
7 | 6 |
|
8 | 7 | class Screen |
9 | 8 | { |
10 | | - public function __construct(protected Client $client) |
11 | | - { |
12 | | - } |
13 | | - |
14 | | - public function getClient() |
15 | | - { |
16 | | - return $this->client; |
17 | | - } |
18 | | - |
19 | | - public function cursorPosition(): object |
20 | | - { |
21 | | - return (object) $this->client->get("screen/cursor-position")->json(); |
22 | | - } |
23 | | - |
24 | | - public function displays(): array |
25 | | - { |
26 | | - return $this->client->get("screen/displays")->json("displays"); |
27 | | - } |
28 | | - |
29 | | - public function primary(): object |
30 | | - { |
31 | | - return $this->client->get("screen/primary-display")->json("primaryDisplay"); |
32 | | - } |
33 | | - |
34 | | - public function active(): object |
35 | | - { |
36 | | - return $this->client->get("screen/active")->json(); |
37 | | - } |
38 | | - |
39 | | - /** |
40 | | - * Returns the center of the screen where the mouse pointer is placed. |
41 | | - * |
42 | | - * @return array<string,int> |
43 | | - */ |
44 | | - public function getCenterOfActiveScreen(): array |
45 | | - { |
46 | | - /* Navigate every screen and check for cursor position against the bounds of the screen. */ |
47 | | - $activeScreen = $this->active(); |
48 | | - |
49 | | - $bounds = $activeScreen["bounds"]; |
50 | | - |
51 | | - return [ |
52 | | - "x" => $bounds["x"] + $bounds["width"] / 2, |
53 | | - "y" => $bounds["y"] + $bounds["height"] / 2, |
54 | | - ]; |
55 | | - } |
| 9 | + public function __construct(protected Client $client) |
| 10 | + { |
| 11 | + } |
| 12 | + |
| 13 | + public function cursorPosition(): object |
| 14 | + { |
| 15 | + return (object) $this->client->get("screen/cursor-position")->json(); |
| 16 | + } |
| 17 | + |
| 18 | + public function displays(): array |
| 19 | + { |
| 20 | + return $this->client->get("screen/displays")->json("displays"); |
| 21 | + } |
| 22 | + |
| 23 | + public function primary(): object |
| 24 | + { |
| 25 | + return $this->client->get("screen/primary-display")->json("primaryDisplay"); |
| 26 | + } |
| 27 | + |
| 28 | + public function active(): object |
| 29 | + { |
| 30 | + return $this->client->get("screen/active")->json(); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Returns the center of the screen where the mouse pointer is placed. |
| 35 | + * |
| 36 | + * @return array<string,int> |
| 37 | + */ |
| 38 | + public function getCenterOfActiveScreen(): array |
| 39 | + { |
| 40 | + /* Navigate every screen and check for cursor position against the bounds of the screen. */ |
| 41 | + $activeScreen = $this->active(); |
| 42 | + |
| 43 | + $bounds = $activeScreen["bounds"]; |
| 44 | + |
| 45 | + return [ |
| 46 | + "x" => $bounds["x"] + $bounds["width"] / 2, |
| 47 | + "y" => $bounds["y"] + $bounds["height"] / 2, |
| 48 | + ]; |
| 49 | + } |
56 | 50 | } |
0 commit comments