-
-
Notifications
You must be signed in to change notification settings - Fork 191
/
Copy pathScreen.php
48 lines (38 loc) · 1.15 KB
/
Screen.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Native\Laravel;
use Native\Laravel\Client\Client;
class Screen
{
public function __construct(protected Client $client) {}
public function cursorPosition(): object
{
return (object) $this->client->get('screen/cursor-position')->json();
}
public function displays(): array
{
return $this->client->get('screen/displays')->json('displays');
}
public function primary(): array
{
return $this->client->get('screen/primary-display')->json('primaryDisplay');
}
public function active(): array
{
return $this->client->get('screen/active')->json();
}
/**
* Returns the center of the screen where the mouse pointer is placed.
*
* @return array<string,int>
*/
public function getCenterOfActiveScreen(): array
{
/* Navigate every screen and check for cursor position against the bounds of the screen. */
$activeScreen = $this->active();
$bounds = $activeScreen['bounds'];
return [
'x' => $bounds['x'] + $bounds['width'] / 2,
'y' => $bounds['y'] + $bounds['height'] / 2,
];
}
}