Skip to content

Commit 405dc51

Browse files
committed
added methods, cleaned imports, restored 4 spaces indent and removed useless method.
1 parent fc7a859 commit 405dc51

File tree

2 files changed

+43
-47
lines changed

2 files changed

+43
-47
lines changed

src/Facades/Screen.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @method static object cursorPosition()
99
* @method static array displays()
1010
* @method static array getCenterOfActiveScreen()
11+
* @method static array active()
12+
* @method static array primary()
1113
*/
1214
class Screen extends Facade
1315
{

src/Screen.php

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,48 @@
33
namespace Native\Laravel;
44

55
use Native\Laravel\Client\Client;
6-
use Illuminate\Support\Facades\Log;
76

87
class Screen
98
{
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+
}
5650
}

0 commit comments

Comments
 (0)